[CMake] Can't link Qt libraries CMake 2.8.7 + OSX 10.5 + Qt 4.8.1

Michael Jackson mike.jackson at bluequartz.net
Fri Mar 30 11:07:34 EDT 2012


Please reply to the list also so others may help.

 Can you use either ccmake or CMake-GUI to set the necessary flag? 
--
Mike Jackson <www.bluequartz.net>

On Mar 30, 2012, at 10:51 AM, Carlo Nicolini wrote:

> As you said the architecture of QtGui library is:
> 
> /Library/Frameworks/QtGui.framework/QtGui: Mach-O 64-bit dynamically linked shared library x86_64
> 
> so I've added in my CMakeLists.txt the following command
> 
> set(CMAKE_OSX_ARCHITECTURES "x86_64")
> 
> but I still get that error :(
> 
> These are for info, the compiler options which are issued by QtCreator for the same project which works that way
> 
> g++-4.0 -c -pipe -g -gdwarf-2 -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Qt4.8/mkspecs/macx-g++40 -I. -I/Library/Frameworks/QtCore.framework/Versions/4/Headers -I/usr/include/QtCore -I/Library/Frameworks/QtGui.framework/Versions/4/Headers -I/usr/include/QtGui -I/usr/include -I. -I. -F/Library/Frameworks -o main.o main.cpp
> 
> As it can be seen , there are different options from the options issued by cmake (I set verbosity 1)
> 
> /opt/local/bin/c++    -Wl,-search_paths_first -Wl,-headerpad_max_install_names   CMakeFiles/QtTest.dir/main.cpp.o CMakeFiles/QtTest.dir/mainwindow.cpp.o CMakeFiles/QtTest.dir/moc_mainwindow.cxx.o  -o QtTest.app/Contents/MacOS/QtTest  -framework QtGui -framework QtCore 
> 
> 
> 
> 
> 2012/3/30 Michael Jackson <mike.jackson at bluequartz.net>
> The error is this:
> 
> > ld warning: in /Library/Frameworks//QtGui.framework/QtGui, file is not of required architecture
> 
> Your program is compiling for one architecture but the Qt libs are compiled for another. My guess is that you are default compiling for 32 bit (since that is the default under 10.5.8) but the Qt 4.8.1 libraries are 64 bit. You can check this but issuing the following command:
> 
> file /Library/Frameworks//QtGui.framework/QtGui
> 
> and the output will tell you what architectures are present in the library.
> 
> Then add the "x86_64" flag for the OS_X_ARCHITECTURES to your cmake cache using either ccmake or CMake-GUI.
> 
> Hope that helps
> ___________________________________________________________
> Mike Jackson                    Principal Software Engineer
> BlueQuartz Software                            Dayton, Ohio
> mike.jackson at bluequartz.net              www.bluequartz.net
> 
> On Mar 30, 2012, at 8:55 AM, Carlo Nicolini wrote:
> 
> > I've a very strange problem while trying to compile a the example provided at
> >
> > http://www.cmake.org/Wiki/images/2/25/QtTest-Package-Example.zip
> >
> > System Informations:
> > Mac OSX 10.5.8
> >
> > cmake version 2.8.7 installed from latest dmg package available
> > Qt 4.8.1 Installed from latest repositories
> >
> > I issue the following commands in the QtTest-Package example
> > cmake .
> > make
> >
> > I kept the original CMakeLists.txt unmodified but at last stage, the linker can't find symbols and this is the output:
> >
> > ld warning: in /Library/Frameworks//QtGui.framework/QtGui, file is not of required architecture
> > ld warning: in /Library/Frameworks//QtCore.framework/QtCore, file is not of required architecture
> > Undefined symbols:
> >   "QWidget::languageChange()", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QWidget::focusInEvent(QFocusEvent*)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QMainWindow::createPopupMenu()", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QWidget::windowActivationChange(bool)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QWidget::QWidget(QWidget*, QFlags<Qt::WindowType>)", referenced from:
> >       Ui_MainWindow::setupUi(QMainWindow*)       in mainwindow.cpp.o
> >   "QApplication::QApplication(int&, char**, int)", referenced from:
> >       _main in main.cpp.o
> >   "QWidget::inputMethodEvent(QInputMethodEvent*)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QWidget::paintEvent(QPaintEvent*)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QMainWindow::qt_metacall(QMetaObject::Call, int, void**)", referenced from:
> >       MainWindow::qt_metacall(QMetaObject::Call, int, void**)in moc_mainwindow.cxx.o
> >   "QWidget::mouseMoveEvent(QMouseEvent*)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QWidget::keyReleaseEvent(QKeyEvent*)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QApplication::exec()", referenced from:
> >       _main in main.cpp.o
> >   "QWidget::macEvent(OpaqueEventHandlerCallRef*, OpaqueEventRef*)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QMetaObject::connectSlotsByName(QObject*)", referenced from:
> >       Ui_MainWindow::setupUi(QMainWindow*)       in mainwindow.cpp.o
> >   "QWidget::focusOutEvent(QFocusEvent*)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "typeinfo for QMainWindow", referenced from:
> >       typeinfo for MainWindowin moc_mainwindow.cxx.o
> >   "QMainWindow::addToolBar(QToolBar*)", referenced from:
> >       Ui_MainWindow::setupUi(QMainWindow*)       in mainwindow.cpp.o
> >   "QWidget::dragLeaveEvent(QDragLeaveEvent*)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QWidget::inputMethodQuery(Qt::InputMethodQuery) const", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QWidget::focusNextPrevChild(bool)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QWidget::devType() const", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QWidget::mouseReleaseEvent(QMouseEvent*)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QMainWindow::setMenuBar(QMenuBar*)", referenced from:
> >       Ui_MainWindow::setupUi(QMainWindow*)       in mainwindow.cpp.o
> >   "QWidget::dragMoveEvent(QDragMoveEvent*)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QMenuBar::QMenuBar(QWidget*)", referenced from:
> >       Ui_MainWindow::setupUi(QMainWindow*)       in mainwindow.cpp.o
> >   "QMainWindow::~QMainWindow()", referenced from:
> >       MainWindow::MainWindow(QWidget*)in mainwindow.cpp.o
> >       MainWindow::MainWindow(QWidget*)in mainwindow.cpp.o
> >       MainWindow::~MainWindow()in mainwindow.cpp.o
> >       MainWindow::~MainWindow()in mainwindow.cpp.o
> >       MainWindow::~MainWindow()in mainwindow.cpp.o
> >   "QWidget::styleChange(QStyle&)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QWidget::setVisible(bool)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QWidget::hideEvent(QHideEvent*)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QWidget::fontChange(QFont const&)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QWidget::resizeEvent(QResizeEvent*)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QObject::eventFilter(QObject*, QEvent*)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QMainWindow::contextMenuEvent(QContextMenuEvent*)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QWidget::resize(QSize const&)", referenced from:
> >       QWidget::resize(int, int)in mainwindow.cpp.o
> >   "QWidget::paletteChange(QPalette const&)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QWidget::minimumSizeHint() const", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QMainWindow::QMainWindow(QWidget*, QFlags<Qt::WindowType>)", referenced from:
> >       MainWindow::MainWindow(QWidget*)in mainwindow.cpp.o
> >       MainWindow::MainWindow(QWidget*)in mainwindow.cpp.o
> >   "QMainWindow::setStatusBar(QStatusBar*)", referenced from:
> >       Ui_MainWindow::setupUi(QMainWindow*)       in mainwindow.cpp.o
> >   "QObject::objectName() const", referenced from:
> >       Ui_MainWindow::setupUi(QMainWindow*)       in mainwindow.cpp.o
> >   "QWidget::closeEvent(QCloseEvent*)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "non-virtual thunk to QWidget::metric(QPaintDevice::PaintDeviceMetric) const", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QWidget::paintEngine() const", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QMainWindow::event(QEvent*)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QWidget::dropEvent(QDropEvent*)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QWidget::moveEvent(QMoveEvent*)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QWidget::leaveEvent(QEvent*)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QWidget::enterEvent(QEvent*)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "non-virtual thunk to QWidget::paintEngine() const", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "non-virtual thunk to QWidget::devType() const", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QString::free(QString::Data*)", referenced from:
> >       QString::~QString()in mainwindow.cpp.o
> >   "QWidget::dragEnterEvent(QDragEnterEvent*)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QMainWindow::qt_metacast(char const*)", referenced from:
> >       MainWindow::qt_metacast(char const*)in moc_mainwindow.cxx.o
> >   "QWidget::heightForWidth(int) const", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QMainWindow::staticMetaObject", referenced from:
> >       MainWindow::staticMetaObject        in moc_mainwindow.cxx.o
> >   "QWidget::wheelEvent(QWheelEvent*)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QObject::setObjectName(QString const&)", referenced from:
> >       Ui_MainWindow::setupUi(QMainWindow*)       in mainwindow.cpp.o
> >       Ui_MainWindow::setupUi(QMainWindow*)       in mainwindow.cpp.o
> >       Ui_MainWindow::setupUi(QMainWindow*)       in mainwindow.cpp.o
> >       Ui_MainWindow::setupUi(QMainWindow*)       in mainwindow.cpp.o
> >       Ui_MainWindow::setupUi(QMainWindow*)       in mainwindow.cpp.o
> >   "QWidget::mouseDoubleClickEvent(QMouseEvent*)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QWidget::enabledChange(bool)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QWidget::tabletEvent(QTabletEvent*)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QString::fromUtf8(char const*, int)", referenced from:
> >       Ui_MainWindow::setupUi(QMainWindow*)       in mainwindow.cpp.o
> >       Ui_MainWindow::setupUi(QMainWindow*)       in mainwindow.cpp.o
> >       Ui_MainWindow::setupUi(QMainWindow*)       in mainwindow.cpp.o
> >       Ui_MainWindow::setupUi(QMainWindow*)       in mainwindow.cpp.o
> >       Ui_MainWindow::setupUi(QMainWindow*)       in mainwindow.cpp.o
> >   "QWidget::keyPressEvent(QKeyEvent*)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QMainWindow::setCentralWidget(QWidget*)", referenced from:
> >       Ui_MainWindow::setupUi(QMainWindow*)       in mainwindow.cpp.o
> >   "QObject::customEvent(QEvent*)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QWidget::changeEvent(QEvent*)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QWidget::showEvent(QShowEvent*)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QObject::disconnectNotify(char const*)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QStatusBar::QStatusBar(QWidget*)", referenced from:
> >       Ui_MainWindow::setupUi(QMainWindow*)       in mainwindow.cpp.o
> >   "QWidget::mousePressEvent(QMouseEvent*)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QObject::timerEvent(QTimerEvent*)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QApplication::~QApplication()", referenced from:
> >       _main in main.cpp.o
> >       _main in main.cpp.o
> >   "QWidget::setWindowTitle(QString const&)", referenced from:
> >       Ui_MainWindow::retranslateUi(QMainWindow*)        in mainwindow.cpp.o
> >   "QCoreApplication::translate(char const*, char const*, char const*, QCoreApplication::Encoding)", referenced from:
> >       Ui_MainWindow::retranslateUi(QMainWindow*)        in mainwindow.cpp.o
> >   "QWidget::metric(QPaintDevice::PaintDeviceMetric) const", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QWidget::sizeHint() const", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QObject::connectNotify(char const*)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QToolBar::QToolBar(QWidget*)", referenced from:
> >       Ui_MainWindow::setupUi(QMainWindow*)       in mainwindow.cpp.o
> >   "QObject::childEvent(QChildEvent*)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> >   "QWidget::actionEvent(QActionEvent*)", referenced from:
> >       vtable for MainWindowin moc_mainwindow.cxx.o
> > ld: symbol(s) not found
> > collect2: ld returned 1 exit status
> > make[2]: *** [QtTest.app/Contents/MacOS/QtTest] Error 1
> > make[1]: *** [CMakeFiles/QtTest.dir/all] Error 2
> > make: *** [all] Error 2
> >
> >
> > Trying to build the same example under QtCreator works smoothly, as well in my system as in another Linux box.
> >
> > What can be the error here?
> >
> > Many thanks in advance
> > --
> >
> > Powered by www.kitware.com
> >
> > Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> >
> > Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
> >
> > Follow this link to subscribe/unsubscribe:
> > http://www.cmake.org/mailman/listinfo/cmake
> 
> 
> 
> 
> -- 
> Carlo Nicolini
> LION Laboratory (Machine Learning and Intelligent Optimization)
> DISI - Dipartimento di Scienza ed Ingegneria dell'Informazione
> Universita' di Trento
> Via Sommarive, 14
> 38100 Trento (Italy)
> ......................................................................
> web sites:
> http://disi.unitn.it/~nicolini/ - personal
> http://www.intelligent-optimization.org/
> http://www.reactive-search.org/
> 



More information about the CMake mailing list