Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: matt on July 10, 2005, 04:47:33 am

Title: link errors
Post by: matt on July 10, 2005, 04:47:33 am
hi

i get a linker error when compiling on fedora core 4 (gcc4, wx2.4):

Linking executable devel/codeblocks.exe...
.objs/src/app.o(.gnu.linkonce.t._ZN13CodeBlocksAppC1Ev[CodeBlocksApp::CodeBlocksApp()]+0x16): In function `CodeBlocksApp::CodeBlocksApp()':
src/app.cpp:77: undefined reference to `vtable for CodeBlocksApp'
collect2: ld returned 1 exit status
make: *** [devel/codeblocks.exe] Error 1

does anyone know what this is about?

thanks
Title: Re: link errors
Post by: Anonymous on July 10, 2005, 07:37:22 am
Quote from: matt
hi

i get a linker error when compiling on fedora core 4 (gcc4, wx2.4):

Linking executable devel/codeblocks.exe...
.objs/src/app.o(.gnu.linkonce.t._ZN13CodeBlocksAppC1Ev[CodeBlocksApp::CodeBlocksApp()]+0x16): In function `CodeBlocksApp::CodeBlocksApp()':
src/app.cpp:77: undefined reference to `vtable for CodeBlocksApp'
collect2: ld returned 1 exit status
make: *** [devel/codeblocks.exe] Error 1

does anyone know what this is about?

thanks


Can you post more of the error? preferably the command being executed to link codeblocks.exe, it looks as if the linker is not linking with all the correct libraries.
Title: link errors
Post by: matt on July 11, 2005, 10:36:28 pm
thanks for the reply.

i posted the whole error that was printed to the shell, but from exploring the makefile i deduced that `wx-config --libs` is run to determine what to link the program with. on my system this command produces the following result:

Code
-pthread -lwx_gtk2-2.4


is this all that is required?

thanks

p.s. i noticed that in the unix makefile the line which links the executable includes "-mwindows". correct me if im wrong, but is this not incorrect?
Title: link errors
Post by: rickg22 on July 11, 2005, 11:17:56 pm
-mwindows means "no console window". I think it applies to both unix and windows.
Title: link errors
Post by: mandrav on July 11, 2005, 11:43:30 pm
-mwindows applies only to windows.
Anyway, tomorrow I 'll update the unix project files too,
Now, concerning the error you 're getting, I can't think of anything. I haven't seen this error before and my only suggestion would be rebuilding the project, in case something screwed up.
Also I notice you 're using gcc 4. I'm not saying something's wrong with it, just that it's a pretty recent release and it ***might*** have some bugs.
If I were you and couldn't figure out what's wrong, I 'd try with an older (and proven to be stable) gcc version, like 3.4.

Yiannis.
Title: link errors
Post by: matt_matrus on July 12, 2005, 02:37:34 am
thanks for the advice, i shall try gcc 3.4 tomorrow
Title: link errors
Post by: matt on July 14, 2005, 04:36:51 pm
Well, i just tried did a cvs checkout and got it to compile first time on Mandriva 2005! But, when i try to run codeblocks.exe in output, it says:

Code
./codeblocks.exe: error while loading shared libraries: libcodeblocks.so: cannot open shared object file: No such file or directory


I ran
Code
make -f Makefile.unix update
. Has this replaced the shell script?

p.s. i couldn't be bothered to try with fc4
Title: link errors
Post by: matt_matrus on July 14, 2005, 05:07:40 pm
Sorry, forgot to login!

I got it to work by copying libcodeblocks.so to /usr/lib. Is there no way to run it from its own directory properly, because there is no longer a "run.sh" script.

Thanks
Title: link errors
Post by: mandrav on July 14, 2005, 05:52:31 pm
Quote
Is there no way to run it from its own directory properly, because there is no longer a "run.sh" script.

run.sh is created when you run the update script.

Yiannis.
Title: link errors
Post by: matt_matrus on July 15, 2005, 05:46:12 pm
I couldn't find run.sh anywhere in the cvs version (probably me being stupid). So i downloaded the final-beta, ran make -f Makefile.unix update, and copied the script to the cvs version's directory. With a bit of path tweaking in the script voila! :D

Edit:
To make everything work i needed to run codeblocks with the --prefix option and rename the wxwindows templates to have a capital second w (i.e. wxWindows.* instead of wxwindows.*)
Title: Re: link errors
Post by: zemo on August 16, 2005, 01:24:31 am
Hi!

I have the same problem. Using fc4 (gcc 4.0.1, wx 2.4.2). Link error:

Linking executable devel/codeblocks.exe...
.objs/src/app.o(.gnu.linkonce.t._ZN13CodeBlocksAppC1Ev[CodeBlocksApp::CodeBlocksApp()]+0x16): In function `CodeBlocksApp::CodeBlocksApp()':
src/app.h:37: undefined reference to `vtable for CodeBlocksApp'
/usr/local/lib/libwx_gtk2-2.4.so: undefined reference to `wxwxListStringNode::~wxwxListStringNode()'
/usr/local/lib/libwx_gtk2-2.4.so: undefined reference to `wxwxMenuItemListNode::~wxwxMenuItemListNode()'
/usr/local/lib/libwx_gtk2-2.4.so: undefined reference to `wxwxMenuItemListNode::~wxwxMenuItemListNode()'
/usr/local/lib/libwx_gtk2-2.4.so: undefined reference to `vtable for wxFileProto'
/usr/local/lib/libwx_gtk2-2.4.so: undefined reference to `wxwxListStringNode::~wxwxListStringNode()'
collect2: ld returned 1 exit status
make: *** [devel/codeblocks.exe] Error 1

Tryed codeblocks-1.0-rc1-1 and codeblocks CVS versions. Any idea?
Title: Re: link errors
Post by: zemo on August 16, 2005, 04:46:06 pm
Progress report:

I was able so solve some gcc4 compile errors. I applyed 2 patches for wxGTK-2.4.2, found here: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=154958
This solved these errors:
/usr/local/lib/libwx_gtk2-2.4.so: undefined reference to `wxwxListStringNode::~wxwxListStringNode()'
/usr/local/lib/libwx_gtk2-2.4.so: undefined reference to `wxwxMenuItemListNode::~wxwxMenuItemListNode()'
/usr/local/lib/libwx_gtk2-2.4.so: undefined reference to `wxwxMenuItemListNode::~wxwxMenuItemListNode()'
/usr/local/lib/libwx_gtk2-2.4.so: undefined reference to `vtable for wxFileProto'
/usr/local/lib/libwx_gtk2-2.4.so: undefined reference to `wxwxListStringNode::~wxwxListStringNode()'

but it still won't compile, now I get just this:
Linking executable devel/codeblocks.exe...
.objs/src/app.o(.gnu.linkonce.t._ZN13CodeBlocksAppC1Ev[CodeBlocksApp::CodeBlocksApp()]+0x16): In function `CodeBlocksApp::CodeBlocksApp()':
src/app.h:37: undefined reference to `vtable for CodeBlocksApp'
collect2: ld returned 1 exit status
make: *** [devel/codeblocks.exe] Error 1

I believe this is gcc4 isue. Searched the web, but no luck  :?.

P.S.: wxGTK examples compile without problems.
Title: Re: link errors
Post by: rickg22 on August 16, 2005, 05:46:07 pm
Are you compiling via the makefile.unix ? I've done it without a single problem.
Title: Re: link errors
Post by: zemo on August 16, 2005, 05:59:27 pm
Yes. I followed instructions from wiki. Did you used gcc3.4 or gcc4 ?
Title: Re: link errors
Post by: rickg22 on August 16, 2005, 07:51:19 pm
I use GCC 3.4
Title: Re: link errors
Post by: tksuoran on August 30, 2005, 08:48:20 am
I'm having the same problem with gcc 4. It looks like gcc 4 really wants those virtual destructors. I get lots of warnings that they are missing, and then linking fails.
Title: Re: link errors
Post by: zieQ on August 30, 2005, 09:57:53 am
I think that, in the C++ standard, virtual destructors are not mandatory. It seems to be a bug from gcc4.
Anyway, it's a good habit to use virtual destructors, so IMHO we should change all the offending destructors in C::B!
Title: Re: link errors
Post by: Link5225 on October 19, 2005, 01:27:40 am
Any progress on this yet?  I use Fedora Core 4 with gcc 4.0, and I'd really like to try out Code::Blocks.  I've been running into a few problems trying to compile gcc 3.4 from source, so I'd rather just be able to compile with 4.0.  Is there any easy way to fix this?

EDIT:  Okay, turns out it does work if I use wxWidgets 2.6.2 and the CVS version of C::B (downloaded at night on Oct 18, whatever version that might be).  From there I just followed the instructions on the wiki, including the bootstrapping and everything shown at the bottom.  Hopefully whatever was fixed to get rid of the 'undefined reference to vtable' errors will be included in the actual release sometime soon.