Can't get methods::GET or any of the "macro processed includes" in http_msg.h to properly work.

Nov 6, 2014 at 6:23 AM
I'm trying to use Casablanca for simple rest queries in a Windows Phone 8.1 application. I've cloned the repo and built the cpprest120_wp81_2_2.lib and cpprest120_wp81_2_2.dll which I've then included in the application, I also add additional include directories to Point to the include directory in the Casablanca repo.

Everything compiles and links, but when I try to run I constantly break on any of the lines trying to resolve any of the methods::<ANYTHING HERE> or headers::<ANYTHING HERE>.

It seems like the macros really isn't being processed properly but how can I fix this? I've managed to use NuGet packages successfully but unfortunately that is not an option in the real build process we're using.

Please advise...

Regards

Johan Lindfors
//coderox
Coordinator
Nov 6, 2014 at 6:42 AM
Edited Nov 6, 2014 at 6:43 AM
Hi Johan,

Could you be more specific about
... I constantly break on any of the lines trying to resolve any of the methods::<ANYTHING HERE> or headers::<ANYTHING HERE>.
Also, as a diagnostic test, could you try this:
  • Compile your program which breaks
  • Ensure it does break
  • Without recompiling, replace the .dll in the runtime folder with the one from the NuGet package
  • Does it still break?
If the program still breaks, then the dll you've built is probably fine and somehow your program's headers/macros/somethings are interacting badly with the cpprestsdk headers. If the program does not break, then the problem is likely in the build process for the cpprestsdk dll/lib (And your program is fine :)).

In the case it's an issue with the dll/lib build process, could you detail exactly what steps you used to build the dll?

Edit: Note that the above is assuming you built from the master branch.

Thanks,
roschuma
Nov 6, 2014 at 7:28 AM
Hi Roschuma!

I appreciate you taking time in helping me with this! I've tried the proposed solution above with no success.

I've also reproduced this behaviour by creating a simple blank solution for Windows Phone, and then installing the nuget package for cpprestsdk.

After that I add #include "cpprest/http_client.h" in one of the source files and then in a method I try to instansiate web::http::http_request request(web::http::methods::GET);

This works perfectly when being run.

I then remove the nuget package (but first I make a copy of the packages/cpprest.2.2.0 directory) by using "uninstall-package

I then manually add the appropriate lib file from the recently copied directory, and also add the dll from the runtime directory. I also make sure to add the additional include for the include directory. Once again, everything compiles and runs, but when hitting the line where I create the instance of the http_request it now breaks (and crashes if I don't catch exceptions).

So I guess there's some preprocessor directive that isn't properly set, but I can't figure out which. I've looked at the .targets file but wasn't succesful in figuring out...

Once again, thanks!

Johan
Nov 6, 2014 at 7:40 AM
Edited Nov 6, 2014 at 9:51 AM
I'm sorry, I managed to get it to work now, by also setting the preprocessor: HAS_CPPRESTSDK

Also, something that must be properly aligned is the Debug and Release versions of the app and lib.

It now works just fine, and it's once again, my bad!!! :)

Thanks for your help!

Johan
Marked as answer by JohanLindfors on 11/6/2014 at 12:41 AM