Page 1 of 1

undefined reference problem in CodeBlocks

Posted: Thu Mar 19, 2009 2:01 am
by nalamar
Hi there,

first of all, i know that this is an linker-error, but i can't fix it on my own ... maybe im just blind.

I'm Using Windows Vista, with CodeBlocks 8.02, wxwidgets 2.8.9, wxsqlite3 1.9.4

As is startet trying to include wxsqlite, my problems startet. I compiled it with the same option as i compiled wxwidgets. I tried to copy the first few lines from the sample which is included in wxsqlite into my code, which resulted in the following lines.

Code: Select all

obj\Debug\En_MaxApp.o||In function `_Z6initDBv':|
E:\en max\En Max\En_MaxApp.cpp|34|undefined reference to `wxSQLite3Database::wxSQLite3Database()'|
E:\en max\En Max\En_MaxApp.cpp|35|undefined reference to `wxSQLite3Database::Open(wxString const&, wxString const&)'|
E:\en max\En Max\En_MaxApp.cpp|36|undefined reference to `wxSQLite3Database::ExecuteUpdate(wxString const&)'|
||=== Build finished: 3 errors, 0 warnings ===|
This is the part of the code where i tried to use it:

Code: Select all

#ifdef WX_PRECOMP
#include "wx_pch.h"
#endif

#ifdef __BORLANDC__
#pragma hdrstop
#endif //__BORLANDC__

#include "En_MaxApp.h"
#include "En_MaxMain.h"
#include "EnMaxClass.h"
#include "wx/wxsqlite3.h"
#include "wx/wxsqlite3opt.h"

IMPLEMENT_APP(En_MaxApp);


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

bool En_MaxApp::OnInit()
{
    GUIFrame* frame = new GUIFrame(0L);
    frame->SetIcon(wxICON(aaaa)); // To Set App Icon
    frame->Show();

    return true;
}
I added the include and lib directory to the build options for the project. I tried to add the "libwxcode_msw28u_wxsqlite3.a" file to the Linker Settings, but that resulted in tons of error messages.

Please give me a hint what i did wrong or what i missed.
Thanks

Nala

Re: undefined reference problem in CodeBlocks

Posted: Thu Mar 19, 2009 5:20 am
by mc2r
nalamar wrote:I added the include and lib directory to the build options for the project. I tried to add the "libwxcode_msw28u_wxsqlite3.a" file to the Linker Settings, but that resulted in tons of error messages.
Not sure what compiler codeblocks uses on windows, but you could try adding -lwxcode_msw28_wxsqlite3 to the linker settings.

mingw(gcc for windows) will add the lib and .a or .dll as appropriate.

-Max

Posted: Thu Mar 19, 2009 10:55 am
by nalamar
CodeBlocks is installed with MinGW

and using your advice resultet in this:

Code: Select all

ld.exe||cannot find -lwxcode_msw28_wxsqlite3|
Edit:

I added the u to cause i compiled everything with unicode support, which leads to the same problems as i insert it directly ....

This is one of over the errormessages

Code: Select all

E:\wxsqlite3\lib\gcc_lib\libwxcode_msw28u_wxsqlite3.a(wxsqlite3_lib_wxsqlite3.o):wxsqlite3.cpp:(.text+0xf68)||undefined reference to `_sqlite3_free'|

Posted: Thu Mar 19, 2009 1:28 pm
by nalamar
Solved it, i guess

I compiled wxsqlite another time, and Compared all FLAGS, now it runs ... problably i set wx_shared=1 instead of shared=1 during first compiling ....

For the moment i dont have any Errors Compiling.

Thx, Jan