Linking LibRaw

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

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

Linking LibRaw

Post by AndyPhotosBell »

Hi

I'm using C++ Builder 2007 and LibRaw (http://www.libraw.org) 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
{
public:
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?

Thanks

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

Re: Linking LibRaw

Post by AndyPhotosBell »

I found this:

http://bcbjournal.org/articles/vol4/001 ... 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.

Andy
rlebeau
BCBJ Author
BCBJ Author
Posts: 1716
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA
Contact:

Re: Linking LibRaw

Post 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.
Remy Lebeau (TeamB)
Lebeau Software
Post Reply