sqlite3.dll depends on MSVCRT.DLL.  [SOLVED]

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
fancyivan
Experienced Solver
Experienced Solver
Posts: 80
Joined: Wed May 26, 2010 8:42 am
Location: Beijing, China
Contact:

sqlite3.dll depends on MSVCRT.DLL.

Postby fancyivan » Mon Jun 28, 2010 2:23 am

hello,

I'm a new for wxWidget and wxSQLite3.
I only used the SQLite3 with .net wapper.

after I read the ReadMe of wxSQLite3, I know that the sqlite3.dll will be used generally.

on http://sqlite.org/download.html,
sqlitedll-3_6_23_1.zip (253.34 KiB),This is a DLL of the SQLite library without the TCL bindings. The only external dependency is MSVCRT.DLL.

why does sqlite3.dll depend on msvcrt.dll? because it created by VC++?

Can we create a new sqlite3.dll without any dependency?

My develop environment: windows xp + C::B + mingw32(gcc4.4.0).

thanks.

utelle
Moderator
Moderator
Posts: 823
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: sqlite3.dll depends on MSVCRT.DLL.

Postby utelle » Mon Jun 28, 2010 7:02 am

fancyivan wrote:on http://sqlite.org/download.html,
sqlitedll-3_6_23_1.zip (253.34 KiB),This is a DLL of the SQLite library without the TCL bindings. The only external dependency is MSVCRT.DLL.

Exactly. And the same holds true for the DLL coming with wxSQLite3 which additionally supports encryption.

fancyivan wrote:why does sqlite3.dll depend on msvcrt.dll?

SQLite is written in C and therefore depends on the C runtime library. MSVCRT.DLL represents the C runtime library and is usually available on all Windows platforms without the need to install anything.

fancyivan wrote:because it created by VC++?

No. Applications created with MinGW usually depend on MSVCRT.DLL, too.

fancyivan wrote:Can we create a new sqlite3.dll without any dependency?

Yes, if the C runtime library is linked statically with SQLite. I know it's easy to accomplish using VC++ (just switch the C++ code generation option "Use runtime library" from "Multithreaded DLL" to "Multithreaded").

fancyivan wrote:My develop environment: windows xp + C::B + mingw32(gcc4.4.0).

As far as I know MinGW applications always depend on MSVCRT.DLL. Years ago there was a project to create an alternate C runtime library for MinGW which is independent of MSVCRT.DLL, but I don't know whether this project has been completed or not.

Regards,

Ulrich

fancyivan
Experienced Solver
Experienced Solver
Posts: 80
Joined: Wed May 26, 2010 8:42 am
Location: Beijing, China
Contact:

Re: sqlite3.dll depends on MSVCRT.DLL.

Postby fancyivan » Mon Jun 28, 2010 8:24 am

Ulrich, thank u very much for your reply.

after i posted this issue this morning, i googled a lot of articles about msvcrt and mingw, and your answer is simple but very clear, Now i'm clear about my question. thank you again.

just now, I compiled the wxSQLite3 successfully. Here is my step:

btw again: windows xp + mingw(gcc4.4.0)

1. open the file: wxSQLite3/build/makefile.gcc, set WX_DEBUG = 0,
WX_SHARED = 0, WX_UNICODE = 1, WX_DIR = C:\CodeBlocks\extension\wxWidgets-2.8.11 (i installed the wxWidgets here.) then save it.

2. compile it by using: make -f makefile.gcc

3. done. in folder of "wxSQLite3/lib/gcc_lib/", I got this file: "libwxcode_msw28u_wxsqlite3.a".

and the sample "minimal.exe" works fine.


But............How can i use wxSQLite3 in my applicatoin?

I copied the "wxSQLite3/include/wx/....." into "wxWidgets/include/wx/.....", and copied the "libwxcode_msw28u_wxsqlite3.a" into "wxWidgets/lib/gcc_lib/".

then I created a wxWidgets GUI project as usual (C::B 10.05), add <wx/wxsqlite3.h> into TestSQLMain.h, add two functions:

Code: Select all

wxSQLite3Database* initDB(void)
{
   wxString testDBName = wxGetCwd() + wxT("/test2.db");
   if (wxFileExists(testDBName))
   {
      wxRemoveFile(testDBName);
   }
   wxSQLite3Database* db = new wxSQLite3Database();
   db->Open(testDBName);
   db->ExecuteUpdate(wxT("CREATE TABLE test (col1 INTEGER)"));
   return db;
}

void clearDB(wxSQLite3Database* db)
{
   assert(db != NULL);
   db->Close();
   delete db;
}

//Test wxSQLite3
void TestFrame::OnAbout(wxCommandEvent &event)
{
    wxString msg = wxbuildinfo(long_f);
    wxMessageBox(msg, _("Welcome to..."));
    wxSQLite3Database* db = initDB();
    clearDB(db);
}


copy sqlite3.dll into Release folder of my project. add the "libwxcode_msw28u_wxsqlite3.a" into link library of my project.

It compiled successfully, but linking failed, here are the error messages, pls help me.

Code: Select all

obj\Release\TestMain.o:TestMain.cpp:(.text+0x510):undefined reference to ‘TestFrame::initDB()’
obj\Release\TestMain.o:TestMain.cpp:(.text+0x510):undefined reference to ‘TestFrame::clearDB()’
libwxcode_msw28u_wxsqlite3.a(wxsqlite3_lib_wxsqlite3.o):wxsqlite3.cpp:(.text+0xc3b):undefined reference to 'wxRegEx::Init()'
libwxcode_msw28u_wxsqlite3.a(wxsqlite3_lib_wxsqlite3.o):wxsqlite3.cpp:(.text+0xc3b):undefined reference to 'sqlite3_user_data'
......
libwxcode_msw28u_wxsqlite3.a(wxsqlite3_lib_wxsqlite3.o):wxsqlite3.cpp:(.text+0xc3b):undefined reference to 'sqlite3_close'


Thanks.

fancyivan
Experienced Solver
Experienced Solver
Posts: 80
Joined: Wed May 26, 2010 8:42 am
Location: Beijing, China
Contact:

Re: sqlite3.dll depends on MSVCRT.DLL.

Postby fancyivan » Mon Jun 28, 2010 9:07 am

About the linking failed messages, I tried to add the sqlite3.a into the link library, the most error messages disappeared.

but there are still 10 error messages left, I found that these error are all about wxRegEx. then I tried to add "libwxregexu.a" into the link library, but it does not help....

Code: Select all

obj\Release\TestMain.o:TestMain.cpp:(.text+0x510):undefined reference to ‘TestFrame::initDB()’
obj\Release\TestMain.o:TestMain.cpp:(.text+0x510):undefined reference to ‘TestFrame::clearDB()’
libwxcode_msw28u_wxsqlite3.a(wxsqlite3_lib_wxsqlite3.o):wxsqlite3.cpp:(.text+0xc3b):undefined reference to 'wxRegEx::Init()'
libwxcode_msw28u_wxsqlite3.a(wxsqlite3_lib_wxsqlite3.o):wxsqlite3.cpp:(.text+0xc3b):undefined reference to 'sqlite3_user_data'
......
libwxcode_msw28u_wxsqlite3.a(wxsqlite3_lib_wxsqlite3.o):wxsqlite3.cpp:(.text+0xc3b):undefined reference to 'sqlite3_close'



Thanks.[/quote]

utelle
Moderator
Moderator
Posts: 823
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: sqlite3.dll depends on MSVCRT.DLL.  [SOLVED]

Postby utelle » Mon Jun 28, 2010 9:31 am

fancyivan wrote:btw again: windows xp + mingw(gcc4.4.0)

1. open the file: wxSQLite3/build/makefile.gcc, set WX_DEBUG = 0,
WX_SHARED = 0, WX_UNICODE = 1, WX_DIR = C:\CodeBlocks\extension\wxWidgets-2.8.11 (i installed the wxWidgets here.) then save it.

That is you create wxSQLite3 as a static library.

fancyivan wrote:3. done. in folder of "wxSQLite3/lib/gcc_lib/", I got this file: "libwxcode_msw28u_wxsqlite3.a".

and the sample "minimal.exe" works fine.

But............How can i use wxSQLite3 in my applicatoin?

In your project you have to instruct your compiler to use the include directory of wxSQLite3 as an additional directory for header files. And in the linker step you have to add a reference to libwxcode_msw28u_wxsqlite3.a and to sqlite3.a (a pre-built version for MinGW comes with wxSQLite3). It may be required to rename this file to libsqlite3.a.

If you specify USE_DYNAMIC_SQLITE3_LOAD=1 in the makefile the SQLite DLL will be loaded dynamically at runtime eliminating the need to specify the link library sqlite3.a for the linker.

fancyivan wrote:I copied the "wxSQLite3/include/wx/....." into "wxWidgets/include/wx/.....", and copied the "libwxcode_msw28u_wxsqlite3.a" into "wxWidgets/lib/gcc_lib/".

This step is not necessary if you specify appropriate additional header and library paths for the compiler and the linker in your project settings.

fancyivan wrote:It compiled successfully, but linking failed, here are the error messages, pls help me.

Code: Select all

obj\Release\TestMain.o:TestMain.cpp:(.text+0x510):undefined reference to ‘TestFrame::initDB()’
obj\Release\TestMain.o:TestMain.cpp:(.text+0x510):undefined reference to ‘TestFrame::clearDB()’
libwxcode_msw28u_wxsqlite3.a(wxsqlite3_lib_wxsqlite3.o):wxsqlite3.cpp:(.text+0xc3b):undefined reference to 'wxRegEx::Init()'
libwxcode_msw28u_wxsqlite3.a(wxsqlite3_lib_wxsqlite3.o):wxsqlite3.cpp:(.text+0xc3b):undefined reference to 'sqlite3_user_data'
......
libwxcode_msw28u_wxsqlite3.a(wxsqlite3_lib_wxsqlite3.o):wxsqlite3.cpp:(.text+0xc3b):undefined reference to 'sqlite3_close'

wxSQLite3 provides an implementation for the REGEX operator in SQLite's SQL dialect. For this purpose the wxWidgets class wxRegEx is used. Therefore you have to add the regular expression library (libwxregexu.a in your case) to the linker options. Unfortunately the GCC linker is a bit dumb: the order of the libraries matter. The reference to the regex library has to be given after the reference to the wxSQLite3 library.

Regards,

Ulrich

fancyivan
Experienced Solver
Experienced Solver
Posts: 80
Joined: Wed May 26, 2010 8:42 am
Location: Beijing, China
Contact:

Re: sqlite3.dll depends on MSVCRT.DLL.

Postby fancyivan » Mon Jun 28, 2010 10:03 am

It works, it works!!
Thank you Ulrich. :)

thanks for your patient to reply my stupid & easy question.....

1. use include directory of wxSQLite3.
2. if link sqlite3 as absolute path, do not need to rename it.
if as relative path, sqlited3.a should be renamed to libsqlite3.a.
3. about wxRegex, as you mentioned, we should adjust the order of libraries.... this item takes me a lot of time this afternoon, i debuged my codes again and again (without change the order), the linking error still existed.
and i found that if only put wxRegex after wxSQLite3, there will be the same error messages. i seems that wxSQLite3 need other libraries, so i put the wxSQLite3 to the first, now it works fine~~

thank you again, Ulrich.


utelle wrote:wxSQLite3 provides an implementation for the REGEX operator in SQLite's SQL dialect. For this purpose the wxWidgets class wxRegEx is used. Therefore you have to add the regular expression library (libwxregexu.a in your case) to the linker options. Unfortunately the GCC linker is a bit dumb: the order of the libraries matter. The reference to the regex library has to be given after the reference to the wxSQLite3 library.

Regards,

Ulrich


Return to “wxCode”

Who is online

Users browsing this forum: No registered users and 3 guests