Thread: setting up SQLite with Visual C++ Express

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    89

    setting up SQLite with Visual C++ Express

    Hi, I have been playing with SQLite and I got everything setup with Dev-C++ with the help of this forum. The problem is now I'm trying to set it up with VC++ as well and am having no luck. I have the DLL, the .h and .a library file. I put the .a into the lib folder for VC++ and put the .h file in the include folder. I did #include <sqlite3.h> in my app and it compiled fine but when I tried this:
    Code:
    sqlite3 *db;
    I go this error:
    Code:
    Project1.obj : warning LNK4248: unresolved typeref token (01000054) for 'sqlite3'; image may not run
    I tried opening a database anyway since it was only a warning but started getting weird errors.
    Any ideas?

    thanks
    Last edited by ac251404; 08-24-2006 at 01:33 PM.

  2. #2
    Registered User
    Join Date
    May 2003
    Posts
    1,619
    VC++ doesn't use .a library files. You'll probably need to download the source and compile a DLL out of it, which will also create an import library (.lib) which you'll need to link with your build.

    It's vital that you use the same runtime libraries (e.g. Multithreaded DLL) for both your project and the DLL you make.
    Last edited by Cat; 08-24-2006 at 05:04 PM.
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    89
    I already have the .dll, can i make a .lib from that? Do I use the .DLL as well and if so where should I put it? Right now I have it in my system path because thats how I got it working with Dev-C++. If I get the .lib file I should just put that in the lib folder and the .h in the include folder correct? Are there any command line linker options I should add or anything? Thanks

  4. #4
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,058
    Why not just download the Windows version of Sqlite3 and use the Windows Sqlite3.lib, Sqlite3.dll and Sqlite3.h files?

  5. #5
    Registered User
    Join Date
    May 2006
    Posts
    89
    I did download the windows precompiled binaries, all the zip contains is the .dll and .def. I also downloaded the source to get the .h file. To get it working for Dev-Cpp I had to use the mingw dlltool to create a '.a' library file for the include directory. I tried using this in the same manner to create a .lib file but I'm not sure if it works like that since mingw is its own compiler. So I'm not sure how to take the .dll and do something with it to make it compile in my program.

  6. #6
    Registered User
    Join Date
    May 2006
    Posts
    89
    Okay I have placed the proper .lib file into my VC lib dir and I have the .h in my include and have also determined that this error is a result of mixing managed and unmanaged code. I think i am using a wrong linker reference, anyone know which I might try?

  7. #7
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,058
    To generate the lib file (sqlite3.lib) to allow your windows compiler to link your app to the dll is done as follows:

    Code:
    lib /machine:i386 /def:sqlite3.def

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  3. load gif into program
    By willc0de4food in forum Windows Programming
    Replies: 14
    Last Post: 01-11-2006, 10:43 AM
  4. Errors with including winsock 2 lib
    By gamingdl'er in forum C++ Programming
    Replies: 3
    Last Post: 12-05-2005, 08:13 PM
  5. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM