10

I know, I dug the whole internet to find out what the problem is and nothing has been helpful so far.

I am on Windows 7, using:

Qt 4.8.3: https://download.qt.io/archive/qt/4.8/4.8.3/qt-win-opensource-4.8.3-mingw.exe
MinGW32 4.4.0: http://nosymbolfound.blogspot.com/2012/12/since-until-now-qt-under-windows-is.html

I can compile any Qt demo example with Qt Creator, so I believe my system is working fine.
When trying to compile the program I ran into the well known issue:

g++ -enable-auto-import -o libqlcengine.a object_script.libqlcengine.Debug  -L".\lib" -L"c:\Qt\4.8.3\lib" -lwinmm -L../../hotplugmonitor/src -lhotplugmonitor -lQtScriptd4 -lQtXmld4 -lQtGuid4 -lQtCored4
c:/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../libmingw32.a(main.o):main.c:(.text+0x104): undefined reference to `WinMain@16'

(object_script.libqlcengine.Debug is a pretty long list of .o files)
Now, at that point of build it's trying to link a static .a library, so I see no reason for MinGW to look for WinMain. I did grep 'WinMain' and found no result on the entire source tree.

If you want to checkout the original sources:

svn co https://qlc.svn.sourceforge.net/svnroot/qlc qlc

Or my forked version:

git clone git://git.code.sf.net/p/qlcplus/code qlcplus-code

They have the same result.
Guys, what am I missing here ? I tried a whole bunch of C flags (-mwindows -lmingw32 -DQT_NEEDS_MAIN -lqtmain) but none worked.

Any magic please ?

P.S. Of course I can build on Linux either i386/amd64

SOLVED:

I just needed to add the following line to the .pro files where libraries were created:

win32:QMAKE_LFLAGS += -shared
Community
  • 1
  • 1
Massimo Callegari
  • 2,099
  • 1
  • 26
  • 39
  • 7
    Note that [it's ok to ask and answer your own questions](http://blog.stackoverflow.com/2011/07/its-ok-to-ask-and-answer-your-own-questions/). *(Knowing what the proper -shared flags are might help someone else. Also, leaving the question open makes it look "unanswered"...)* – HostileFork says dont trust SE Nov 20 '12 at 23:09
  • Very sorry. I am new here and didn't find how to close a question. I thought moderators would do that. – Massimo Callegari Nov 21 '12 at 13:57
  • 1
    Don't close it. Just add an answer yourself which details the solution. And then accept your own answer. – Bart Nov 21 '12 at 23:24
  • 1
    Anyone coming from Google and having the same problem with QML plugins failing to build on Windows / MinGW with 4.8.3: add `CONFIG += dll`, that'll be enough (absent winmain@16 error will go away), see http://www.mail-archive.com/interest@qt-project.org/msg04447.html . – mlvljr Dec 12 '12 at 10:01
  • If this question is sovled, please post your solution as an anser and accept it (see: http://blog.stackoverflow.com/2011/07/its-ok-to-ask-and-answer-your-own-questions/) – ollo Jan 23 '13 at 19:32

1 Answers1

5

[SOLVED]

I just figured out I needed to add the following line to the .pro files where libraries were created:

win32:QMAKE_LFLAGS += -shared
Massimo Callegari
  • 2,099
  • 1
  • 26
  • 39