Welcome! Log In Create A New Profile

Advanced

Compile errors

Posted by Vampyre 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Compile errors
January 23, 2012 08:41PM
Hi peeps

been trying to compile some code and get the following errors

debug/codevisitor.o: In function `CodeVisitor':
C:\projects\src\visitor\codevisitor-build-desktop/../codevisitor/codevisitor.cpp:9: undefined reference to `_imp___ZN11FileVisitor10setFiltersE11QStringList'
C:\projects\src\visitor\codevisitor-build-desktop/../codevisitor/codevisitor.cpp:9: undefined reference to `_imp___ZN11FileVisitor10setFiltersE11QStringList'
C:\projects\src\visitor\codevisitor-build-desktop/../codevisitor/codevisitor.cpp:13: undefined reference to `_imp___ZN11FileVisitorC2E11QStringListbb'
C:\projects\src\visitor\codevisitor-build-desktop/../codevisitor/codevisitor.cpp:13: undefined reference to `_imp___ZN11FileVisitorC2E11QStringListbb'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\codevisitor.exe] Error 1

same when compiling the utils
c:\projects\libs\customer/customer.cpp:4: undefined reference to `_imp___ZN10Dat
aObjectC2EP7QObject'
c:\projects\libs\customer/customer.cpp:4: undefined reference to `_imp___ZN10Dat
aObjectC2EP7QObject'

anyone with any insite ?

thanks in advance
Re: Compile errors
January 24, 2012 06:15AM
Have gone through tut102 section 4? Maybe it can help. Myself have only managed to compile successfully the example on tut102. It gave me similar error, until I copied all code in the same Dir.
avatar Re: Compile errors
January 28, 2012 06:52PM
Anytime you see an error of the type "undefined reference", it's a linker error. What's happening is that your code is referencing some code that somebody else wrote and compiled into a library of some sort, and that code has not been incorporated into your final executable yet.

It's all well and good to #include a header file to some 3rd party code but that only takes care of the interfaces and is sufficient during the compilation process. Once that's done, all your compiled code needs to be brought together with all 3rd party compiled code (packaged together in static libraries) to make the final executable file and that's the job of the linker.

The code you're looking for will be in a static library file somewhere in the Ezust directory. I can't remember what the name is exactly, you'll have to read your Tut letters but you give the instruction to the linker to go fetch that library file and link it to your own code by using the LIBS variable in your project file. You need to specify both the path to the library file (-L) and the library file name itself(-l, lower-case L).

eg. if I need to link in the following library file: c:\my\other\sdk\libs\otherlibrary.a

I would add the following to the project file:

LIBS += -Lc:\my\other\sdk\libs -lotherlibrary

NB: no spaces must be between the -L/-l and the text that follows, and the file extension for the library file can be left off. (actually, the Qt manual recommends not including it).

The reason for splitting the path from the library file is because it's often the case that more than one static library needs to be linked that sits in the same directory as another library.

eg. if I also need to link in the following library file as well as the one above: c:\my\other\sdk\libs\otherlibrary2.a

My project file would change to:

LIBS += -Lc:\my\other\sdk\libs -lotherlibrary -lotherlibrary2

If I remember correctly, Ezust makes you create an environmental variable for the path to it's library and calls it CPPLIBS. Environmental variables can be referenced inside project files using the $$(xxx) syntax, where 'xxx' is the variable's name.
Sorry, only registered users may post in this forum.

Click here to login