Author Topic: Weird undefined reference to (...)  (Read 6228 times)

Offline agent007se

  • Multiple posting newcomer
  • *
  • Posts: 25
Weird undefined reference to (...)
« 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: [Select]
-------------- 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: C++
  1. //======================================
  2. // TABLIG WIN32 PORT : @see : http://lukas.oxygene.sk/wiki/TagLibWin32
  3. #include <tag.h>
  4. #include <fileref.h>
  5. //======================================
  6. CMusicFile::CMusicFile(QString mFFP)
  7. {
  8.     ...
  9.     TagLib::FileRef musicTag("song.mp3");
  10.     ...
  11. }
  12.  

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 !

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5193
Re: Weird undefined reference to (...)
« Reply #1 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) ... ?

Offline agent007se

  • Multiple posting newcomer
  • *
  • Posts: 25
Re: Weird undefined reference to (...)
« Reply #2 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).

Offline agent007se

  • Multiple posting newcomer
  • *
  • Posts: 25
Re: Weird undefined reference to (...)
« Reply #3 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
  1. <CodeBlocks_project_file>
  2. <FileVersion major="1" minor="4"/>
  3. <Project>
  4. <Option title="QT Application"/>
  5. <Option pch_mode="0"/>
  6. <Option compiler="gcc"/>
  7. <Build>
  8. <Target title="default">
  9. <Option output="D:\MuRef\MuRef.exe"/>
  10. <Option type="0"/>
  11. <Option compiler="gcc"/>
  12. <Option includeInTargetAll="1"/>
  13. <Option projectResourceIncludeDirsRelation="0"/>
  14. <Compiler>
  15. <Add directory="$(QTDIR)\include"/>
  16. <Add directory="$(QTDIR)\include\Qt"/>
  17. <Add directory="$(QTDIR)\include\ActiveQt"/>
  18. <Add directory="$(QTDIR)\include\Qt3Support"/>
  19. <Add directory="$(QTDIR)\include\QtAssistant"/>
  20. <Add directory="$(QTDIR)\include\QtCore"/>
  21. <Add directory="$(QTDIR)\include\QtDesigner"/>
  22. <Add directory="$(QTDIR)\include\QtGui"/>
  23. <Add directory="$(QTDIR)\include\QtMotif"/>
  24. <Add directory="$(QTDIR)\include\QtNetwork"/>
  25. <Add directory="$(QTDIR)\include\QtNsPlugin"/>
  26. <Add directory="$(QTDIR)\include\QtOpenGL"/>
  27. <Add directory="$(QTDIR)\include\QtSql"/>
  28. <Add directory="$(QTDIR)\include\QtXml"/>
  29. <Add directory="C:\Boost\include\boost-1_33_1"/>
  30. <Add directory="D:\MuRef\others\includes\taglibwin32"/>
  31. <Add directory="D:\MuRef\others\includes\taglibwin32\taglib"/>
  32. </Compiler>
  33. <Linker>
  34. <Add library="libQt3Support4.a"/>
  35. <Add library="libQtAssistantClient.a"/>
  36. <Add library="libQtCore4.a"/>
  37. <Add library="libQtDesigner4.a"/>
  38. <Add library="libQtDesignerComponents4.a"/>
  39. <Add library="libQtGui4.a"/>
  40. <Add library="libqtmain.a"/>
  41. <Add library="libQtNetwork4.a"/>
  42. <Add library="libQtOpenGl4.a"/>
  43. <Add library="libQtSql4.a"/>
  44. <Add library="libQtXml4.a"/>
  45. <Add library="libQtSvg4.a"/>
  46. <Add library="libQtTest4.a"/>
  47. <Add library="libQtUiTools.a"/>
  48. <Add library="D:\MuRef\others\lib\libfmodex.a"/>
  49. <Add library="D:\MuRef\others\lib\taglib.lib"/>
  50. <Add library="D:\MuRef\others\lib\taglib_static.lib"/>
  51. <Add directory="$(QTDIR)\lib"/>
  52. <Add directory="D:\MuRef\others\lib"/>
  53. </Linker>
  54. <ExtraCommands>
  55. <Add before="qt-prebuild"/>
  56. </ExtraCommands>
  57. </Target>
  58. </Build>
  59.  
« Last Edit: July 15, 2006, 02:46:06 pm by agent007se »

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5193
Re: Weird undefined reference to (...)
« Reply #4 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.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9508
Re: Weird undefined reference to (...)
« Reply #5 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline agent007se

  • Multiple posting newcomer
  • *
  • Posts: 25
Re: Weird undefined reference to (...)
« Reply #6 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.

Offline agent007se

  • Multiple posting newcomer
  • *
  • Posts: 25
Re: Weird undefined reference to (...)
« Reply #7 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...
« Last Edit: July 16, 2006, 10:21:54 pm by agent007se »