To compile the sqlite3.c file to sqlite3.dll you need to create a separate 
project that will "compile" sqlite3.c (as a "C" file) with the dependency 
sqlite3.h and tell VS to output a "DLL" / Dynamic Link Library rather than an 
EXE file.  The ".lib" is the built from the symbols exported into this DLL.  

I presume that you can set these options in the VS gooey somewhere but where I 
do not know since I only use the VS gooey under duress.

You also somehow have to tell VS to "export" the sqlite3_api (perhaps by 
defining the compiler symbol SQLITE_API=__declspec(dllexport) as one would do 
with GCC) or by adding a dependency in the gooey to the sqlite3.def file (which 
contains a list of the symbols that should be exported) and the .def file is 
then also used to create the .lib file.

If I were to build the sqlite3.dll using the command line compiler (CL), I 
would define the symbol SQLITE_API=__declspec(dllexport) and compile to a DLL 
(rather than an EXE).  The output of the compile step is the .DLL and the .LIB 
file to go with it (plus perhaps a manifest that you have to attach back to the 
DLL in some cases, though what those are are beyond me -- if there is and 
output manifest I just plop in back into the DLL as a matter of course).

Any "options" you want included when you compile the DLL are specified in the 
input to the sqlite3.c compile step (as defines).

---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a 
lot about anticipated traffic volume.


>-----Original Message-----
>From: sqlite-users [mailto:sqlite-users-
>boun...@mailinglists.sqlite.org] On Behalf Of zydeholic
>Sent: Friday, 21 December, 2018 18:29
>To: SQLite mailing list
>Subject: Re: [sqlite] Need setup code for VC++ 2017 that will
>ACTUALLY COMPILE
>
>So, and sorry if this is covering ground already covered, but if I
>wanted to compile my own DLL and .lib file, I would do what exactly?
>Just not tell it about the .lib dependencies?  And not put the lib
>and dll files in my project directory?  Sorry for my denseness.  I'm
>very knew to this route of doing things, old as that route may be.
>
>
>      From: Keith Medcalf <kmedc...@dessus.com>
> To: SQLite mailing list <sqlite-users@mailinglists.sqlite.org>
> Sent: Friday, December 21, 2018 5:15 PM
> Subject: Re: [sqlite] Need setup code for VC++ 2017 that will
>ACTUALLY COMPILE
>
>
>No problem.  You can of course omit the sqlite3.c file  and use the
>sqlite3.lib/sqlite3.dll combination, but your application will then
>be dependent on the version of sqlite3.dll that happens to be found
>at runtime and the options that were used to compile it.  If you use
>the sqlite3.c directly then your application will be statically
>linked and not dependent on the external dll file.  Plus with the
>sqlite3.c compiled statically you will be able to define exactly what
>sqlite3 features you want to include whereas with the .lib/.dll you
>will use whatever options happen to have been used to build that dll.
>
>
>---
>The fact that there's a Highway to Hell but only a Stairway to Heaven
>says a lot about anticipated traffic volume.
>
>
>>-----Original Message-----
>>From: sqlite-users [mailto:sqlite-users-
>>boun...@mailinglists.sqlite.org] On Behalf Of zydeholic
>>Sent: Friday, 21 December, 2018 18:02
>>To: SQLite mailing list
>>Subject: Re: [sqlite] Need setup code for VC++ 2017 that will
>>ACTUALLY COMPILE
>>
>>Holy Chewbacca,
>>I removed the .c file from the project and I got an error free
>>compile.  Yes, I knew my code would not do anything, except prove
>>that I was able to talk through to something.  I'll try your code
>>below.
>>
>>Thanks MUCHO.
>>
>>David
>>
>>      From: Keith Medcalf <kmedc...@dessus.com>
>> To: SQLite mailing list <sqlite-users@mailinglists.sqlite.org>
>> Sent: Friday, December 21, 2018 4:53 PM
>> Subject: Re: [sqlite] Need setup code for VC++ 2017 that will
>>ACTUALLY COMPILE
>>
>>
>>First of all use EITHER the source (.c) OR the precomiled dynamic
>>link library (.dll/.lib).  Not both.
>>
>>The .c file contains the code to the sqlite3 database engine.  The
>>DLL contains this code compiled to a Dynamic Link Library.  The LIB
>>file tells your application how to find the code in the dynamic link
>>library.  If you use both, only god (and probably not ever her)
>knows
>>what will happen.
>>
>>Here is a C++ program that actually does something (yours does
>>not).  It compiles and runs when using a real compiler on Winders
>>(GCC).  It has no error checking.  But it does call "C" functions
>>from "C++".  Simply compile it (in C++ mode) together with the
>>sqlite3.c (in C mode) and link them all together.
>>
>>
>>#include "sqlite3.h"
>>#include <fstream>
>>#include <iostream>
>>using namespace std;
>>
>>int main()
>>{
>>    sqlite3 *db;
>>    sqlite3_stmt *stmt;
>>    sqlite3_open(":memory:", &db);
>>    sqlite3_prepare_v2(db, "select sqlite_source_id();", -1, &stmt,
>>NULL);
>>    sqlite3_step(stmt);
>>    cout << sqlite3_column_text(stmt, 0);
>>    sqlite3_finalize(stmt);
>>    sqlite3_close(db);
>>}
>>
>>
>>
>>
>>---
>>The fact that there's a Highway to Hell but only a Stairway to
>Heaven
>>says a lot about anticipated traffic volume.
>>
>>
>>>-----Original Message-----
>>>From: sqlite-users [mailto:sqlite-users-
>>>boun...@mailinglists.sqlite.org] On Behalf Of zydeholic
>>>Sent: Friday, 21 December, 2018 17:26
>>>To: SQLite mailing list
>>>Subject: Re: [sqlite] Need setup code for VC++ 2017 that will
>>>ACTUALLY COMPILE
>>>
>>>My cpp code consists of this at the moment:
>>>#include "sqlite3.h"
>>>#include <fstream>
>>>#include <iostream>
>>>using namespace std;
>>>
>>>int main()
>>>{
>>>    sqlite3 *db;
>>>}
>>>
>>>I have added sqlite3.h to my header files.I have added sqlite3.c to
>>>my source files.I've moved these two files, plus sqlite3.dll and
>>>sqlite3.lib into the same directory as these other files:
>>>C:\users\dsnos\source\repos\sqlite_try_3\sqlite_try_3
>>>
>>>In Project, I've made the following settings:VC++
>>>Directories>>Library
>>>Directories>>C:\users\dsnos\source\repos\sqlite_try_3\sqlite_try_3;
>C
>>/
>>>C++>>Additional Include
>>>Directories>>C:\users\dsnos\source\repos\sqlite_try_3\sqlite_try_3;
>>>C/C++>>Precompiled Headers>>Not using precompiled headers (all
>>>configurations, all platforms).
>>>Linker>>Input>>Additional Dependencies>>sqlite3.lib
>>>I now get two errors when I compile:
>>>Severity    Code    Description    Project    File    Line    Suppr
>e
>>s
>>>sion State
>>>Error    LNK2001    unresolved external symbol
>>>_sqlite3_version    sqlite_try_3    C:\Users\DSNoS\source\repos\sql
>i
>>t
>>>e_try_3\sqlite_try_3\sqlite3.obj    1
>>>Severity    Code    Description    Project    File    Line    Suppr
>e
>>s
>>>sion State
>>>Error    LNK1120    1 unresolved
>>>externals    sqlite_try_3    C:\Users\DSNoS\source\repos\sqlite_try
>_
>>3
>>>\Debug\sqlite_try_3.exe    1
>>>
>>>
>>>At some point before I started filling in the directories and such
>>in
>>>Project, my code:
>>>sqlite3 *db;
>>>was errored out (underlined in red).  Now they are not erroring
>>>out.  I just get the two errors above when I compile.
>>>
>>>      From: zydeholic <nonghead-webs...@yahoo.com>
>>> To: SQLite mailing list <sqlite-users@mailinglists.sqlite.org>
>>> Sent: Friday, December 21, 2018 3:46 PM
>>> Subject: Re: [sqlite] Need setup code for VC++ 2017 that will
>>>ACTUALLY COMPILE
>>>
>>>Ok, to further define my goals, I am not looking to compile the
>>files
>>>into a final EXE, unless that is the only way I can use it with my
>>>program.  I want to tap into the sqlite functionality from a C++
>>>application I am writing.
>>>
>>>I suppose I need to use the DLL that I downloaded, but have never
>>>used an external library before, not where I had to tell the
>>compiler
>>>how to talk to it.
>>>So, SQLite, backend database.  I will do the front end stuff in my
>>>code.  Hopefully this clarifies something.
>>>
>>>
>>>      From: Larry Brasfield <brasfield.la...@gmail.com>
>>> To: "sqlite-users@mailinglists.sqlite.org" <sqlite-
>>>us...@mailinglists.sqlite.org>
>>> Sent: Friday, December 21, 2018 1:02 PM
>>> Subject: Re: [sqlite] Need setup code for VC++ 2017 that will
>>>ACTUALLY COMPILE
>>>
>>>Zydeholic wrote:
>>>➢ I compile and get one error:
>>>Severity    Code    Description    Project    File    Line    Suppr
>e
>>s
>>>sion State Error    LNK2001    unresolved external symbol
>>>_sqlite3_version    sqlite_try_3    C:\Users\DSNoS\source\repos\sql
>i
>>t
>>>e_try_3\sqlite_try_3\sqlite3.obj    1
>>>
>>>That symbol is declared, and a definition for the object so named
>is
>>>coded, in the sqlite3.c amalgamation without the possibility of
>>>omission by the preprocessor.  So I find it exceedingly strange
>that
>>>your link operation is complaining of an unresolvable reference to
>>>that symbol in sqlite3.obj.  For a C compilation, which you
>>certainly
>>>should be using for that C source, the name should be undecorated,
>>>except for the leading underscore, just as it appears in the above-
>>>quoted error message.  This leads me to believe you are doing
>>>something too strange for anybody to guess with the information
>>>provided so far.
>>>
>>>You may notice that this thread is misnamed for this latest
>>>difficulty, since the code does actually compile.  If I had to name
>>>it accurately, it would be called: [off topic] Need build
>>>instructions for my project which uses SQLite in a development
>>>environment differing from the one actually supported by the SQLite
>>>team.
>>>
>>>Some questions to ask yourself as you attempt to sort this out:
>>>1. Am I compiling the .c sources as C language?
>>>2. Have I modified the sources everybody assumes are as released by
>>>the SQLite team?
>>>3. What does insight does dumpbin.exe, (the VC command line tool
>for
>>>showing compiled image content), provide into my link errors?
>>>4. How does my sqlite3.obj differ from the one I get following step
>>>19 at https://www.sqlite.org/cli.html , and why?
>>>_______________________________________________
>>>sqlite-users mailing list
>>>sqlite-users@mailinglists.sqlite.org
>>>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-
>users
>>>
>>>
>>>
>>>
>>>
>>>_______________________________________________
>>>sqlite-users mailing list
>>>sqlite-users@mailinglists.sqlite.org
>>>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-
>users
>>
>>
>>
>>_______________________________________________
>>sqlite-users mailing list
>>sqlite-users@mailinglists.sqlite.org
>>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>>
>>
>>
>>_______________________________________________
>>sqlite-users mailing list
>>sqlite-users@mailinglists.sqlite.org
>>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
>
>
>_______________________________________________
>sqlite-users mailing list
>sqlite-users@mailinglists.sqlite.org
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
>
>
>_______________________________________________
>sqlite-users mailing list
>sqlite-users@mailinglists.sqlite.org
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to