[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 10:36:26 EDT 2012


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



More information about the CMake mailing list