Linux 交叉编译器生成错误-***目标模式不包含';%';。停止

Linux 交叉编译器生成错误-***目标模式不包含';%';。停止,linux,gcc,cmake,cross-compiling,mingw-w64,Linux,Gcc,Cmake,Cross Compiling,Mingw W64,我尝试在Linux上使用Windows交叉编译器(minw64)进行构建,但出现以下错误 [ 90%] Built target vsl.lang.types Scanning dependencies of target copyFoms_vslation [ 90%] Built target copyFoms_vslation src/vslation/CMakeFiles/vslation.Gps.dir/build.make:152: *** target pattern contai

我尝试在Linux上使用Windows交叉编译器(minw64)进行构建,但出现以下错误

[ 90%] Built target vsl.lang.types
Scanning dependencies of target copyFoms_vslation
[ 90%] Built target copyFoms_vslation
src/vslation/CMakeFiles/vslation.Gps.dir/build.make:152: *** target pattern contains no '%'.  Stop.
CMakeFiles/Makefile2:201: recipe for target 'src/vslation/CMakeFiles/vslation.Xps.dir/all' failed
make[1]: *** [src/vslation/CMakeFiles/vslation.Xps.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
我通过以下命令使用cmake:

cmake -DCMAKE_TOOLCHAIN_FILE=/home/vagrant/toolchain.cmake ../../src-gen
我的工具链文件如下所示:

SET(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_CROSS_COMPILING TRUE)

SET(LIBRARY_PATH /home/vagrant/mingw64/lib/)
SET(CMAKE_INCLUDE_PATH /home/vagrant/mingw64/include/)

SET(CMAKE_FIND_ROOT_PATH /home/vagrant/mingw64/)

INCLUDE_DIRECTORIES(SYSTEM
 "/home/vagrant/mingw64/include"
)

#SET(CMAKE_SYSROOT /home/vagrant/mingw64/)

# specify the cross compiler
SET(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
SET(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)

SET(CMAKE_CXX_COMPILER_AR x86_64-w64-mingw32-gcc-ar)
SET(CMAKE_CXX_COMPILER_RANLIB x86_64-w64-mingw32-gcc-ranlib)

SET(CMAKE_C_COMPILER_AR x86_64-w64-mingw32-gcc-ar)
SET(CMAKE_C_COMPILER_RANLIB x86_64-w64-mingw32-gcc-ranlib)

# Cmake Path - Version 3.12.1
SET(CMAKE_COMMAND /home/vagrant/cmake/cmake-3.12.1-Linux-x86_64/bin/cmake)
SET(CMAKE_CPACK_COMMAND /home/vagrant/cmake/cmake-3.12.1-Linux-x86_64/bin/cpack)
SET(CMAKE_CTEST_COMMAND /home/vagrant/cmake/cmake-3.12.1-Linux-x86_64/bin/ctest)
SET(CMAKE_EDIT_COMMAND /home/vagrant/cmake/cmake-3.12.1-Linux-x86_64/bin/cmake-gui)

# Rti Libs
SET(RTI_INCLUDE_DIRS /home/vagrant/mingw64/include/rti1516e)

# Poco Libs
SET(PocoFoundation_DIR /home/vagrant/mingw64/lib/cmake/Poco)
SET(PocoJSON_DIR /home/vagrant/vagrant/lib/cmake/Poco)
SET(PocoNet_DIR /home/vagrant/vagrant/lib/cmake/Poco)
SET(PocoUtil_DIR /home/vagrant/vagrant/lib/cmake/Poco)
SET(PocoXML_DIR /home/vagrant/vagrant/lib/cmake/Poco)
SET(Poco_DIR /home/vagrant/vagrant/lib/cmake/Poco)

# Pvsomip Libs
SET(vsomeip_DIR /home/vagrant/mingw64/lib/cmake/vsomeip)

# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)

# for libraries and headers in the target directories
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

set(CMAKE_INSTALL_RPATH )
我试图把图书馆分开保存。不要对toolcahin.cmake中的库配置感到好奇

这是CMakeLists.txt。我希望这能有所帮助

cmake_minimum_required(VERSION 3.4)

if(MSVC)
    message(FATAL_ERROR "MSVC not supported")
endif()

if(${CMAKE_CXX_COMPILER} MATCHES "mingw64")
    set(MINGW64 true)
    set(FMU_BINARY_DIR binaries/win64)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPOCO_WIN32_UTF8")
elseif(${CMAKE_CXX_COMPILER} MATCHES "mingw32")
    set(MINGW32 true)
    set(FMU_BINARY_DIR binaries/win32)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPOCO_WIN32_UTF8")
else()
    set(USE_VSOMEIP true)
    set(FMU_BINARY_DIR binaries/linux64)
endif()

find_path(RTI_INCLUDE_DIRS NAMES RTI
 PATH_SUFFIXES include/rti1516e
 DOC "The rti1516e include files"
)
if(RTI_INCLUDE_DIRS)
  #message(STATUS "rti1516e headers found: ${RTI_INCLUDE_DIRS}")
else()
  message(FATAL_ERROR "rti1516e headers NOT found")
endif (RTI_INCLUDE_DIRS)
set(RTI_LIBRARIES rti1516e fedtime1516e)

find_package(Poco 1.8.1 COMPONENTS Util JSON Net Foundation REQUIRED)
if(USE_VSOMEIP)
    find_package (vsomeip 2.6.2 REQUIRED)
    include_directories(include ${RTI_INCLUDE_DIRS} ${Poco_INCLUDE_DIRS} ${VSOMEIP_INCLUDE_DIRS})
    set(LIBS ${RTI_LIBRARIES} ${Poco_LIBRARIES} ${VSOMEIP_LIBRARIES})
else()
    include_directories(include ${RTI_INCLUDE_DIRS} ${Poco_INCLUDE_DIRS})
    set(LIBS ${RTI_LIBRARIES} ${Poco_LIBRARIES})
endif()

set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG -s")
set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -U__STRICT_ANSI__ -DRTI_USES_STD_FSTREAM -Wno-deprecated -Wno-deprecated-declarations")

subdirs(src/model src/gtl/lang/manager src/vslation src/gtl/lang/types )

错误消息引用的行
src/vslation/CMakeFiles/vslation.Gps.dir/build.make:152
的内容是什么?将这一行添加到您的问题帖子中。这是第152-156行的消息
src/vslation/vslation.Gps.exe:Poco::Util NOTFOUND src/vslation/vslation.Gps.exe:Poco::JSON-NOTFOUND src/vslation/vslation.Gps.exe:Net NOTFOUND src/vslation/vslation.Gps.exe:Poco::XML-NOTFOUND src/vslation/vslation.Gps.exe:Poco::Foundation NOTFOUND
Poco::Util NOTFOUND
表示CMake尚未找到对应的Poco库。通常,CMake自己抱怨在
target\u link\u库中使用了“NOTFOUND”
,但您的情况似乎有所不同:问题只是在构建阶段才被发现。是的,这很奇怪。所有缺少的库都可用。我的工具链中有什么遗漏吗?我们已经有了Windows编译器。build.make与Windows fine
src/simulation/simulation.Gps.exe中的build.make外观相同:W:/msys64/mingw64/lib/libPocoUtil.dll.a src/simulation/simulation.Gps.exe:W:/msys64/mingw64/libPocoNet.dll.a src/simulation/simulation.Gps.exe:W:/msys64/mingw64/libPocoNet.dll.a src/simulation/simulation.Gps.exe:W:/msys64/mingw64/lib/libPocoXML.dll.a
您将
CMAKE\u FIND\u ROOT\u PATH\u MODE\u LIBRARY
设置为only,因此只能在
CMAKE\u FIND\u ROOT\u PATH
变量中列出的目录下搜索库。有关更多详细信息,请参阅该问题和我的答案:。