On Thu, 22 Oct 2015 15:23:38 +0200
"Marco Turco" <m.turco at softwarexp.co.uk> wrote:

> The problem is when I link the generated library. I receive the
> following error related to the first two warnings so I'm unable to
> generate the executable file.

You've solved the problem by compiling for a single-threaded
environment.  I wanted to point you toward the generic solution to the
warnings and errors in case you want to use __beginthreadex.  I suspect
the advice you got about changing your compiler switches is correct;
that's what you would do with Microsoft's compiler.  

> Warning W8065 K:\sqlite_see_2013\sqlite3.c 23909: Call to function
> '_endthreadex' with no prototype in function sqlite3ThreadProc

That indicates you're notincluding the .h file that declares the
_endthreadex function.  

Unlike some other advice you might get, I'm not so sanguine about
prototype warnings. The C language permits, but does not require, the
use of functional prototypes.  When you ignore a warning about a
missing prototype, you deny yourself the parameter checking the
compiler could otherwise provide.  

> Error: Unresolved external '__endthreadex'
> referenced from K:\ACTIVEXP\SOURCE\SQLITE.SEE\SQLITE3.LIB|sqlite3

To be pedantic, that is a linker error, not a compiler error.  In this
case you're missing the library that supplies _endthreadex.  According
to Microsoft [1], it's supplied by the C run-time library.  That almost
certainly means you need to set your compile options accordingly.  

Why change compilation just to link to another library?  Normally you
don't; you just add a library name to the linker command.  In the case
of Microsoft and the C runtime, though, some of the symbols differ
between single- and multi-threaded (and release and debug) builds.  You
call function foo, but it might generate e.g. foo_debug_mt, or might
issue locks, or might replace the call with a bullt-in intrinsic or
macro.  

That's why Microsoft (and likely Embarcadero) use a compiler option.
Because of the tight coupling of compile modes and required library,
they need to be controlled together, and the simplest way to do that is
to give one option to the compiler and let it DTRT. 

> At the end I have added the parameter -DSQLITE_THREADSAFE=0 to
> exclude the multithread code from the library 

Yup, that's the other way; change the SQLite code to be
single-threaded.  

HTH.  

--jkl

[1] https://msdn.microsoft.com/en-us/library/hw264s73.aspx

Reply via email to