简体   繁体   English

在Windows上使用gcc / g ++进行CMake构建失败

[英]CMake build with gcc/g++ fails on Windows

I've installed CMake 3.14.4 (from cmake-3.14.4-win64-x64.msi) and GCC 5.1.0 (from tdm64-gcc-5.1.0-2.exe) on Windows 7 Enterprise and 10 Home (64-bit). 我在Windows 7 Enterprise和10 Home(64)上安装了CMake 3.14.4(来自cmake-3.14.4-win64-x64.msi)和GCC 5.1.0(来自tdm64-gcc-5.1.0-2.exe)位)。

I'm trying to build a .LIL from cpp/hpp source files github sources. 我正在尝试从cpp / hpp源文件github源构建一个.LIL The CMakeLists.txt refers to includes directory from the COTS install. CMakeLists.txt引用包含来自COTS安装的目录。 A header file in the includes directory has this if-else and the CMake build always errors out by falling in the last else block below: 包含目录中的头文件具有此if-else,并且CMake构建始终通过落在下面的最后一个else块中而出错:

# if defined(_M_AMD64)
#  include <wchar.h>
#  if BIP_CXX11_SUPPORT
typedef char16_t CciChar;
#  else
typedef wchar_t CciChar;
#  endif
typedef __int64 CciInt;
typedef unsigned __int64 CciCount;
#  define __CCI_WINDOWS__
# else
#  error The C plugin interface for IBM Integration Bus is only available 
for 64-bit Windows x86-64 systems
#endif

Steps: 脚步:

1. c:\iib-swm\build>cmake -DIIB_INSTALL_DIR=C:\Progra~1\IBM\IIB\10.0.0.12 
-G "MinGW Makefiles" ../source
-- The CXX compiler identification is GNU 5.1.0
-- Check for working CXX compiler: C:/software/C++Tools/tdm- 
gcc/bin/g++.exe
-- Check for working CXX compiler: C:/software/C++Tools/tdm- 
gcc/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/iib-swm/build

This is the content of CMakeSystem.cmake after this step: 这是此步骤之后的CMakeSystem.cmake的内容:

set(CMAKE_HOST_SYSTEM "Windows-6.1.7601")
set(CMAKE_HOST_SYSTEM_NAME "Windows")
set(CMAKE_HOST_SYSTEM_VERSION "6.1.7601")
set(CMAKE_HOST_SYSTEM_PROCESSOR "AMD64")



set(CMAKE_SYSTEM "Windows-6.1.7601")
set(CMAKE_SYSTEM_NAME "Windows")
set(CMAKE_SYSTEM_VERSION "6.1.7601")
set(CMAKE_SYSTEM_PROCESSOR "AMD64")

set(CMAKE_CROSSCOMPILING "FALSE")

set(CMAKE_SYSTEM_LOADED 1)

2. c:\iib-swm\build>cmake --build .

   -- Configuring done
   -- Generating done
   -- Build files have been written to: C:/iib-swm/build
   [ 33%] Building CXX object 
   CMakeFiles/statsdsw.dir/StatsdStatsWriter.cpp.obj
   In file included from 
   C:/Progra~1/IBM/IIB/10.0.0.12/server/include/plugin/BipCci.h:14:0,
             from 
   C:/Progra~1/IBM/IIB/10.0.0.12/server/include/plugin/BipCsi.h:14,
             from C:\iib-swm\source\StatsdStatsWriter.hpp:13,
             from C:\iib-swm\source\StatsdStatsWriter.cpp:10:
   C:/Progra~1/IBM/IIB/10.0.0.12/server/include/plugin/BipCos.h:170:4: 
   error: #error The C plugin inter
   face for IBM Integration Bus is only available for 64-bit Windows x86- 
   64 systems
   #  error The C plugin interface for IBM Integration Bus is only 
   available for 64-bit Windows x86-64
   systems
      ^
   CMakeFiles\statsdsw.dir\build.make:62: recipe for target 
   'CMakeFiles/statsdsw.dir/StatsdStatsWriter.
   cpp.obj' failed
   mingw32-make.exe[2]: *** 
   [CMakeFiles/statsdsw.dir/StatsdStatsWriter.cpp.obj] Error 3
   CMakeFiles\Makefile2:71: recipe for target 
   'CMakeFiles/statsdsw.dir/all' failed
   mingw32-make.exe[1]: *** [CMakeFiles/statsdsw.dir/all] Error 130
   Makefile:82: recipe for target 'all' failed
   mingw32-make.exe: *** [all] Error 130

I just can't understand that even when CMake recognizes the system processor as AMD64, it doesn't translate to _M_AMD64 in the includes .h file? 我只是无法理解,即使CMake将系统处理器识别为AMD64,它也不会转换为包含.h文件中的_M_AMD64 I've trawled CMake and related resources on the net. 我在网上搜寻了CMake和相关资源。 Tried running CMake as admin, shortened the path in which git project was cloned to without luck. 尝试以管理员身份运行CMake,缩短了git项目被克隆到的路径而没有运气。

PS: My only brush with cpp was at Uni 15 years ago, so please have mercy my lords (and ladies) if I've missed to C the obvious. PS:15年前,我唯一用cpp刷的是Uni,所以如果我错过了明显的C,请怜悯我的领主(和女士们)。

_M_AMD64 appears to be specific to Visual Studio compilers. _M_AMD64似乎特定于Visual Studio编译器。 The question is confusing because it suggests that CMake is doing the pre-processing. 问题很混乱,因为它表明CMake正在进行预处理。 It doesn't. 它没有。 You are using gcc . 你正在使用gcc gcc doesn't appear to implement the Visual Studio specific pre-processor macros. gcc似乎没有实现Visual Studio特定的预处理器宏。

You'll either have to alter the code to work with gcc or define the missing macros yourself using a CMake command like target_compile_definitions . 您要么必须更改代码才能使用gcc要么使用像target_compile_definitions这样的CMake命令自己定义丢失的宏。

Be aware that the README file says to use Visual Studio 2015 for building on Windows. 请注意, README文件说使用Visual Studio 2015在Windows上构建。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM