<div dir="ltr"><div><br></div><div>This has been driving me crazy for a while now. Occurs for both OSX and Linux.<br></div><div><br></div><div>OSX Mavericks 10.9.5, openSUSE Linux 12.3</div><div>CMake 3.1.1</div><div>Qt 5.4.1 (both shared and static builds, compiled from source)</div><div><br></div><div>Using cmake to compile and link the simple Qt HelloWorld app against Qt shared libraries works just fine. </div><div><br></div><div>Using the same cmake file and specifying the Qt static libraries instead, it fails in the linking (OSX: Undefined symbols for architecture x86_64, ld: symbol(s) not found for architecture x86_64’; LINUX: undefined reference to …, collect2 error: ld returned 1 exit status)</div><div><br></div><div>Message would seem to point towards static libraries not compiled 64 bit.</div><div><br></div><div>But, if I use qmake to generate the makefile to use with the Qt static libraries, it compiles and links with no problem. No symbol problem here. Seems to indicate the static libraries are fine.</div><div><br></div><div>Since using qmake seems to work fine I can’t pin down what the problem is with cmake.</div><div><br></div><div>Can anyone shed some light on this?</div><div><br></div><div>Source, CMakeLists.txt, and qmake .pro contents below. I’ve also attached failed linking output from OSX and linux cmake/make.</div><div><br></div><div>main.cpp:</div><div><br></div><div>#include <QApplication></div><div>#include <QPushButton></div><div> </div><div>int main(int argc, char **argv)</div><div>{</div><div>    QApplication app (argc, argv);</div><div> </div><div>    QPushButton button ("Hello world !");</div><div>    button.show();</div><div> </div><div>    return app.exec();</div><div>}</div><div><br></div><div><br></div><div>CMakeLists.txt:</div><div><br></div><div>cmake_minimum_required(VERSION 2.8.11)</div><div><br></div><div>project(helloworld)</div><div>set(CMAKE_INCLUDE_CURRENT_DIR ON)</div><div>set(CMAKE_AUTOMOC ON)</div><div>find_package(Qt5Widgets REQUIRED)</div><div>add_executable(helloworld main.cpp)</div><div>target_link_libraries(helloworld Qt5::Widgets)</div><div><br></div><div><br></div><div><a href="http://main.pro" target="_blank">main.pro</a>:</div><div><br></div><div>SOURCES = main.cpp</div><div>CONFIG += qt warn_on release</div><div>QT += core widgets gui</div><div><br></div><div><br></div><div>Thanks in advance.</div><div><br></div><div><br></div><div>Paul</div><div><br></div><div><br></div></div>