Question: why is there no __declspec(dllexport) or __declspec(dllimport) ?
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).
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!
Hi @sorinmustaca, by any chance, would you be able to share your patch on this? I am still interested.
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).
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!
I've run into this problem as well...would be good if there was an official fix.
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 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.
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 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
My attempt can be found here - https://github.com/SRombauts/SQLiteCpp/pull/406
fixed in #406