User forums > Using Code::Blocks

Problem compiling QT project in CodeBlocks QT 4.4 and CB 8.02

(1/2) > >>

rben13:
I've got Qt 4.4 and CB 8.02.
I initially had trouble getting my application to link, but then figured out I had to copy QtCore4.dll to the windows system director or put it in the linker path, whatever, easy fix. After that, simple Qt applications compiled fine. (I'm working my way through a Qt tutorial.) But when I got the the first application that subclasses QWidget, things get wonky. I get the error message listed at the end of this post.

I understand that I have to use qmake, which runs moc, so I added the following lines to the pre-build steps:
qmake -project
qmake

Still I get the same problem, just now I don't get errors on the lines that referred to slots in my C++ files.

Can someone tell me what I need to do to fix this? Your help is greatly appreciated.

Thanks
  Ray

||=== TribalCostModel, Debug ===|
obj\Debug\lcdrange.o(.text+0x172)||In function `ZN8LCDRangeC2EP7QWidget':
C:\src\lcdrange.cpp|23|undefined reference to `vtable for LCDRange'
obj\Debug\lcdrange.o(.text+0x17e):C:\src\lcdrange.cpp|23|undefined reference to `vtable for LCDRange'
obj\Debug\lcdrange.o(.text+0x4cc)||In function `ZN8LCDRangeC1EP7QWidget':
C:\src\lcdrange.cpp|23|undefined reference to `vtable for LCDRange'
obj\Debug\lcdrange.o(.text+0x4d8):C:\src\lcdrange.cpp|23|undefined reference to `vtable for LCDRange'
||=== Build finished: 4 errors, 0 warnings ===|

rben13:
I figured out part of this. I opened up the project properites and told it to use custom Makefile. Now the original error is gone, but I have the error:


ld.exe||cannot find -lqtmaind|
||=== Build finished: 1 errors, 0 warnings ===|


I've tried adding the Qt /lib directory to the linker search path, but that doesn't seem to be working. Perhaps I'm not doing it correctly. Any help is appreciated.

Ray

darcwader:
i had similar problem, i think the problem is that the debug version of library is not compiled. so try changing the build to release.

i've used codeblocks for c++ and wx programs so far, recently i've started to use it to learn some amount of qt.
to use it with qt, i do the following (for debug)

0. add qt's bin directory to PATH
1. while choosing qt4 project i setup the obj dir or debug as obj/Debug ->debug from  exe as debug/project.exe
2. project options > choose custom makefile
3. build options > make commands as make debug 

if i make any changes to the pro file i need to run qmake to generate Makefile again,but i am still doing it from cmd line(tools menu), as pre-build and post-build commands cannot be used if i am using custom Makefile.  Anyone has any idea how to enable this... (run command qmake before executing make while using custom makefile?

darcwader:
I just found out that if u create a .pro file add it to C::B there is a rule within the makefile which would automatically generate the makefile itself :D

so no need to run qmake before giving make debug just giving the use custom makefile option is enough if a pro file is present. 8) 

maybe the wizard can setup project to use the custom makefile option and the custom make commands.
here are the targets that i found...


* debug
* debug-clean
* debug-distclean
* release
* release-clean
* release-distclean
hope this helps.

rben13:

--- Quote from: darcwader on May 11, 2008, 01:16:32 pm ---i had similar problem, i think the problem is that the debug version of library is not compiled. so try changing the build to release.

Anyone has any idea how to enable this... (run command qmake before executing make while using custom makefile?

--- End quote ---

I tried deleting the debug target, which worked, kind of. Now it appears things build, but the resulting exe isn't run.

Add your qmake -project and qmake lines into the pre/post build steps pre-build box under Project Build Options, that will take care of qmake for you.

Now I just have to figure out how to make it actually run the program. :)

Navigation

[0] Message Index

[#] Next page

Go to full version