What you're trying to do is possible without .def files
or import files or whatever.

Just put something like this in sqlite3.h before everything:

#ifdef _WIN32
 #define S3EXPORT __declspec(dllexport)
 #define S3IMPORT __declspec(dllimport)
 #define S3CALL   __stdcall
 #ifdef _S3_USER_DLL_IMPLEMENTATION_
  #define S3IMPEXP S3EXPORT
 #else
  #define S3IMPEXP S3IMPORT
 #endif
#else
 #define S3EXPORT
 #define S3IMPORT
 #define S3CALL
 #define S3IMPEXP
#endif

And annotate your exportable function declarations and 
implementations accordingly.

When you compile sqlite3.dll or sqlite3.exe you compile with

 -U_S3_USER_DLL_IMPLEMENTATION_

or simply do not define it.
When a user compiles their own code/DLL they must compile
with this flag:

 -D_S3_USER_DLL_IMPLEMENTATION_

For every single function that you want accessible to 3rd party 
DLLs you must prepend with the S3CALL macro just before the 
function name - this also includes function pointers. 
Before the return code you need to prepend the S3IMPEXP macro.

 S3IMPEXP int S3CALL sqlite3_open(
   const char *filename,   /* Database filename (UTF-8) */
   sqlite3 **ppDb          /* OUT: SQLite db handle */
 );

Each User DLL must have well known function(s) for sqlite 
to call the user's code. They must be declared as follows:

 S3EXPORT int S3CALL MyExampleDllEntryPoint(int whatever);

This is a good source of information of how to make Java JNI DLLs
with MinGW - basically the same thing you're trying to do:

 http://www.mingw.org/mingwfaq.shtml#faq-jni-dll

Notice that a .def file is nowhere to be seen.

All this symbol import/export nonsense does have advantages - 
it speeds up the loading/linking of symbols in shared libraries,
and it reduces symbol pollution when you have to dynamically 
load/link several shared libraries into the same program, reducing
the chance of symbol collision.

GCC has recognized this fact and has added a similar feature
to its compiler:

  http://gcc.gnu.org/wiki/Visibility



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Reply via email to