2014-07-06 59 views
1

我使用此工具鏈交叉編譯(從64位的openSUSE到窗口32位):如何使用cmake與工具鏈文件進行交叉編譯時使用find_package?

# the name of the target operating system 
SET(CMAKE_SYSTEM_NAME Windows) 

# which compilers to use for C and C++ 
SET(CMAKE_C_COMPILER /usr/bin/i686-w64-mingw32-gcc) 
SET(CMAKE_CXX_COMPILER /usr/bin/i686-w64-mingw32-g++) 
SET(CMAKE_RC_COMPILER /usr/bin/i686-w64-mingw32-windres) 

# here is the target environment located 
SET(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32) 

# adjust the default behaviour of the FIND_XXX() commands: 
# search headers and libraries in the target environment, search 
# programs in the host environment 
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 

然後使用這樣的: cmake的-DCMAKE_TOOLCHAIN_FILE =〜/ ZCROSS/mingw32.cmake。 但每次我試圖用這個cmake的文件時間:

project(ut6) 
cmake_minimum_required(VERSION 2.6) 
find_package(Qt4 REQUIRED) 

include_directories(${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR}) 

set(ut6_SRCS ut6.cpp main.cpp) 
qt4_automoc(${ut6_SRCS}) 
add_executable(ut6 ${ut6_SRCS}) 
target_link_libraries(ut6 ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY}) 
install(TARGETS ut6 RUNTIME DESTINATION bin) 

這個控制檯出看跌期權:

CMake Warning at /usr/share/cmake/Modules/FindQt4.cmake:657 (message): 
    /usr/bin/qmake reported QT_INSTALL_LIBS as "/usr/lib64" but QtCore could 
    not be found there. Qt is NOT installed correctly for the target build 
    environment. 
Call Stack (most recent call first): 
    CMakeLists.txt:3 (find_package) 


CMake Error at /usr/share/cmake/Modules/FindQt4.cmake:661 (message): 
    Could NOT find QtCore. Check 
    /home/aked/projects/ut6/CMakeFiles/CMakeError.log for more details. 
Call Stack (most recent call first): 
    CMakeLists.txt:3 (find_package) 

看起來是尋找本地系統庫中,但不是mingw32的位置,我可以交叉編譯時仍然使用find_package?

現在我只是手動鏈接到libQtCore.dll.a,它的工作原理,但是當我想用qt4_automoc生成moc信息時,我又被卡住了。感謝您的幫助

回答

2

找到了解決辦法,找到QT4當你穿越compilling,你都必須使用該手動設置的一切只是不工作:(工具鏈文件中)(在每個系統上的目錄可能不一樣)

set(QT_BINARY_DIR /usr/i686-w64-mingw32/sys-root/mingw/bin/) 
set(QT_LIBRARY_DIR ${KDE_PREFIX}/lib) 
set(QT_QTCORE_LIBRARY ${KDE_PREFIX}/lib/libQtCore4.a) 
set(QT_QTCORE_INCLUDE_DIR ${KDE_PREFIX}/include/QtCore) 
set(QT_MKSPECS_DIR ${KDE_PREFIX}/mkspecs) 
set(QT_MOC_EXECUTABLE ${QT_BINARY_DIR}/moc) 
set(QT_QMAKE_EXECUTABLE ${QT_BINARY_DIR}/qmake) 
set(QT_UIC_EXECUTABLE ${QT_BINARY_DIR}/uic) 
相關問題