Discussion:
[sqlite] Problems making sqlite.lib using Embarcadero C++ 7.00
Marco Turco
10 years ago
Permalink
Hi all,

I'm trying to generate the sqlite3 library but there is no way with
Embercadero C++ 7.00.

I always receive some warnings and the first two related to the
_endthreadex' and '_beginthreadex' cannot permit to link me the library.



See below.



k:\BCC70\Bin\Bcc32.Exe -DHB_NO_DEFAULT_API_MACROS -M -c -O2 -e -tW
-DHB_NO_DEFAULT_STACK_MACROS -DHB_OS_WIN_USED -DHB_FM_STATISTICS_OFF
-D__HARBOUR__ -DSQLITE_HAS_CODEC=1 -Ik:\BCC70\Include;k:\XHARBOUR\Include
-nK:\sqlite_see_2013\Obj K:\sqlite_see_2013\sqlite3.c



Embarcadero C++ 7.00 for Win32 Copyright (c) 1993-2015 Embarcadero
Technologies, Inc.

K:\sqlite_see_2013\sqlite3.c:

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

Warning W8065 K:\sqlite_see_2013\sqlite3.c 23936: Call to function
'_beginthreadex' with no prototype in function sqlite3ThreadCreate

Warning W8057 K:\sqlite_see_2013\sqlite3.c 38624: Parameter 'iOff' is never
used in function winUnfetch

Warning W8060 K:\sqlite_see_2013\sqlite3.c 80952: Possibly incorrect
assignment in function vdbeSorterCompareInt

Warning W8060 K:\sqlite_see_2013\sqlite3.c 82583: Possibly incorrect
assignment in function vdbeSorterSetupMerge

Warning W8057 K:\sqlite_see_2013\sqlite3.c 185433: Parameter 'iDb' is never
used in function sqlite3CodecGetKey

k:\BCC70\Bin\TLib.Exe K:\sqlite_see_2013\sqlite_see_2013.Lib /P512
@K:\sqlite_see_2013\sqlite_see_2013.bcl ,
K:\sqlite_see_2013\Debug\sqlite_see_2013.Lst



TLIB 6.4 Copyright (c) 1987-2014 Embarcadero Technologies, Inc.

+K:\sqlite_see_2013\Obj\sqlite3.Obj



Any help ? Thank you in advance



Marco
R.Smith
10 years ago
Permalink
...
These are just warnings... They are not important and it should still
compile.

If it fails to compile you should get a message like this:
"Error nnnn: Failed to compile K:\sqlite_see_2013\sqlite3.c 185433: Some
description of what failed"

The warnings doesn't mean it did not compile. What makes you think the
file failed to compile, is the actual compiled file missing or such?
Post by Marco Turco
TLIB 6.4 Copyright (c) 1987-2014 Embarcadero Technologies, Inc.
+K:\sqlite_see_2013\Obj\sqlite3.Obj
Any help ? Thank you in advance
Marco
_______________________________________________
sqlite-users mailing list
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Marco Turco
10 years ago
Permalink
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.

Embarcadero C++ 7.00 for Win32 Copyright (c) 1993-2015 Embarcadero Technologies, Inc.
K:\RENTMNG\Obj\mod306f.c:
k:\BCC70\Bin\iLink32.Exe -Gn -aa -Tpe -s @K:\RENTMNG\RENTMNG.bcl

Turbo Incremental Link 6.70 Copyright (c) 1997-2014 Embarcadero Technologies, Inc.
Error: Unresolved external '__endthreadex' referenced from K:\ACTIVEXP\SOURCE\SQLITE.SEE\SQLITE3.LIB|sqlite3
Error: Unresolved external '__beginthreadex' referenced from K:\ACTIVEXP\SOURCE\SQLITE.SEE\SQLITE3.LIB|sqlite3
Error: Unable to perform link

Marco

-----Original Message-----
From: sqlite-users-***@mailinglists.sqlite.org [mailto:sqlite-users-***@mailinglists.sqlite.org] On Behalf Of R.Smith
Sent: Thursday, October 22, 2015 12:12 PM
To: sqlite-***@mailinglists.sqlite.org
Subject: Re: [sqlite] Problems making sqlite.lib using Embarcadero C++ 7.00
...
These are just warnings... They are not important and it should still compile.

If it fails to compile you should get a message like this:
"Error nnnn: Failed to compile K:\sqlite_see_2013\sqlite3.c 185433: Some description of what failed"

The warnings doesn't mean it did not compile. What makes you think the file failed to compile, is the actual compiled file missing or such?
Post by Marco Turco
TLIB 6.4 Copyright (c) 1987-2014 Embarcadero Technologies, Inc.
+K:\sqlite_see_2013\Obj\sqlite3.Obj
Any help ? Thank you in advance
Marco
_______________________________________________
sqlite-users mailing list
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
James K. Lowden
10 years ago
Permalink
On Thu, 22 Oct 2015 15:23:38 +0200
Post by Marco Turco
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.
Post by Marco Turco
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.
Post by Marco Turco
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.
Post by Marco Turco
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
Clemens Ladisch
10 years ago
Permalink
Post by James K. Lowden
On Thu, 22 Oct 2015 15:23:38 +0200
Post by Marco Turco
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.
No; the single-threaded environment is the problem.
Post by James K. Lowden
Post by Marco Turco
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.
_endthreadex is declared in process.h, which SQLite includes.
However, that header takes care to omit this declaration when
compiling in single-threaded mode.


Regards,
Clemens
James K. Lowden
10 years ago
Permalink
On Tue, 27 Oct 2015 12:24:03 +0100
Post by Clemens Ladisch
Post by James K. Lowden
You've solved the problem by compiling for a single-threaded
environment.
No; the single-threaded environment is the problem.
That's a matter of opinion. Another way to look at it: threads set
back computing by 20 years.

Protected memory was invented for good reason. Then it was uninvented,
and we're still dealing with the fallout. Software transactional
memory has so far failed to pass muster, and communicating sequential
processes has still not seen implementation support in most
languages.

--jkl
Dominique Devienne
10 years ago
Permalink
...
Most languages, true. But one (new'ish) language, Go [1],
embraced CSP from the get go [2].

This talk [3] by Rob Pike, one of the three fathers of Go,
featured on the front page [1] discusses specifically Go's CSP
implementation.
It goes hand-in-hand with this other "classical" Go talk [4]: Concurrency
Is Not Parallelism.

[1] https://golang.org/
[2] https://blog.golang.org/share-memory-by-communicating
[3]

[4]


Clemens Ladisch
10 years ago
Permalink
...
My Borland C++ 5.5.1 (the old, free version) needs -tWM for a multithreaded
program; you're using -tW.


Regards,
Clemens
Marco Turco
10 years ago
Permalink
Hi,
could you please give me the full Bcc32 string you are using ?

thank you

Marco

-----Original Message-----
From: sqlite-users-***@mailinglists.sqlite.org [mailto:sqlite-users-***@mailinglists.sqlite.org] On Behalf Of Clemens Ladisch
Sent: Thursday, October 22, 2015 4:22 PM
To: sqlite-***@mailinglists.sqlite.org
Subject: Re: [sqlite] Problems making sqlite.lib using Embarcadero C++ 7.00
...
My Borland C++ 5.5.1 (the old, free version) needs -tWM for a multithreaded program; you're using -tW.


Regards,
Clemens
Clemens Ladisch
10 years ago
Permalink
Post by Marco Turco
could you please give me the full Bcc32 string you are using ?
That would not be useful for you; I'm using an incompatible calling convention.

Just replace "-tW" with "-tWM".


Regards,
Clemens
Marco Turco
10 years ago
Permalink
Solved.
At the end I have added the parameter -DSQLITE_THREADSAFE=0 to exclude the multithread code from the library

Thank you.

Marco

-----Original Message-----
From: sqlite-users-***@mailinglists.sqlite.org [mailto:sqlite-users-***@mailinglists.sqlite.org] On Behalf Of Clemens Ladisch
Sent: Thursday, October 22, 2015 8:51 PM
To: sqlite-***@mailinglists.sqlite.org
Subject: Re: [sqlite] Problems making sqlite.lib using Embarcadero C++ 7.00
Post by Marco Turco
could you please give me the full Bcc32 string you are using ?
That would not be useful for you; I'm using an incompatible calling convention.

Just replace "-tW" with "-tWM".


Regards,
Clemens
Scott Doctor
10 years ago
Permalink
I am using Embarcadero's development studio and compiling in the sqlite
amalgamation. You can just turn off those two warnings.

To turn it off for whole project:
Select the Projects menu Options
Under the C++ Compiler options select the warnings
Open the options for selected warnings.
scroll down to those two warnings and disable them.

To turn off the warnings just for sqlite, just right click on the
sqlite.c file name, select the local options. the same project options
menu opens, but will apply only to that file.

If you try to compile the SQLite amalgamation with all warnings on, you
will get over 600 of them. Most warnings are for unused variables, and
variables that are assigned a value but never used

I examined those particular ones. It is due to assigning a variable
within an 'if'. Although it has double parenthesis around it, which is
supposed to indicate that the assignment is intended, it still gives the
warning for some reason on some of them. That is an important warning as
that is usually a nasty bug where a single equals is used instead of a
double equals for an equivalence comparison.

Although that style makes for more compact code by doing the assignment
at the same time as the logic test, I find that it is a safer practice
to do the assignment just before the 'if' then test the variable. From a
debugging point of view it is much easier to set a break point on the if
statement and see the actual result being checked. I did a few compile
tests. with the optimizer, the resulting compiled code was identical
either way..

------------
Scott Doctor
...