PDA

View Full Version : Error - undefined reference qMain



tpf80
2nd November 2008, 02:03
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:


c:\Qt\4.4.1\lib/libqtmain.a(qtmain_win.o)(.text+0x156):qtmain_win. cpp: undefined reference to `qMain(int, char**)'

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.

tpf80
3rd November 2008, 01:25
ah after a few trials and errors, I figured it out.

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

lorebett
22nd February 2009, 19:06
I'm having the same error, but when linking a file which includes main...
am I missing something?

tpf80
22nd February 2009, 20:22
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.

lorebett
23rd February 2009, 07:54
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:



#undef main


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