[CMake] qt4 simple app

Cristian Adam cristian.adam at gmx.net
Wed May 17 16:22:02 EDT 2006


Hi all,

I'm trying to compile a simple Qt4 (4.1.1) application with Visual 
Studio 7 .NET 2003, but I get this error:
Linking...
MSVCRT.lib(crtexew.obj) : error LNK2019: unresolved external symbol 
_WinMain at 16 referenced in function _WinMainCRTStartup

Here is my CMakeLists.txt file:

SET(QT_USE_QTMAIN TRUE)
INCLUDE (${CMAKE_ROOT}/Modules/FindQt4.cmake)

INCLUDE_DIRECTORIES(
	${QT_INCLUDES}
)

LINK_DIRECTORIES(
	${QT_LIBRARY_DIR}
)

IF(NOT QT_LIBRARIES)
	SET(QT_LIBRARIES
		${QT_QTCORE_LIBRARY}
		${QT_QTGUI_LIBRARY}
		${QT_QTMAIN_LIBRARY}
	)	
ENDIF(NOT QT_LIBRARIES)

ADD_EXECUTABLE(main WIN32 main.cpp)
TARGET_LINK_LIBRARIES(main ${QT_LIBRARIES})

If I compile the same application with MinGW with Qt4 (4.1.2) everything 
compiles just fine.

Also if I set qtmain.lib instead ${QT_QTMAIN_LIBRARY} everyting compiles 
just fine, but I don't like this hack, also I think that setting 
QT_LIBRARIES by hand is a hack.

Somehow SET(QT_USE_QTMAIN TRUE) is ignored for Visual Studio 7 .NET 2003.

Any ideas?

Regards,
Cristi.


More information about the CMake mailing list