undefined reference problem in CodeBlocks Topic is solved

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
nalamar
In need of some credit
In need of some credit
Posts: 7
Joined: Thu Mar 19, 2009 1:02 am

undefined reference problem in CodeBlocks

Post by nalamar » Thu Mar 19, 2009 2:01 am

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

mc2r
wxWorld Domination!
wxWorld Domination!
Posts: 1195
Joined: Thu Feb 22, 2007 4:47 pm
Location: Denver, Co
Contact:

Re: undefined reference problem in CodeBlocks

Post by mc2r » Thu Mar 19, 2009 5:20 am

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

nalamar
In need of some credit
In need of some credit
Posts: 7
Joined: Thu Mar 19, 2009 1:02 am

Post by nalamar » Thu Mar 19, 2009 10:55 am

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'|

nalamar
In need of some credit
In need of some credit
Posts: 7
Joined: Thu Mar 19, 2009 1:02 am

Post by nalamar » Thu Mar 19, 2009 1:28 pm

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

Post Reply