[CMake] /NODEFAULTLIB:library errors

Mike Jackson imikejackson at gmail.com
Thu May 31 16:18:53 EDT 2007


I am trying to compile my Qt based application by using CMake to
generate VS2003 projects. The project compiles but dies at the link
stage with lots of errors. It seems I have been down this path before
but the last solution I had does not seem to work any more.

The errors are:

LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of
other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of
other libs; use /NODEFAULTLIB:library

For this I have in my CMakeLists.txt file:

IF(WIN32)
 SET(GUI_TYPE WIN32)
 ADD_DEFINITIONS(-DNODEFAULTLIB:library)
 SET (${QT_LIBRARIES} qtmain ${QT_LIBRARIES})
ENDIF(WIN32)

for which I thought used to work (Maybe a different verison of VS?
Could some one set me straight on this error, what to put into my
CMakeLists.txt file to get rid of it.

The Other error is:
MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol
_WinMain at 16 referenced in function _WinMainCRTStartup

which I know I have seen before, and again thought I had a solution
for but now I am not so sure. I thought the following in a
CMakeLists.txt file would work (as it did in the past).

SET (${QT_LIBRARIES} qtmain ${QT_LIBRARIES}). This does not seem to
work any more.

I would be eternally grateful if someone could shed some light on the above.

System Info: Windows XP, VS 2003 .Net (with latest service pack), CMake 2.4.6

I am usually a OS X/Linux guy so this is all a bit new.

Thanks
-- 
Mike Jackson
imikejackson _at_ gee-mail dot com


More information about the CMake mailing list