Memory Assertion when linking against Casablanca

Mar 22, 2015 at 8:20 AM
Edited Mar 22, 2015 at 8:22 AM
Hi there,

I'm just starting exploring this library and it's really great!

I wrote some simple testing code posting HTTP POST request and it works perfectly in my testing application. However, when I'm adding same code to existing big solution, I'm getting the memory assertions.

Details of the project which has to use Casablanca are below. Since this project is a part of large shared solution, I don't have an option to change these settings...
  • DLL
  • Use MFC in a Static Library
  • Multithreaded Debug (/MTd)
It's failing almost immediately during a constructor call of uri_builder, at the object's destructing stage...
    http_client client( L"http://<host>/" );

    // Build request URI and start the request.
    uri_builder builder( L"<path>" );  //MEMORY ASSERTION
_ASSERTE(_pFirstBlock == pHead);
I thought that this may be related to allocated memory crossing the DLL boundaries, but the constructor takes const reference:
uri_builder(const uri &uri_str) it should work fine... Also, if there is some heap memory issues, why the first statement (http_client client( L"http://<host>/" );) doesn't asser? Obviously, I'm missing something...

Please help!
Mar 22, 2015 at 9:46 AM
Edited Mar 22, 2015 at 10:18 AM
I've looked at the other threads and it seems that there no other way than to build a static library from source code...

So I've followed this blog post: and built the static cpprestsdk library.

I've also looked at this thread and found some additional tips to make it work..

So now when I link produced lib to existing project, I was still getting few linker errors from oauth1.obj and web_utilities.obj as below. Is it related to some recent changes in the C++ REST SDK project, which were not present at the time of above posts?

So, finally, to be able to link without errors, I had to add these libraries:


Is it correct way of doing this? Also does linking against above Windows libraries makes it no cross-platform any longer?

Thanks a lot!
Mar 23, 2015 at 5:32 PM
Hi olegshirokikh,

Yes there have been changes since that blob post written by someone almost a year ago. We are always making improvements and fixing bugs.

Yes the WinHTTP Windows crypto libraries you've mentioned are necessary. Regarding "Also does linking against above Windows libraries makes it no cross-platform any longer?" We don't have a single cross platform binary. You have to recompile for each of the different platforms you want to target. For example if you wanted to run on OS X.