Hi, there! I am try to cross compilation qt5 apps on Linux. By this wiki point: http://www.cmake.org/Wiki/CmakeMingw I can make the simple qt5 demo works.
main.cpp > #include <QApplication> > #include <QLabel> > > int main(int argc, char *argv[]) > { > QApplication a(argc, argv); > QLabel *label = new QLabel("Hello World"); > label->show(); > int i; > return a.exec(); > } > CMakeLists.txt > cmake_minimum_required(VERSION 2.8.9 FATAL_ERROR) > > project(testproject) > > # Find includes in corresponding build directories > set(CMAKE_INCLUDE_CURRENT_DIR ON) > # Instruct CMake to run moc automatically when needed > set(CMAKE_AUTOMOC ON) > > # Find the QtWidgets library > find_package(Qt5Widgets) > > # Tell CMake to create the helloworld executable > add_executable(helloworld main.cpp) > > # Use the Widgets module from Qt 5 > qt5_use_modules(helloworld Widgets) > loaden@qpsoft:~/qpSOFT/Projects/demo/m64$ cmake .. > -DCMAKE_PREFIX_PATH=/home/loaden/qpSOFT/Projects/BuildQt5-m64/qtbase > -DCMAKE_TOOLCHAIN_FILE=~/.mingw64.cmake > -- The C compiler identification is GNU 4.7.1 > -- The CXX compiler identification is GNU 4.7.1 > -- Check for working C compiler: /opt/mingw64/bin/x86_64-w64-mingw32-gcc > -- Check for working C compiler: /opt/mingw64/bin/x86_64-w64-mingw32-gcc > -- works > -- Detecting C compiler ABI info > -- Detecting C compiler ABI info - done > -- Check for working CXX compiler: /opt/mingw64/bin/x86_64-w64-mingw32-g++ > -- Check for working CXX compiler: /opt/mingw64/bin/x86_64-w64-mingw32-g++ > -- works > -- Detecting CXX compiler ABI info > -- Detecting CXX compiler ABI info - done > -- Configuring done > -- Generating done > -- Build files have been written to: /home/loaden/qpSOFT/Projects/demo/m64 > loaden@qpsoft:~/qpSOFT/Projects/demo/m64$ make > Scanning dependencies of target helloworld_automoc > [ 33%] Automoc for target helloworld > [ 33%] Built target helloworld_automoc > Scanning dependencies of target helloworld > [ 66%] Building CXX object CMakeFiles/helloworld.dir/main.cpp.obj > [100%] Building CXX object > CMakeFiles/helloworld.dir/helloworld_automoc.cpp.obj > Linking CXX executable helloworld.exe > [100%] Built target helloworld > When I try another demo, it's failed, and I can't find the reason. CMakeLists.txt > cmake_minimum_required(VERSION 2.8.9 FATAL_ERROR) > > project(testproject) > > # Find includes in corresponding build directories > set(CMAKE_INCLUDE_CURRENT_DIR ON) > # Instruct CMake to run moc automatically when needed > set(CMAKE_AUTOMOC ON) > > # Find the QtWidgets library > find_package(Qt5Widgets REQUIRED) > > # Tell CMake to create the helloworld executable > add_executable(helloworld > main.cpp > mainwindow.cpp > mainwindow.ui > ) > > # Use the Widgets module from Qt 5 > qt5_use_modules(helloworld Widgets) > > # Support UI files > qt5_wrap_ui(ui_mainwindow.h mainwindow.ui) > I can sure this project can be build for Linux target. It's just failed for cross build. loaden@qpsoft:~/qpSOFT/Projects/qtdemo/m64$ cmake .. > -DCMAKE_PREFIX_PATH=/home/loaden/qpSOFT/Projects/BuildQt5-m64/qtbase > -DCMAKE_TOOLCHAIN_FILE=~/.mingw64.cmake > -- The C compiler identification is GNU 4.7.1 > -- The CXX compiler identification is GNU 4.7.1 > -- Check for working C compiler: /opt/mingw64/bin/x86_64-w64-mingw32-gcc > -- Check for working C compiler: /opt/mingw64/bin/x86_64-w64-mingw32-gcc > -- works > -- Detecting C compiler ABI info > -- Detecting C compiler ABI info - done > -- Check for working CXX compiler: /opt/mingw64/bin/x86_64-w64-mingw32-g++ > -- Check for working CXX compiler: /opt/mingw64/bin/x86_64-w64-mingw32-g++ > -- works > -- Detecting CXX compiler ABI info > -- Detecting CXX compiler ABI info - done > -- Configuring done > -- Generating done > -- Build files have been written to: > /home/loaden/qpSOFT/Projects/qtdemo/m64 > loaden@qpsoft:~/qpSOFT/Projects/qtdemo/m64$ make > Scanning dependencies of target helloworld_automoc > [ 20%] Automoc for target helloworld > Generating moc_mainwindow.cpp > No such file or directory > AUTOMOC: error: process for > /home/loaden/qpSOFT/Projects/qtdemo/m64/moc_mainwindow.cpp failed: > No such file or directory > moc failed... > make[2]: *** [CMakeFiles/helloworld_automoc] Error 1 > make[1]: *** [CMakeFiles/helloworld_automoc.dir/all] Error 2 > make: *** [all] Error 2 > > -- Best Regards Yuchen
_______________________________________________ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development