Results 1 to 11 of 11

Thread: Can't Compile Tutorial 7

  1. #1
    Join Date
    Feb 2006
    Posts
    11
    Qt products
    Qt4
    Platforms
    Windows

    Default Can't Compile Tutorial 7

    Hi, I've been compiling all the tutorials up to now, and snooping around it. But tutorial 7 (Qt Assistant - Tutorials - T7) doesn't compile.

    It's the first tutorial that moves to multiple files, and it's the linker that can't compile.

    Switching to target: default
    Compiling: main.cpp
    Compiling: lcdrange.cpp
    Linking executable: C:\Projects\QTProjects\Tut1\tut1.exe
    .objs\lcdrange.o:lcdrange.cpp:(.text+0x172): undefined reference to `vtable for LCDRange'
    .objs\lcdrange.o:lcdrange.cpp:(.text+0x17e): undefined reference to `vtable for LCDRange'
    .objs\lcdrange.o:lcdrange.cpp:(.text+0x4cc): undefined reference to `vtable for LCDRange'
    .objs\lcdrange.o:lcdrange.cpp:(.text+0x4d8): undefined reference to `vtable for LCDRange'
    collect2: ld returned 1 exit status
    Process terminated with status 1 (0 minutes, 4 seconds)
    0 errors, 0 warnings
    Can anybody help me?

    I have a bad feeling I've only been using Code::Blocks and not Qt before this.

  2. #2
    Join Date
    Feb 2006
    Posts
    11
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Can't Compile Tutorial 7

    Right...

    I need to be in command prompt and go
    qmake -project
    qmake
    make


    But how can I get code::blocks to do that when I click compile?

  3. #3
    Join Date
    Feb 2006
    Location
    Kirovohrad, Ukraine
    Posts
    72
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Exclamation Re: Can't Compile Tutorial 7

    Ok, try this.
    Do this once:
    1. Unzip the attachement to %HOMEPATH%\.Codeblocks
    2. Restart Codeblocks
    3. Menu > Settings > Compiler
    4. Select Other tab
    5. Set Build method to Work with Makefiles (GNU "make" required)
    6. (Optional) Set Logging to Full command line
    7. Menu > Tools > Configure tools...
    8. Add the first tool
      • Add
      • Name: Create QT Project file
      • Executable: Path to qmake.exe
      • Parameters: -o Makefile
      • Working directory: ${PROJECT_DIR}
      • Ok
    9. Add the second tool
      • Add
      • Name: Create Makefile
      • Executable: Path to qmake.exe
      • Parameters: leave empty
      • Working directory: ${PROJECT_DIR}
      • Ok


    For each of your new QT Projects do the following:
    1. Menu > File > New Project...
    2. Select User Templates tab
    3. Choose Cesar's QT Application
    4. After adding new *.cpp, *.h files don't forget to
      1. Menu > Tools > Create QT Project file
      2. Menu > Tools > Create Makefile
    Attached Files Attached Files

  4. #4
    Join Date
    Feb 2006
    Location
    Kirovohrad, Ukraine
    Posts
    72
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Re: Can't Compile Tutorial 7

    Some more comments:
    The name of the template depends on the name of the directory, which contains the *.cbp project template. In this case it is "Cesar's QT Application". You might want change it to something reasonable .
    The *.cbp file is plain XML file so it could be edited manually.
    Now I'm looking for the fine way to include diferent QT modules while building the *.pro file. For now, you should change the Tool "Create QT Project file" and add QT+="sql network" to the options, to make use of sql and network modules respectively... Any ideas how to improove this approach?

  5. #5
    Join Date
    Jan 2006
    Location
    Athens - Greece
    Posts
    219
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Can't Compile Tutorial 7

    Would you care giving this a try? Still pre-alpha I'm afraid but I'm working on it

  6. #6
    Join Date
    Feb 2006
    Posts
    11
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Can't Compile Tutorial 7

    Still can't compile 7 or 8...


  7. #7
    Join Date
    Feb 2006
    Location
    Kirovohrad, Ukraine
    Posts
    72
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Can't Compile Tutorial 7

    Could you, please, post something more informative? Any compilation/linking errors, the steps you've done to achive them, etc. Your post gives no information about the reason of your problem.

  8. #8
    Join Date
    Feb 2006
    Posts
    11
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Can't Compile Tutorial 7

    Sorry

    Well, the results are still the same as it were earlier. So nothing's changed.

    On both the projects.

    But I could redo them from scratch again (using your Code::Blocks template, and check if they run again). But I don't have time for the next while...

    -Reenen

  9. #9
    Join Date
    Feb 2006
    Location
    Kirovohrad, Ukraine
    Posts
    72
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Wink Re: Can't Compile Tutorial 7

    That's ok, keep trying, when you find some spare time
    But keep in mind, that qmake -project scans the current directory, all its sub-directories and adds the files it found to the project file. So all the *.o files left from the previous compilation attempts will occasionally get to the resulting Makefile. This may lead to broken dependencies, etc, etc...

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,014 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Can't Compile Tutorial 7

    Did you remember to add the Q_OBJECT macro to the class definition?
    Did you split the class into two files (header and implementation)?

  11. #11
    Join Date
    Feb 2006
    Posts
    11
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Can't Compile Tutorial 7

    Yes, I did add the Q_OBJECT macro thingy to the file. But I haven't "rebooted" the whole application and restarted from scratch.

    I'll do that when time permits.

Similar Threads

  1. Compile Application in XCode for Release. How?
    By Alex Snet in forum Installation and Deployment
    Replies: 7
    Last Post: 3rd February 2009, 09:16
  2. qtgui4.dll error in visual c++ 2005
    By Comptrol in forum Installation and Deployment
    Replies: 33
    Last Post: 19th June 2008, 07:18
  3. Access to PostgreSQL DB on a linux server
    By rmagro in forum Qt Programming
    Replies: 28
    Last Post: 13th March 2008, 09:02
  4. Compile Errors
    By luffy27 in forum Qt Programming
    Replies: 3
    Last Post: 4th November 2006, 05:26
  5. Hehe, Cant Compile tutorial 8
    By Reenen in forum Newbie
    Replies: 1
    Last Post: 8th February 2006, 13:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.