Author Topic: Problem compiling QT project in CodeBlocks QT 4.4 and CB 8.02  (Read 6315 times)

Offline rben13

  • Single posting newcomer
  • *
  • Posts: 7
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 ===|

Offline rben13

  • Single posting newcomer
  • *
  • Posts: 7
Re: Problem compiling QT project in CodeBlocks QT 4.4 and CB 8.02
« Reply #1 on: May 09, 2008, 07:34:53 pm »
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

Offline darcwader

  • Single posting newcomer
  • *
  • Posts: 7
Re: Problem compiling QT project in CodeBlocks QT 4.4 and CB 8.02
« Reply #2 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.

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?

Offline darcwader

  • Single posting newcomer
  • *
  • Posts: 7
Re: Problem compiling QT project in CodeBlocks QT 4.4 and CB 8.02
« Reply #3 on: May 11, 2008, 02:00:29 pm »
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.

Offline rben13

  • Single posting newcomer
  • *
  • Posts: 7
Re: Problem compiling QT project in CodeBlocks QT 4.4 and CB 8.02
« Reply #4 on: May 11, 2008, 09:22:59 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?


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. :)

Offline rben13

  • Single posting newcomer
  • *
  • Posts: 7
Re: Problem compiling QT project in CodeBlocks QT 4.4 and CB 8.02
« Reply #5 on: May 11, 2008, 09:27:44 pm »
I can run the program from the command line or by double-click, so my build is working, if you don't count the lack of debug. Guess I'll have to compile that part myself.

I appreciate the help. Will post solution to getting it to run if I find one.

Thanks,
  Ray

Offline darcwader

  • Single posting newcomer
  • *
  • Posts: 7
Re: Problem compiling QT project in CodeBlocks QT 4.4 and CB 8.02
« Reply #6 on: May 12, 2008, 09:17:50 pm »
Quote
Guess I'll have to compile that part myself.

i am able to build the debug version aswell, make sure u have compiled qt in debug mode. best way is to goto qt install directory, lib/ see if u have libraries with "d" suffix. ex: libqtmaind.a . if its not there u will need to compile those.

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

make sure the project exe or o/p filename at project options > build targets > release ... output filename  is same as the one generated by qmake. it will launch it. :)

Offline rben13

  • Single posting newcomer
  • *
  • Posts: 7
Re: Problem compiling QT project in CodeBlocks QT 4.4 and CB 8.02
« Reply #7 on: May 27, 2008, 03:48:52 pm »
I've discovered that most of my problems seemed to stem from not running qmake each time I was rebuilding my program. I eventually figured out how to make sure that happened, and now things compile and link just fine.