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



我已经在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)。

我正在尝试从 cpp/hpp 源文件 github 源构建一个.LIL。CMakeLists.txt 是指 COTS 安装中的包含目录。包含目录中的头文件具有此 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

步骤:

1. c:iib-swmbuild>cmake -DIIB_INSTALL_DIR=C:Progra~1IBMIIB10.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

这是此步骤之后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-swmbuild>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-swmsourceStatsdStatsWriter.hpp:13,
from C:iib-swmsourceStatsdStatsWriter.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
^
CMakeFilesstatsdsw.dirbuild.make:62: recipe for target 
'CMakeFiles/statsdsw.dir/StatsdStatsWriter.
cpp.obj' failed
mingw32-make.exe[2]: *** 
[CMakeFiles/statsdsw.dir/StatsdStatsWriter.cpp.obj] Error 3
CMakeFilesMakefile2: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

我只是不明白,即使 CMake 将系统处理器识别为 AMD64,它也不会转换为包含 .h 文件中的_M_AMD64?我在网上搜索了CMake和相关资源。尝试以管理员身份运行 CMake,缩短了克隆 git 项目的路径,但没有运气。

PS:我唯一一次与 cpp 擦肩而过是在 15 年前的大学,所以如果我错过了显而易见的东西,请怜悯我的领主(和女士们)。

>_M_AMD64似乎是特定于Visual Studio编译器的。 这个问题令人困惑,因为它表明CMake正在进行预处理。 其实不然。 您正在使用gcc.gcc似乎没有实现特定于Visual Studio的预处理器宏。

您必须更改代码以使用gcc或使用 CMake 命令(如target_compile_definitions)自行定义缺少的宏。

请注意,自述文件说使用 Visual Studio 2015 在 Windows 上进行构建。

最新更新