Posting a solution to my previous problem<br><br>I wasn't linking in the generated resource file. <br>Here's a working very short CMake file for building the "states" Qt4.6 example:<br><br>---<br>#basic stuff<br>
PROJECT(states) # the name of your project<br>CMAKE_MINIMUM_REQUIRED(VERSION 2.4.0)<br><br>#find qt, and include qt macros<br>FIND_PACKAGE(Qt4 REQUIRED) # find and setup Qt4 for this project<br>INCLUDE(${QT_USE_FILE})<br>
<br>#set up src and rsrc variables<br>SET( states_SRCS main.cpp )<br>SET( states_RESOURCES states.qrc )<br><br>#generate moc dependencies, generate "resources as compiled binary data" files<br>QT4_AUTOMOC(${states_SRCS})<br>
QT4_ADD_RESOURCES( states_RESOURCES_SOURCES ${states_RESOURCES} )<br><br>#the moc files will be generated into the binary directory. <br>#Add this to the include search path so #include "main.moc" will work<br>INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} )<br>
<br>#make an executable target, and associate its sources, and declare what external libraries its depends on<br>ADD_EXECUTABLE( states MACOSX_BUNDLE ${states_SRCS} ${states_RESOURCES_SOURCES} )<br>TARGET_LINK_LIBRARIES(states ${QT_LIBRARIES}) <br>
---<br><br>One thing of note: In order for QT4_AUTOMOC to work, I had to move the definition of the Pixmap class into a new header file named main.h. It seems in general putting your Q_OBJECT class defs in a header is required when building Qt projects under CMake... but there's probably some way around it.<br>
<br>Cheers<br>G<br><br><div class="gmail_quote">On Fri, Dec 4, 2009 at 8:59 PM, Glenn Hughes <span dir="ltr"><<a href="mailto:ghughes02138@gmail.com">ghughes02138@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
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><font color="#888888">Glenn<br><br>
</font></blockquote></div><br>