Results 1 to 5 of 5

Thread: Error - undefined reference qMain

  1. #1
    Join Date
    Oct 2006
    Location
    Hawaii
    Posts
    130
    Thanks
    48
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Error - undefined reference qMain

    Its probably something simple that I overlooked, but I have never gotten this error before and I have no idea how to get past it:
    Qt Code:
    1. c:\Qt\4.4.1\lib/libqtmain.a(qtmain_win.o)(.text+0x156):qtmain_win.cpp: undefined reference to `qMain(int, char**)'
    To copy to clipboard, switch view to plain text mode 
    originally, I had some classes that I wanted to put into a shared library. These classes were for QDialogs, and one of them was a QMainWindow. The reason for a 'dialog' being a QMainWindow was to have a tool bar on it (it is a dialog that allows the user to send an email), which doesn't seem to be allowed for QDialogs. The reason to include the dialogs within a library, was to create a common library of dialogs that I could use in multiple programs.

    The shared library compiled fine with no errors, so I am assuming that something might be wrong with the .pro file of the program that is using the library.

  2. #2
    Join Date
    Oct 2006
    Location
    Hawaii
    Posts
    130
    Thanks
    48
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Error - undefined reference qMain

    ah after a few trials and errors, I figured it out.

    I forgot "main.cpp" in the list of sources in my .pro file

  3. #3
    Join Date
    Nov 2008
    Posts
    33
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Error - undefined reference qMain

    I'm having the same error, but when linking a file which includes main...
    am I missing something?

  4. #4
    Join Date
    Oct 2006
    Location
    Hawaii
    Posts
    130
    Thanks
    48
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Error - undefined reference qMain

    Well, I have had this happen a couple times since then, and it was always because of either of 2 things:

    - missing or mistyping something in my .pro file
    - missing or mistyping a #include command somewhere

    without seeing more info about your problem/code I couldn't say for sure an exact solution.

  5. #5
    Join Date
    Nov 2008
    Posts
    33
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Error - undefined reference qMain

    actually, I'm not using .pro files and qmake, but autotools instead, and it works fine but for some files (with main function); by googling I found a similar problem was due to some include files that define "main"; it all was solved by adding this preprocessor directive before my main:

    Qt Code:
    1. #undef main
    To copy to clipboard, switch view to plain text mode 

    but this looks like a bug, doesn't it?

Similar Threads

  1. QPSQL problem
    By LoneWolf in forum Installation and Deployment
    Replies: 60
    Last Post: 4th November 2009, 14:22
  2. how to add static library into qmake
    By Namrata in forum Qt Tools
    Replies: 1
    Last Post: 20th November 2007, 17:33
  3. MS Sql native driver??
    By LordQt in forum Qt Programming
    Replies: 4
    Last Post: 9th October 2007, 13:41
  4. error undefined reference ...............
    By amit_pansuria in forum Qt Programming
    Replies: 2
    Last Post: 8th June 2007, 14:28
  5. how to correctly compile threads support?
    By srhlefty in forum Installation and Deployment
    Replies: 9
    Last Post: 25th June 2006, 19:15

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
  •  
Qt is a trademark of The Qt Company.