Because CAD development requires requesting data from the server, request data through WebAPI set up on the server before, so libcurl was installed to use data in ObjectARX.
Open VS2012 x64 Native Tools Command Prompt Supplemental address:

I will place the relevant reference configuration images here. The application inside CAD is consistent with the routine.

![Image Description](https://cdn.bimath.com/blog/pg/Snipaste_2026-01-04_16-06-56.png)
![Image Description](https://cdn.bimath.com/blog/pg/Snipaste_2026-01-04_16-07-00.png)
![Image Description](https://cdn.bimath.com/blog/pg/Snipaste_2026-01-04_16-07-05.png)
![Image Description](https://cdn.bimath.com/blog/pg/Snipaste_2026-01-04_16-07-08.png)

All usage is consistent with the current case, but an error occurred here, which I record here. In the code below, when I ran the program, CAD reported a memory leak. After positioning the problem, I found the error in this line:

1
CURLcode res = curl_easy_perform(curl);

I checked many articles and couldn’t solve it. Later I found that it was actually a data transfer error here. My pointer transfer error caused the problem.
Here is the problematic code snippet:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
inline BOOL webApi::DownloadFile(const char* Filepath)
{
// ...

curl_easy_setopt(curl, CURLOPT_URL, combinePath.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &webApi::curlWriteFunction);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
CURLcode result = curl_easy_perform(curl);

fclose(fp);
curl_easy_cleanup(curl);

curl_global_cleanup();

return TRUE;
}

You can see that I passed a pointer in this line of code

1
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &webApi::curlWriteFunction);

The problem arises here because what needs to be called here is a function pointer to the callback function, but I used an instance function pointer in my code, leading to incorrect value passing, which caused subsequent problems.
Modified to:

1
2
3
4
5
6
7
8
9
10
11
12
webapi.h
static size_t downloadCallback(void *buffer, size_t sz, size_t nmemb, void *writer);

webapi.cpp
size_t webApi::downloadCallback(void* buffer, size_t sz, size_t nmemb, void* writer)
{
std::string* psResponse = (std::string*)writer;
size_t size = sz * nmemb;
psResponse->append((char*)buffer, size);

return sz * nmemb;
}

Then modify the original code segment:

1
2
3
4
5
6
7
8
9
10
std::string strTmpStr;
CURL *curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, strUrl.c_str());
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1L);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 20);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, downloadCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &strTmpStr);
CURLcode res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
std::string strRsp;

Problem solved.