[sqlite] problem compiling std_call dll
Thanks for clearing this up. I did wonder about this. Came across it when making a .tlb for those calls to the std_call dll. RBS On Mon, Mar 2, 2015 at 6:14 AM, Scott Robison wrote: > On Sun, Mar 1, 2015 at 10:55 PM, J Decker wrote: > > > On Sun, Mar 1, 2015 at 9:22 PM, Keith Medcalf > wrote: > > > > > >I do not know if this is the case, but typically Windows creates names > > > >like > > > >_sqlite3_db_filename at X (where X is a number) if a function is defined > > as > > > >stdcall. It doesn't *have* to do this, but that's the convention used > by > > > > > > the @X is used to include the ordinal reference (@X) in the > > symbol > > > since you can link by either name or ordinal (or, in the case of > > specially > > > constructed libraries, by both having to match). > > > > 1) the @X is the size of paramters pushed on the stack. > > 2) (something else in another mail that irked me) It's not a 'default > > calling convention for windows' it's a default calling convention for > some > > compilers; and doesn't have be even be on windows. > > > > 1. I didn't see you'd already explained the @X meaning. Sorry for > duplicating your answer. > 2. Just in case you meant me, I was not trying to say it is the default > calling convention for windows. I was saying that appending "@X" to the > symbol is the default convention used by (at least) Microsoft compilers > when using the stdcall calling convention. It's a confusing bit of > terminology what with multiple applications of the word "convention" so I > just wanted to clarify what I meant. I understand Windows does not require > everyone to use stdcall for their own APIs and such. > > -- > Scott Robison > ___ > sqlite-users mailing list > sqlite-users at mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users >
[sqlite] problem compiling std_call dll
On Sat, 28 Feb 2015 11:22:12 + Bart Smissaert wrote: > It doesn't compile and gives linking errors: > > Error 1 error LNK2001: unresolved external symbol > _sqlite3_db_filename > C:\Users\Bart\SQLiteForExcel\Source\SQLite3_StdCall > \SQLite3_StdCall.obj SQLite3_StdCall > Error 2 error LNK1120: 1 unresolved > externals C:\Users\Bart\SQLiteForExcel\Source\SQLite3_StdCall\Release > \SQLite3_StdCall.dll 1 1 SQLite3_StdCall What you mean is, it *does* compile, and then the linker emits an error. :-) > Strangely it doesn't point to a line in the block SQLITE3_STDCALL_API > but points to line 1. Not strange, or anyway not too strange. The linker doesn't know from source code. It only knows the object code references a symbol for which it found no definition. The symbol you want, sqlite3_db_filename appears to be defined in sqlite3ext.h, line 475: #define sqlite3_db_filename sqlite3_api->db_filename If you include that file, the linker shouldn't attempt to resolve the symbol, because the preprocessor defines it away. HTH. --jkl
[sqlite] problem compiling std_call dll
On Sun, Mar 1, 2015 at 10:55 PM, J Decker wrote: > On Sun, Mar 1, 2015 at 9:22 PM, Keith Medcalf wrote: > > > >I do not know if this is the case, but typically Windows creates names > > >like > > >_sqlite3_db_filename at X (where X is a number) if a function is defined > as > > >stdcall. It doesn't *have* to do this, but that's the convention used by > > > > the @X is used to include the ordinal reference (@X) in the > symbol > > since you can link by either name or ordinal (or, in the case of > specially > > constructed libraries, by both having to match). > > 1) the @X is the size of paramters pushed on the stack. > 2) (something else in another mail that irked me) It's not a 'default > calling convention for windows' it's a default calling convention for some > compilers; and doesn't have be even be on windows. > 1. I didn't see you'd already explained the @X meaning. Sorry for duplicating your answer. 2. Just in case you meant me, I was not trying to say it is the default calling convention for windows. I was saying that appending "@X" to the symbol is the default convention used by (at least) Microsoft compilers when using the stdcall calling convention. It's a confusing bit of terminology what with multiple applications of the word "convention" so I just wanted to clarify what I meant. I understand Windows does not require everyone to use stdcall for their own APIs and such. -- Scott Robison
[sqlite] problem compiling std_call dll
On Sun, Mar 1, 2015 at 10:22 PM, Keith Medcalf wrote: > >I do not know if this is the case, but typically Windows creates names > >like > >_sqlite3_db_filename at X (where X is a number) if a function is defined as > >stdcall. It doesn't *have* to do this, but that's the convention used by > > the @X is used to include the ordinal reference (@X) in the symbol > since you can link by either name or ordinal (or, in the case of specially > constructed libraries, by both having to match). This is not, however, the > "normal" case. The normal case is to export symbols only and link the > modules at load time by name. This syntax is used specifically so that > when you add a new entry ordinal to a dll, it does not get inserted into > the name table in default order, but rather that symbols keep their > previous version ordinals so that intra-version trampolines contained in > link libraries will continue to work between different versions of the load > library. > It's the size of the data pushed onto the stack by the caller and is used by the callee to clean up the stack. Not unlike the pascal calling convention. See https://en.wikipedia.org/wiki/X86_calling_conventions#stdcall ... In any case, the @X doesn't *need* to be part of the symbol (the Windows API entry points don't use it, even though they use stdcall as I understand it) as the cleanup code isn't dependent on the symbol. It's just a convention. -- Scott Robison
[sqlite] problem compiling std_call dll
>I do not know if this is the case, but typically Windows creates names >like >_sqlite3_db_filename at X (where X is a number) if a function is defined as >stdcall. It doesn't *have* to do this, but that's the convention used by the @X is used to include the ordinal reference (@X) in the symbol since you can link by either name or ordinal (or, in the case of specially constructed libraries, by both having to match). This is not, however, the "normal" case. The normal case is to export symbols only and link the modules at load time by name. This syntax is used specifically so that when you add a new entry ordinal to a dll, it does not get inserted into the name table in default order, but rather that symbols keep their previous version ordinals so that intra-version trampolines contained in link libraries will continue to work between different versions of the load library. --- Theory is when you know everything but nothing works. Practice is when everything works but no one knows why. Sometimes theory and practice are combined: nothing works and no one knows why.
[sqlite] problem compiling std_call dll
On Sun, Mar 1, 2015 at 9:22 PM, Keith Medcalf wrote: > >I do not know if this is the case, but typically Windows creates names > >like > >_sqlite3_db_filename at X (where X is a number) if a function is defined as > >stdcall. It doesn't *have* to do this, but that's the convention used by > > the @X is used to include the ordinal reference (@X) in the symbol > since you can link by either name or ordinal (or, in the case of specially > constructed libraries, by both having to match). 1) the @X is the size of paramters pushed on the stack. 2) (something else in another mail that irked me) It's not a 'default calling convention for windows' it's a default calling convention for some compilers; and doesn't have be even be on windows. there are usually command line options to set default calling conventions to fix it; and it should be well defined in the header so long as both sources includes the same prototypes and have the same settings it should work. This is not, however, the "normal" case. The normal case is to export > symbols only and link the modules at load time by name. This syntax is > used specifically so that when you add a new entry ordinal to a dll, it > does not get inserted into the name table in default order, but rather that > symbols keep their previous version ordinals so that intra-version > trampolines contained in link libraries will continue to work between > different versions of the load library. > > --- > Theory is when you know everything but nothing works. Practice is when > everything works but no one knows why. Sometimes theory and practice are > combined: nothing works and no one knows why. > > > > > ___ > sqlite-users mailing list > sqlite-users at mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users >
[sqlite] problem compiling std_call dll
On Sun, Mar 1, 2015 at 9:28 PM, James K. Lowden wrote: > On Sat, 28 Feb 2015 11:22:12 + > Bart Smissaert wrote: > > > It doesn't compile and gives linking errors: > > > > Error 1 error LNK2001: unresolved external symbol > > _sqlite3_db_filename > > C:\Users\Bart\SQLiteForExcel\Source\SQLite3_StdCall > > \SQLite3_StdCall.obj SQLite3_StdCall > > Error 2 error LNK1120: 1 unresolved > > externals C:\Users\Bart\SQLiteForExcel\Source\SQLite3_StdCall\Release > > \SQLite3_StdCall.dll 1 1 SQLite3_StdCall > > What you mean is, it *does* compile, and then the linker emits an > error. :-) > > > Strangely it doesn't point to a line in the block SQLITE3_STDCALL_API > > but points to line 1. > > Not strange, or anyway not too strange. The linker doesn't know from > source code. It only knows the object code references a symbol for > which it found no definition. > > The symbol you want, sqlite3_db_filename appears to be defined in > sqlite3ext.h, line 475: > > #define sqlite3_db_filename sqlite3_api->db_filename > > If you include that file, the linker shouldn't attempt to resolve > the symbol, because the preprocessor defines it away. > I do not know if this is the case, but typically Windows creates names like _sqlite3_db_filename at X (where X is a number) if a function is defined as stdcall. It doesn't *have* to do this, but that's the convention used by default. The fact that the error message is _sqlite3_db_filename instead of _sqlite3_db_filename at X makes me suspect that there is a prototype somewhere for the function that doesn't include stdcall. Perhaps the header and source files are out of sync? If that were the case, the @X version of the symbol might be in the obj file (the source file got stdcall right), while consumers using the header try to use the cdecl form without the @X (because the prototype is different in the two locations. I hope this isn't too rambling. Just thoughts from a sleep deprived person. :) -- Scott Robison
[sqlite] problem compiling std_call dll
Iooked at that underscore (in _sqlite3_db_filename) as well, but that is just how VS presents the error, it didn't find a faulty underscore in the code. So, that is not it. As far as I can see the SQLite3 functions in this project are only in 3 places: sqlite3.h, SQLite3_StdCall.c and in the .def file. sqlite3_db_filename is in all 3 and all seems to be spelled right. Not sure if it gives any more information, but this is the build output: 1>-- Build started: Project: SQLite3_StdCall, Configuration: Release Win32 -- 1> SQLite3_StdCall.c 1> Creating library C:\Users\Bart\SQLiteForExcel\Source\SQLite3_StdCall\Release\SQLite3_StdCall.lib and object C:\Users\Bart\SQLiteForExcel\Source\SQLite3_StdCall\Release\SQLite3_StdCall.exp 1>SQLite3_StdCall.obj : error LNK2001: unresolved external symbol _sqlite3_db_filename 1>C:\Users\Bart\SQLiteForExcel\Source\SQLite3_StdCall\Release\SQLite3_StdCall.dll : fatal error LNK1120: 1 unresolved externals == Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped == RBS On Sun, Mar 1, 2015 at 7:10 AM, Amit Chaudhuri wrote: > Bart, > > you say "don't know anything about C or C++ or compiling C code" > Perhaps this will help. > > The error message (unresolved) external means that the linker is > trying to find something (_sqlite3_db_filename in this case) but it > cannot. > > Possible common causes include - it has been misspelt (I'm looking at > that underscore) or you have failed to point it at a library. > > I'm afraid I'm not fluent in the windows tools to track this down and > don't have a system I can follow along with. But on Linux one might > use the nm utility to examine a contents of library files for symbols. > > Regards, > > Amit > > On Sat, Feb 28, 2015 at 11:22 AM, Bart Smissaert > wrote: > > Trying to compile a std_call dll to be used with VB6 and VBA. > > Using instructions and files from this website: > > https://sqliteforexcel.codeplex.com/ > > All works well and have added a few SQLite functions that weren't in the > > compiled dll > > as in the download section from that website. > > However having problems adding sqlite3_db_filename. > > > > I added this to sqlite3.h: > > > > const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName); > > > > and this to SQLite3_StdCall.c: > > > > SQLITE3_STDCALL_API const char * __stdcall > > sqlite3_stdcall_db_filename(sqlite3 *pDb, const char *zDbName) > > { > > return sqlite3_db_filename(pDb, zDbName); > > } > > > > It doesn't compile and gives linking errors: > > > > Error 1 error LNK2001: unresolved external symbol > > _sqlite3_db_filename > > C:\Users\Bart\SQLiteForExcel\Source\SQLite3_StdCall\SQLite3_StdCall.obj > > SQLite3_StdCall > > Error 2 error LNK1120: 1 unresolved > > externals > C:\Users\Bart\SQLiteForExcel\Source\SQLite3_StdCall\Release\SQLite3_StdCall.dll > > 1 1 SQLite3_StdCall > > > > Strangely it doesn't point to a line in the block SQLITE3_STDCALL_API but > > points to line 1. > > This is at the start of SQLite3_StdCall.c: > > > > #include "stdafx.h" > > #include "SQLite3_StdCall.h" > > > > Compiling this on Windows 7 with Microsoft Visual Studio Professional > > Studio 2013. > > Admittedly, don't know anything about C or C++ or compiling C code, so I > am > > sure I must > > be overlooking something simple and silly, but just can't figure it out. > > Any ideas what could be the problem here? > > > > > > RBS > > ___ > > sqlite-users mailing list > > sqlite-users at mailinglists.sqlite.org > > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > ___ > sqlite-users mailing list > sqlite-users at mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users >
[sqlite] problem compiling std_call dll
Hello Bart, dumpbin /all sqlite3.obj > sqlite.txt You can then look at the sqlite.txt file with a text editor. I found _sqlite3_db_filename listed in there a couple times. That tells you it was probably compiled in. If you can't find it then that could be part of the problem. Then I might dump the obj for the Stdcall file and see how it mentions the function too. I have no idea how long this function has been in Sqlite. It makes me wonder if you're using an older version where the function didn't exist. As an experiment, I'd probably comment out the function in the stdcall wrapper that calls _sqlite3_db_filename then rebuild. See if the error goes away. Sunday, March 1, 2015, 5:15:32 AM, you wrote: BS> Iooked at that underscore (in _sqlite3_db_filename) as well, but that is BS> just how VS presents the error, it didn't find a faulty underscore in the BS> code. So, that is not it. As far as I can see the SQLite3 functions in this BS> project are only in 3 places: sqlite3.h, SQLite3_StdCall.c and in the .def BS> file. sqlite3_db_filename is in all 3 and all seems to be spelled right. BS> Not sure if it gives any more information, but this is the build output: 1>>-- Build started: Project: SQLite3_StdCall, Configuration: Release BS> Win32 -- 1>> SQLite3_StdCall.c 1>> Creating library BS> C:\Users\Bart\SQLiteForExcel\Source\SQLite3_StdCall\Release\SQLite3_StdCall.lib BS> and object BS> C:\Users\Bart\SQLiteForExcel\Source\SQLite3_StdCall\Release\SQLite3_StdCall.exp 1>>SQLite3_StdCall.obj : error LNK2001: unresolved external symbol BS> _sqlite3_db_filename 1>>C:\Users\Bart\SQLiteForExcel\Source\SQLite3_StdCall\Release\SQLite3_StdCall.dll BS> : fatal error LNK1120: 1 unresolved externals BS> == Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped == BS> RBS BS> On Sun, Mar 1, 2015 at 7:10 AM, Amit Chaudhuri BS> wrote: >> Bart, >> >> you say "don't know anything about C or C++ or compiling C code" >> Perhaps this will help. >> >> The error message (unresolved) external means that the linker is >> trying to find something (_sqlite3_db_filename in this case) but it >> cannot. >> >> Possible common causes include - it has been misspelt (I'm looking at >> that underscore) or you have failed to point it at a library. >> >> I'm afraid I'm not fluent in the windows tools to track this down and >> don't have a system I can follow along with. But on Linux one might >> use the nm utility to examine a contents of library files for symbols. >> >> Regards, >> >> Amit >> >> On Sat, Feb 28, 2015 at 11:22 AM, Bart Smissaert >> wrote: >> > Trying to compile a std_call dll to be used with VB6 and VBA. >> > Using instructions and files from this website: >> > https://sqliteforexcel.codeplex.com/ >> > All works well and have added a few SQLite functions that weren't in the >> > compiled dll >> > as in the download section from that website. >> > However having problems adding sqlite3_db_filename. >> > >> > I added this to sqlite3.h: >> > >> > const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName); >> > >> > and this to SQLite3_StdCall.c: >> > >> > SQLITE3_STDCALL_API const char * __stdcall >> > sqlite3_stdcall_db_filename(sqlite3 *pDb, const char *zDbName) >> > { >> > return sqlite3_db_filename(pDb, zDbName); >> > } >> > >> > It doesn't compile and gives linking errors: >> > >> > Error 1 error LNK2001: unresolved external symbol >> > _sqlite3_db_filename >> > C:\Users\Bart\SQLiteForExcel\Source\SQLite3_StdCall\SQLite3_StdCall.obj >> > SQLite3_StdCall >> > Error 2 error LNK1120: 1 unresolved >> > externals >> C:\Users\Bart\SQLiteForExcel\Source\SQLite3_StdCall\Release\SQLite3_StdCall.dll >> > 1 1 SQLite3_StdCall >> > >> > Strangely it doesn't point to a line in the block SQLITE3_STDCALL_API but >> > points to line 1. >> > This is at the start of SQLite3_StdCall.c: >> > >> > #include "stdafx.h" >> > #include "SQLite3_StdCall.h" >> > >> > Compiling this on Windows 7 with Microsoft Visual Studio Professional >> > Studio 2013. >> > Admittedly, don't know anything about C or C++ or compiling C code, so I >> am >> > sure I must >> > be overlooking something simple and silly, but just can't figure it out. >> > Any ideas what could be the problem here? >> > >> > >> > RBS >> > ___ >> > sqlite-users mailing list >> > sqlite-users at mailinglists.sqlite.org >> > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users >> ___ >> sqlite-users mailing list >> sqlite-users at mailinglists.sqlite.org >> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users >> BS> ___ BS> sqlite-users mailing list BS> sqlite-users at mailinglists.sqlite.org BS> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users -- Tegmailto:Teg at djii.com
[sqlite] problem compiling std_call dll
Bart, you say "don't know anything about C or C++ or compiling C code" Perhaps this will help. The error message (unresolved) external means that the linker is trying to find something (_sqlite3_db_filename in this case) but it cannot. Possible common causes include - it has been misspelt (I'm looking at that underscore) or you have failed to point it at a library. I'm afraid I'm not fluent in the windows tools to track this down and don't have a system I can follow along with. But on Linux one might use the nm utility to examine a contents of library files for symbols. Regards, Amit On Sat, Feb 28, 2015 at 11:22 AM, Bart Smissaert wrote: > Trying to compile a std_call dll to be used with VB6 and VBA. > Using instructions and files from this website: > https://sqliteforexcel.codeplex.com/ > All works well and have added a few SQLite functions that weren't in the > compiled dll > as in the download section from that website. > However having problems adding sqlite3_db_filename. > > I added this to sqlite3.h: > > const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName); > > and this to SQLite3_StdCall.c: > > SQLITE3_STDCALL_API const char * __stdcall > sqlite3_stdcall_db_filename(sqlite3 *pDb, const char *zDbName) > { > return sqlite3_db_filename(pDb, zDbName); > } > > It doesn't compile and gives linking errors: > > Error 1 error LNK2001: unresolved external symbol > _sqlite3_db_filename > C:\Users\Bart\SQLiteForExcel\Source\SQLite3_StdCall\SQLite3_StdCall.obj > SQLite3_StdCall > Error 2 error LNK1120: 1 unresolved > externals > C:\Users\Bart\SQLiteForExcel\Source\SQLite3_StdCall\Release\SQLite3_StdCall.dll > 1 1 SQLite3_StdCall > > Strangely it doesn't point to a line in the block SQLITE3_STDCALL_API but > points to line 1. > This is at the start of SQLite3_StdCall.c: > > #include "stdafx.h" > #include "SQLite3_StdCall.h" > > Compiling this on Windows 7 with Microsoft Visual Studio Professional > Studio 2013. > Admittedly, don't know anything about C or C++ or compiling C code, so I am > sure I must > be overlooking something simple and silly, but just can't figure it out. > Any ideas what could be the problem here? > > > RBS > ___ > sqlite-users mailing list > sqlite-users at mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] problem compiling std_call dll
Trying to compile a std_call dll to be used with VB6 and VBA. Using instructions and files from this website: https://sqliteforexcel.codeplex.com/ All works well and have added a few SQLite functions that weren't in the compiled dll as in the download section from that website. However having problems adding sqlite3_db_filename. I added this to sqlite3.h: const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName); and this to SQLite3_StdCall.c: SQLITE3_STDCALL_API const char * __stdcall sqlite3_stdcall_db_filename(sqlite3 *pDb, const char *zDbName) { return sqlite3_db_filename(pDb, zDbName); } It doesn't compile and gives linking errors: Error 1 error LNK2001: unresolved external symbol _sqlite3_db_filename C:\Users\Bart\SQLiteForExcel\Source\SQLite3_StdCall\SQLite3_StdCall.obj SQLite3_StdCall Error 2 error LNK1120: 1 unresolved externals C:\Users\Bart\SQLiteForExcel\Source\SQLite3_StdCall\Release\SQLite3_StdCall.dll 1 1 SQLite3_StdCall Strangely it doesn't point to a line in the block SQLITE3_STDCALL_API but points to line 1. This is at the start of SQLite3_StdCall.c: #include "stdafx.h" #include "SQLite3_StdCall.h" Compiling this on Windows 7 with Microsoft Visual Studio Professional Studio 2013. Admittedly, don't know anything about C or C++ or compiling C code, so I am sure I must be overlooking something simple and silly, but just can't figure it out. Any ideas what could be the problem here? RBS