Well I seem to have a typo in my original CMakeLists.txt file which was causing part of the problem and I did not fully understand what the other problems were.. but now I have a better idea which I am going to elaborate on a bit just in case someone else googles for the same problem.

There were 3 problems:

1: The /NODEFAULTLIB problem. What was happening was that between the previous libraries that I had compiled (HDF5) and my new libraries and my Application and Qt there was a mismatch between the type of C/C ++ runtime used for each. One of them had a "Single Threaded" runtime where the others were compiled against the "Multi-Threaded" runtime. Once I checked each project to make sure each project had the same settings, then I no longer needed this setting.

2:MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol [EMAIL PROTECTED] referenced in function _WinMainCRTStartup. This is caused because if you are building a "Windows" application versus a "console" application you need to have this function (_WinMain() ). Qt provides this for Windows in the "qtmain" library. So adding a line like the following to your CMakeLists.txt file should alleviate the problem.
        SET (${QT_LIBRARIES} qtmain ${QT_LIBRARIES})
And the secret to make this work is to _actually_ include the $ {QT_LIBRARIES} in your TARGET_LINK_LIBRARIES command ( which I finally noticed that I was NOT doing.. oops).

3: My third problem was more with HDF5 in a Dynamic Library. I needed to have the following:
        ADD_DEFINITIONS(-DHDF5_MODULES_ON)
        ADD_DEFINITIONS("-D_HDF5USEDLL_")
in my CMakeLists.txt file. This is used in a sub project that the main project includes through the ADD_SUBDIRECTORY(...) command so I _assumed_ it would get added to the parent project. This was not a valid assumption. Adding those lines to the parent project (which also links against HDF5.lib) was needed.

After all of the above was figured out I was finally able to compile and run my Qt based application. I am writing all this in the hopes that it will help some one else out in the future.

--
Mike Jackson   Senior Research Engineer
Innovative Management & Technology Services


On May 31, 2007, at 9:32 PM, Won-Ki Jeong wrote:

Try add the following in CMakeLists.txt

 SET( CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}
"/NODEFAULTLIBS:LIBCMT" )
 SET( CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}
"/NODEFAULTLIBS:MSVCRT" )
 SET( CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}
"/NODEFAULTLIBS:MSVCPRTD" )

On 5/31/07, Mike Jackson <[EMAIL PROTECTED]> wrote:
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
[EMAIL PROTECTED] 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
_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake


_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to