SQLiteCpp icon indicating copy to clipboard operation
SQLiteCpp copied to clipboard

Question: why is there no __declspec(dllexport) or __declspec(dllimport) ?

Open sorinmustaca opened this issue 8 years ago • 11 comments

I need to compile everything as a DLL in order to be used from multiple programs. I have to define in SQLiteCPP.h #ifdef SDK_EXPORTS #define DLL_API __declspec(dllexport) #pragma message("Exporting symbols") #else #define DLL_API __declspec(dllimport) #pragma message("Importing symbols") #endif

and then change every class to be exportable/importable:

class DLL_API ClassName.

Is there a reason why not preparing the code for being used in a DLL ?

If no, I am happy to provide a patch to use this (even if the change is more than trivial).

sorinmustaca avatar May 24 '17 10:05 sorinmustaca

Yes, you are welcome to provide the fix!

Someone else already tried to provide a Pull Request but it was not compiling for all platforms and was never merged, see #57

Cheers!

SRombauts avatar May 24 '17 10:05 SRombauts

Hi @sorinmustaca, by any chance, would you be able to share your patch on this? I am still interested.

SRombauts avatar Dec 18 '17 14:12 SRombauts

Would it be acceptable to implement this change based on a cmake-generated header for symbol visibility? cmake has everything built in to generate the header and required defines for building vs. using the library. But it would work only as long as SQLiteCpp is built with cmake (any generator and platform).

emmenlau avatar Oct 24 '19 15:10 emmenlau

No activity in 3 years. Any chance this could be bumped up? The dllexport/dllimport code is needed to build this as a shared library. Thanks!

michaeldurland avatar Oct 26 '22 18:10 michaeldurland

I've run into this problem as well...would be good if there was an official fix.

pierre-aimi avatar Feb 02 '23 04:02 pierre-aimi

Hello, like I said above I would be willing to take the time to review a PR for the above; I am myself not using DLLs anymore these days. IIRC someone proposed one that had some issues...

SRombauts avatar Feb 02 '23 06:02 SRombauts

@SRombauts thanks for the thumbs up! But before someone implements this, a question (copied from above): Would it be good to implement this change based on a cmake-generated header for symbol visibility? cmake has everything built in to generate the header, and it automatically adds the relevant defines during the build. This makes the change very simple and straightforward to implement with cmake. But if other make systems are used, it is not the best possible approach, and a manually crafted header may be better.

emmenlau avatar Feb 02 '23 09:02 emmenlau

It's a good question; now days we have multiple build systems/makers supported, so it's probably best to keep with the simple implementation (it's usually based on straightforward macro)

SRombauts avatar Feb 02 '23 13:02 SRombauts

@SRombauts I'm happy to have a go at this. By the way an easy fix for Sqlite3 is to conditionally add this to the CMakeLists.txt: add_definitions("-DSQLITE_API=__declspec(dllexport)") The rest in sqlitecpp would need to have the macro added manually

pierre-aimi avatar Feb 02 '23 23:02 pierre-aimi

My attempt can be found here - https://github.com/SRombauts/SQLiteCpp/pull/406

pierre-aimi avatar Feb 06 '23 08:02 pierre-aimi

fixed in #406

UnixY2K avatar Apr 01 '23 20:04 UnixY2K