[CMake] can't link simple qt example
Glenn Hughes
ghughes02138 at gmail.com
Fri Dec 4 20:59:10 EST 2009
Hello all, I'm just getting going with CMake and qt, and I'm having a bit of
a problem.
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.)
When I build, I get the following link errors:
/usr/bin/ld: warning suggest use of -bind_at_load, as lazy binding may
result in errors or different symbols being used
/usr/bin/ld: Undefined symbols:
qInitResources_states()
/Developer/Examples/Qt/animation/states/states.build/Debug/states.build/Objects-normal/i386/main.o
reference to undefined qInitResources_states()
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
collect2: ld returned 1 exit status
Here's my CMakeLists.txt file, which I've cobbled together from various
online examples:
project(states)
cmake_minimum_required(VERSION 2.4.0)
find_package(Qt4 REQUIRED)
FIND_PACKAGE( Qt4 COMPONENTS QtCore QtGui ) # don't know if this was
necessary... I'm grasping at straws trying to force link ordering
include(${QT_USE_FILE})
set(states_SRCS
main.cpp
)
qt4_automoc(${states_SRCS})
SET( states_RESOURCES_SOURCES
states.qrc
)
QT4_ADD_RESOURCES( states_RESOURCES_SOURCES ${states_RESOURCES} )
INCLUDE_DIRECTORIES( . )
SET(QT_LIBS "${QT_LIBRARIES}")
ADD_EXECUTABLE( states MACOSX_BUNDLE ${states_SRCS} )
target_link_libraries(states ${QT_LIBRARIES})
#---
Here's the command output:
Ld
/Developer/Examples/Qt/animation/states/Debug/states.app/Contents/MacOS/states
normal i386
cd /Developer/Examples/Qt/animation/states
/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
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.
Any advice?
TIA
Glenn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20091204/208bb9dc/attachment-0001.htm>
More information about the CMake
mailing list