Linking LibRaw

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

Linking LibRaw

Postby AndyPhotosBell » Sat May 09, 2020 1:16 pm


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?


Posts: 4
Joined: Fri May 08, 2020 3:59 am

Re: Linking LibRaw

Postby AndyPhotosBell » Sun May 10, 2020 10:42 am

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.

Posts: 4
Joined: Fri May 08, 2020 3:59 am

Re: Linking LibRaw

Postby rlebeau » Mon May 11, 2020 2:11 pm

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.
Remy Lebeau (TeamB)
Lebeau Software
User avatar
BCBJ Author
BCBJ Author
Posts: 1669
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA

Return to Technical

Who is online

Users browsing this forum: No registered users and 45 guests