Using libcurl to Request WebApi in ObjectARX
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.
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 | inline BOOL webApi::DownloadFile(const char* Filepath) |
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 | webapi.h |
Then modify the original code segment:
1 | std::string strTmpStr; |
Problem solved.



