0

I need to do a http get in RAD Studio XE5 C++. The tutorials on the RAD Studio site discuss a RESTCLient that is not included with the version I have. I found the Casablanca project, which is specifically for Visual Studio, and I made a small program in VS that does the simple http get and handles response in the way I need.

What do I need to do to successfully use Casablanca from within RAD Studio?

There are the steps I have taken so far.

  1. Compiled Casablanca in Visual Studio 2013
  2. Copied the .lib and .dll over to a folder in the RAD Studio project
  3. added that folder to the link path in the RAD Studio project
  4. added the .lib to the project
  5. added dll imports to classes that should be in the .lib to the .cpp I want to use the function in.

class __declspec(dllimport) http_client;
class __declspec(dllimport) filestream; 
class __declspec(dllimport) producerconsumerstream; 
class __declspec(dllimport) rawptrstream; 

  1. There was a OMF error, and I used a tool that came with RAD Studio to convert the .lib, that got past the error.

I don't know how to declare the dll prototype's of the functions, because the returns types are from a namespace in the library itself so they aren't recognized. http_client is an unrecognized structure.

I tried this as well without the class keyword.

Mariano D'Ascanio
  • 1,202
  • 2
  • 16
  • 17

1 Answers1

0

DLLs that export classes are not portable across compilers. So you will not be able to use a Visual Studio compiled DLL in C++Builder if it exports classes. Either flatten the DLL interface to export plain C-style functions instead (and then use C++Builder's command-line IMPLIB tool to create an import .lib file for the DLL, do not use the .lib file created by Visual Studio), or else find another solution.

For instance, C++Builder (and Delphi) ships with Indy 10, which has a TIdHTTP component. You can use its TIdHTTP::Get() method to perform an HTTP GET request. But if you need to actually use REST, you might be better off simply upgrading your XE5 to a version that has TRESTClient available (BTW, Embarcadero's REST classes use Indy internally).

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770