Code::Blocks Forums

User forums => Help => Topic started by: agent007se on July 15, 2006, 01:51:15 pm

Title: Weird undefined reference to (...)
Post by: agent007se on July 15, 2006, 01:51:15 pm
Hello, I'm new to C::B and I find it very cool :D.

I only have some problems after the compilation but I search on google, forums of the libs and nothing...

Here is the build log (:D) :

Code
-------------- Build: default in QT Application ---------------
Running target pre-build steps
qt-prebuild
qt-prebuild : running
qt-prebuild : scan started
qt-prebuild : found UICable file muref.ui
qt-prebuild : found MOCable file ui_murefimpl.h
qt-prebuild : scan completed
mingw32-g++.exe -LD:\Qt\4.1.3\lib -LD:\MuRef\others\lib -L"D:\Program Files\CodeBlocks\lib"  -o D:\MuRef\MuRef.exe .objs\CContextMenu.o .objs\CDatabase.o .objs\CLinkGUI.o .objs\CMusicFile.o .objs\CPlaylist.o .objs\CScanFiles.o .objs\CToolBox.o .objs\QTreeWidgetToolBox.o .objs\main.o .objs\moc_ui_murefimpl.o .objs\ui_murefimpl.o    -lQt3Support4 -lQtAssistantClient -lQtCore4 -lQtDesigner4 -lQtDesignerComponents4 -lQtGui4 -lqtmain -lQtNetwork4 -lQtOpenGl4 -lQtSql4 -lQtXml4 -lQtSvg4 -lQtTest4 -lQtUiTools D:\MuRef\others\lib\libfmodex.a D:\MuRef\others\lib\taglib.lib D:\MuRef\others\lib\taglib_static.lib  -mwindows
.objs\CMusicFile.o(.text+0x7bd):CMusicFile.cpp: undefined reference to `TagLib::FileRef::FileRef(char const*, bool, TagLib::AudioProperties::ReadStyle)'
.objs\CMusicFile.o(.text+0x7c8):CMusicFile.cpp: undefined reference to `TagLib::FileRef::~FileRef()'
.objs\CMusicFile.o(.text+0xbfd):CMusicFile.cpp: undefined reference to `TagLib::FileRef::FileRef(char const*, bool, TagLib::AudioProperties::ReadStyle)'
.objs\CMusicFile.o(.text+0xc08):CMusicFile.cpp: undefined reference to `TagLib::FileRef::~FileRef()'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 2 seconds)
4 errors, 0 warnings

And here is the portion of code which create that error :

in class CMusicFile.cpp :
Code: cpp
//======================================
// TABLIG WIN32 PORT : @see : http://lukas.oxygene.sk/wiki/TagLibWin32
#include <tag.h>
#include <fileref.h>
//======================================
CMusicFile::CMusicFile(QString mFFP)
{
    ...
    TagLib::FileRef musicTag("song.mp3");
    ...
}

The problem doesn't only appear with that lib and I have the EXACT same typical error with id3lib (which IS a cross-platform lib and many people use it but no help from their mailing list (which is actually outdated)).

Can someone help me ?? :-) That's a so nice IDE and I don't want to move to MSVC 2005 Express...

Thanks a lot :D !
Title: Re: Weird undefined reference to (...)
Post by: killerbot on July 15, 2006, 02:01:21 pm
it seems the TagLib::FileRef implementation is missing. Did you add the source file, did you add the library (in case it comes as a lib) ... ?
Title: Re: Weird undefined reference to (...)
Post by: agent007se on July 15, 2006, 02:16:27 pm
Thanks for the quick answer.

I got in the package :

lib/taglib.lib
lib/taglib_static.lib
include/ (all headers here : tag.h, fileref.h, ...)

I put in project->build options->default->linker tab->link libraries : taglib.lib & taglib_static.lib but nothing different happens... (i.e.: same error).
Title: Re: Weird undefined reference to (...)
Post by: agent007se on July 15, 2006, 02:41:13 pm
Min 20 others reading and no replies hmmm if I can give you other information just say me... maybe the project file ?

Code: xml
<CodeBlocks_project_file>
<FileVersion major="1" minor="4"/>
<Project>
<Option title="QT Application"/>
<Option pch_mode="0"/>
<Option compiler="gcc"/>
<Build>
<Target title="default">
<Option output="D:\MuRef\MuRef.exe"/>
<Option type="0"/>
<Option compiler="gcc"/>
<Option includeInTargetAll="1"/>
<Option projectResourceIncludeDirsRelation="0"/>
<Compiler>
<Add directory="$(QTDIR)\include"/>
<Add directory="$(QTDIR)\include\Qt"/>
<Add directory="$(QTDIR)\include\ActiveQt"/>
<Add directory="$(QTDIR)\include\Qt3Support"/>
<Add directory="$(QTDIR)\include\QtAssistant"/>
<Add directory="$(QTDIR)\include\QtCore"/>
<Add directory="$(QTDIR)\include\QtDesigner"/>
<Add directory="$(QTDIR)\include\QtGui"/>
<Add directory="$(QTDIR)\include\QtMotif"/>
<Add directory="$(QTDIR)\include\QtNetwork"/>
<Add directory="$(QTDIR)\include\QtNsPlugin"/>
<Add directory="$(QTDIR)\include\QtOpenGL"/>
<Add directory="$(QTDIR)\include\QtSql"/>
<Add directory="$(QTDIR)\include\QtXml"/>
<Add directory="C:\Boost\include\boost-1_33_1"/>
<Add directory="D:\MuRef\others\includes\taglibwin32"/>
<Add directory="D:\MuRef\others\includes\taglibwin32\taglib"/>
</Compiler>
<Linker>
<Add library="libQt3Support4.a"/>
<Add library="libQtAssistantClient.a"/>
<Add library="libQtCore4.a"/>
<Add library="libQtDesigner4.a"/>
<Add library="libQtDesignerComponents4.a"/>
<Add library="libQtGui4.a"/>
<Add library="libqtmain.a"/>
<Add library="libQtNetwork4.a"/>
<Add library="libQtOpenGl4.a"/>
<Add library="libQtSql4.a"/>
<Add library="libQtXml4.a"/>
<Add library="libQtSvg4.a"/>
<Add library="libQtTest4.a"/>
<Add library="libQtUiTools.a"/>
<Add library="D:\MuRef\others\lib\libfmodex.a"/>
<Add library="D:\MuRef\others\lib\taglib.lib"/>
<Add library="D:\MuRef\others\lib\taglib_static.lib"/>
<Add directory="$(QTDIR)\lib"/>
<Add directory="D:\MuRef\others\lib"/>
</Linker>
<ExtraCommands>
<Add before="qt-prebuild"/>
</ExtraCommands>
</Target>
</Build>
Title: Re: Weird undefined reference to (...)
Post by: killerbot on July 15, 2006, 03:52:39 pm
Quote
<Add library="D:\MuRef\others\lib\taglib.lib"/>
<Add library="D:\MuRef\others\lib\taglib_static.lib"/>

2 different libs ?? or twice the same. These libs should provide the implementation.
Title: Re: Weird undefined reference to (...)
Post by: MortenMacFly on July 15, 2006, 05:18:39 pm
Quote
<Add library="D:\MuRef\others\lib\taglib.lib"/>
<Add library="D:\MuRef\others\lib\taglib_static.lib"/>
In addition: I think it's no good to include libs directly - with full path specifier. I'd suggest you include "D:\MuRef\others\lib" into the linker directories and just add "taglib" or "taglib_static" to the libs to link against. The same applies to the other libs with full path specification, too.
This isn't the cause for your errors but you should consider to "correct" this.
With regards, Morten.
Title: Re: Weird undefined reference to (...)
Post by: agent007se on July 15, 2006, 07:53:28 pm
Quote
<Add library="D:\MuRef\others\lib\taglib.lib"/>
<Add library="D:\MuRef\others\lib\taglib_static.lib"/>

2 different libs ?? or twice the same. These libs should provide the implementation.

For sure that they are supposed to do :p !! They aren't here by chance ;). And that IS my problem... you know, I said that it isn't a specific issue and I have the exact same problem with 'id3lib' and 'sqlite3'... (the last one I don't care anymore about because I'm using Qt).

The only lib which didn't cause me troubles was libfmodex.a where in the doc that was specified : for migw, use this.
Title: Re: Weird undefined reference to (...)
Post by: agent007se on July 15, 2006, 07:54:42 pm
Quote
<Add library="D:\MuRef\others\lib\taglib.lib"/>
<Add library="D:\MuRef\others\lib\taglib_static.lib"/>
In addition: I think it's no good to include libs directly - with full path specifier. I'd suggest you include "D:\MuRef\others\lib" into the linker directories and just add "taglib" or "taglib_static" to the libs to link against. The same applies to the other libs with full path specification, too.
This isn't the cause for your errors but you should consider to "correct" this.
With regards, Morten.

Thank you very much for the precisions :-). I corrected that ;).

SOLVED by using a correct lib built for mingw...