Hello all, I'm just getting going with CMake and qt, and I'm having a bit of a problem.<br>I've assembled pretty much the simplest CMakeLists.txt file I can imagine for a very simple example qt project. (I'm trying to build the qt 4.6 "states" example using CMake.)<br>
<br>When I build, I get the following link errors:<br><br>/usr/bin/ld: warning suggest use of -bind_at_load, as lazy binding may result in errors or different symbols being used<br>/usr/bin/ld: Undefined symbols:<br>qInitResources_states()<br>
/Developer/Examples/Qt/animation/states/states.build/Debug/states.build/Objects-normal/i386/main.o reference to undefined qInitResources_states()<br>symbol typeinfo for QFactoryInterfaceused from dynamic library /Developer/SDKs/MacOSX10.4u.sdk/Library/Frameworks/QtCore.framework/QtCore(single module) not from earlier dynamic library QtGui.framework/Versions/4/QtGui(single module)<br>
symbol typeinfo for QEventTransitionPrivateused from dynamic library /Developer/SDKs/MacOSX10.4u.sdk/Library/Frameworks/QtCore.framework/QtCore(single module) not from earlier dynamic library QtGui.framework/Versions/4/QtGui(single module)<br>
symbol typeinfo for QAbstractItemModelPrivateused from dynamic library /Developer/SDKs/MacOSX10.4u.sdk/Library/Frameworks/QtCore.framework/QtCore(single module) not from earlier dynamic library QtGui.framework/Versions/4/QtGui(single module)<br>
symbol typeinfo for QAbstractEventDispatcherPrivateused from dynamic library /Developer/SDKs/MacOSX10.4u.sdk/Library/Frameworks/QtCore.framework/QtCore(single module) not from earlier dynamic library QtGui.framework/Versions/4/QtGui(single module)<br>
symbol typeinfo name for QFactoryInterfaceused from dynamic library /Developer/SDKs/MacOSX10.4u.sdk/Library/Frameworks/QtCore.framework/QtCore(single module) not from earlier dynamic library QtGui.framework/Versions/4/QtGui(single module)<br>
symbol typeinfo name for QEventTransitionPrivateused from dynamic library /Developer/SDKs/MacOSX10.4u.sdk/Library/Frameworks/QtCore.framework/QtCore(single module) not from earlier dynamic library QtGui.framework/Versions/4/QtGui(single module)<br>
symbol typeinfo name for QAbstractItemModelPrivateused from dynamic library /Developer/SDKs/MacOSX10.4u.sdk/Library/Frameworks/QtCore.framework/QtCore(single module) not from earlier dynamic library QtGui.framework/Versions/4/QtGui(single module)<br>
symbol typeinfo name for QAbstractEventDispatcherPrivateused from dynamic library /Developer/SDKs/MacOSX10.4u.sdk/Library/Frameworks/QtCore.framework/QtCore(single module) not from earlier dynamic library QtGui.framework/Versions/4/QtGui(single module)<br>
symbol vtable for QFactoryInterfaceused from dynamic library /Developer/SDKs/MacOSX10.4u.sdk/Library/Frameworks/QtCore.framework/QtCore(single module) not from earlier dynamic library QtGui.framework/Versions/4/QtGui(single module)<br>
symbol vtable for QEventTransitionPrivateused from dynamic library /Developer/SDKs/MacOSX10.4u.sdk/Library/Frameworks/QtCore.framework/QtCore(single module) not from earlier dynamic library QtGui.framework/Versions/4/QtGui(single module)<br>
symbol vtable for QAbstractItemModelPrivateused from dynamic library /Developer/SDKs/MacOSX10.4u.sdk/Library/Frameworks/QtCore.framework/QtCore(single module) not from earlier dynamic library QtGui.framework/Versions/4/QtGui(single module)<br>
symbol vtable for QAbstractEventDispatcherPrivateused from dynamic library /Developer/SDKs/MacOSX10.4u.sdk/Library/Frameworks/QtCore.framework/QtCore(single module) not from earlier dynamic library QtGui.framework/Versions/4/QtGui(single module)<br>
collect2: ld returned 1 exit status<br><br>Here's my CMakeLists.txt file, which I've cobbled together from various online examples:<br><br>project(states) <br>cmake_minimum_required(VERSION 2.4.0)<br>find_package(Qt4 REQUIRED) <br>
<br>FIND_PACKAGE( Qt4 COMPONENTS QtCore QtGui ) # don't know if this was necessary... I'm grasping at straws trying to force link ordering<br><br>include(${QT_USE_FILE})<br><br>set(states_SRCS<br> main.cpp<br>)<br>
<br>qt4_automoc(${states_SRCS})<br><br>SET( states_RESOURCES_SOURCES<br> states.qrc<br> )<br><br>QT4_ADD_RESOURCES( states_RESOURCES_SOURCES ${states_RESOURCES} )<br><br>INCLUDE_DIRECTORIES( . ) <br><br>SET(QT_LIBS "${QT_LIBRARIES}")<br>
<br>ADD_EXECUTABLE( states MACOSX_BUNDLE ${states_SRCS} )<br>target_link_libraries(states ${QT_LIBRARIES}) <br> <br>#---<br><br>Here's the command output:<br>Ld /Developer/Examples/Qt/animation/states/Debug/states.app/Contents/MacOS/states normal i386<br>
cd /Developer/Examples/Qt/animation/states<br> /usr/bin/g++-4.0 -o /Developer/Examples/Qt/animation/states/Debug/states.app/Contents/MacOS/states -L/Developer/Examples/Qt/animation/states/Debug -F/Developer/Examples/Qt/animation/states/Debug -F/Developer/SDKs/MacOSX10.4u.sdk/Library/Frameworks -filelist /Developer/Examples/Qt/animation/states/states.build/Debug/states.build/Objects-normal/i386/states.LinkFileList -arch i386 -Wl,-Y,1455 -mmacosx-version-min=10.4 -Wl,-search_paths_first -headerpad_max_install_names -framework QtGui -framework Carbon -framework AppKit -framework QtCore /usr/lib/libz.dylib -framework ApplicationServices -isysroot /Developer/SDKs/MacOSX10.4u.sdk<br>
<br>As you can see both QtCore and QtGui are being passed to the link command... So, I'm at a bit of a loss. I've tried building both from the command line and in XCode with the same errors in both places. I've tried a bunch of different tweaks to the CMakeLists.txt file, throwing out the cache and everything else and re-make-making between tries, but the result is always the same.<br>
<br>Any advice? <br><br>TIA<br>Glenn<br><br>