Page 1 of 1

Linking LibRaw

PostPosted: Sat May 09, 2020 1:16 pm
by AndyPhotosBell

I'm using C++ Builder 2007 and LibRaw ( to decode RAW images from digital cameras.

The LibRaw DLL is built with MSVC.

I've built an import library with ImpLib and can use the basic functions in the supplied header file, with a few adjustments to it.

However, I'm stumped with the following section:

#ifdef __cplusplus

class DllDef LibRaw
libraw_data_t imgdata;
int verbose;

LibRaw(unsigned int flags = LIBRAW_OPTIONS_NONE);
libraw_output_params_t *output_params_ptr() { return &imgdata.params; }

//loads more functions

DllDef translates to #define DllDef __declspec(dllimport)

If I use class LibRaw in my code I get linker errors over its constructor and destructor.

For its non class functions I change DllDef to something like

extern "C" void __stdcall func();

and these link and run properly.

But I can't find a way to make the class LibRaw link properly.

Is it possible to?



Re: Linking LibRaw

PostPosted: Sun May 10, 2020 10:42 am
by AndyPhotosBell
I found this: ... uilder.htm

And it's convinced me not to attempt it. I was able to adjust the library's C API to access the method I was after.


Re: Linking LibRaw

PostPosted: Mon May 11, 2020 2:11 pm
by rlebeau
AndyPhotosBell wrote:The LibRaw DLL is built with MSVC

Unfortunately, you can't use classes across the DLL boundary with different compilers (except for COM interfaces, since there is a common ABI that all compilers have to conform to for COM). Your only hope will be if the LibRaw class is implemented inside the library's header file as inline calls to flat C-style functions. Otherwise, if the LibRaw class's methods are actually implemented inside the DLL then you are SOL.