如何在 Solaris 上构建 AWS C++ SDK?
How to build AWS C++ SDK on Solaris?
我正在尝试在 Solaris 上构建 AWS C++ SDK,但我无法成功。
我在 AWS C++ SDK 页面上发现 this 未解决的问题,说这是可能的,但没有关于它的指南,我希望这里有人可以提供帮助。
这是我用来构建它的命令:
$ cmake ../aws-sdk-cpp/ -DCMAKE_BUILD_TYPE=Debug -DBUILD_ONLY="s3"
这是输出:
-- TARGET_ARCH not specified; inferring host OS to be platform compilation target
-- Building AWS libraries as shared objects
-- Generating linux build config
-- Building project version: 1.7.134
-- Configuring done
-- Generating done
-- Build files have been written to: /workspace/dmoini/sdk_build/.deps
gmake: Warning: File 'Makefile' has modification time 267 s in the future
gmake[1]: Warning: File 'CMakeFiles/Makefile2' has modification time 267 s in the future
gmake[2]: Warning: File 'CMakeFiles/AwsCCommon.dir/progress.make' has modification time 267 s in the future
gmake[2]: warning: Clock skew detected. Your build may be incomplete.
gmake[2]: Warning: File 'CMakeFiles/AwsCCommon.dir/progress.make' has modification time 267 s in the future
[ 4%] Performing build step for 'AwsCCommon'
[ 1%] Building C object CMakeFiles/aws-c-common.dir/source/array_list.c.o
In file included from /usr/include/stdio.h:37:0,
from /workspace/dmoini/sdk_build/.deps/build/src/AwsCCommon/include/aws/common/common.h:22,
from /workspace/dmoini/sdk_build/.deps/build/src/AwsCCommon/include/aws/common/array_list.h:18,
from /workspace/dmoini/sdk_build/.deps/build/src/AwsCCommon/source/array_list.c:16:
/opt/gcc-5.1.0/lib/gcc/i386-pc-solaris2.11/5.1.0/include-fixed/sys/feature_tests.h:405:2: error: #error "Compiler or options invalid for pre-UNIX 03 X/Open applications and pre-2001 POSIX applications"
#error "Compiler or options invalid for pre-UNIX 03 X/Open applications \
^
gmake[5]: *** [CMakeFiles/aws-c-common.dir/build.make:63: CMakeFiles/aws-c-common.dir/source/array_list.c.o] Error 1
gmake[4]: *** [CMakeFiles/Makefile2:484: CMakeFiles/aws-c-common.dir/all] Error 2
gmake[3]: *** [Makefile:139: all] Error 2
gmake[2]: *** [CMakeFiles/AwsCCommon.dir/build.make:112: build/src/AwsCCommon-stamp/AwsCCommon-build] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:68: CMakeFiles/AwsCCommon.dir/all] Error 2
gmake: *** [Makefile:84: all] Error 2
CMake Error at CMakeLists.txt:193 (message):
Failed to build third-party libraries.
此外,这是我的系统信息:
$ uname -a
SunOS bld-dmoini-01-sv4b 5.11 omnios-r151020-4151d05 i86pc i386 i86pc
非常感谢help/guidance。
我已经在原装 Solaris 11.4 上成功完成了 AWS C++ SDK 的编译,并发现了几个可能导致上述问题的问题。
从干净的源代码树开始。
删除-Werror
要做的第一件事是删除 -Werror
编译器选项。 Solaris 11.4 上默认安装的 OpenSSL 版本有很多已弃用的功能,-Werror
选项在 运行 进入这些弃用时会导致构建失败。我从 AWS SDK 源代码树的最顶层目录中使用此 find
命令 运行 删除所有 -Werror
选项:
vi `find . | xargs grep -l Werror`
您将获得大约三四个文件,其中只有两个实际上将 -Werror
设置为编译器选项。只需从这些文件中删除 "-Werror"
字符串。
修复POSIX定义
然后运行 cmake .
在最顶层目录。它会失败,因为它下载的 cmake 文件会有不正确的 POSIX command-line 选项 - -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=500
。 500
是错误的。 _POSIX_C_SOURCE=200809L
对应_XOPEN_SOURCE=700
。 _XOPEN_SOURCE=500
是 SUSv2, circa 1997。用C99编译SUSv2应用程序是不合适的。
根据 2.2.1 Strictly Conforming POSIX Application, paragraph 8:
- For the C programming language, shall define
_POSIX_C_SOURCE
to be 200809L
before any header is included
和2.2.4 Strictly Conforming XSI Application, paragraph 8:
- For the C programming language, shall define
_XOPEN_SOURCE
to be 700
before any header is included
Per the Illumos sys/feature_tests.h
file(基于 OpenSolaris,它也是 Solaris 11 的基础):
* Feature Test Macro Specification
* ------------------------------------------------ -------------
* _XOPEN_SOURCE XPG3
* _XOPEN_SOURCE && _XOPEN_VERSION = 4 XPG4
* _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED = 1 XPG4v2
* _XOPEN_SOURCE = 500 XPG5
* _XOPEN_SOURCE = 600 (or POSIX_C_SOURCE=200112L) XPG6
* _XOPEN_SOURCE = 700 (or POSIX_C_SOURCE=200809L) XPG7
通过git
下载的文件cmake
需要编辑:
vi `find .deps | xargs grep -l XOPEN_SOURCE`
将任何 -D_XOPEN_SOURCE=500
更改为 -D_XOPEN_SOURCE=700
并重新 运行 cmake .
。这次应该会成功完成。
然后运行gmake
。 (我发现 gmake
对于几乎所有开源项目在 Solaris 上工作得更好,因为许多开源项目使用 GNU-specific make
扩展。)
现在您可以修复任何损坏的源代码 运行。
修复损坏的源代码
1
file aws-sdk-cpp/aws-cpp-sdk-core/source/platform/linux-shared/OSVersionInfo.cpp
有如下错误代码:
Aws::String ComputeOSVersionString()
{
utsname name;
int32_t success = uname(&name);
Per POSIX,正确的类型是struct utsname
,而不仅仅是utsname
:
int uname(struct utsname *name);
AWS 代码需要是:
Aws::String ComputeOSVersionString()
{
struct utsname name;
int success = uname(&name);
不,考虑到 this, umm, laugher:
,AWS 代码的质量肯定不会给我留下深刻印象
while (!feof(outputStream))
是的,一个实际的 while (!feof())
循环...
2
文件aws-sdk-cpp/aws-cpp-sdk-mediaconvert/include/aws/mediaconvert/model/M2tsSegmentationMarkers.h uses an enumeration with the value EBP
, which conflicts with the EBP
register #define
in /usr/include/sys/regset.h
.
我只是将其更改为 EBP_HASH
,因为它似乎与代码有些匹配:
vi `find . | xargs grep -l EBP`
3
文件aws-sdk-cpp/aws-cpp-sdk-route53domains/include/aws/route53domains/model/CountryCode.h creates an enumeration value ES
that conflicts with the ES
register #define
in /usr/include/sys/regset.h
。我刚刚添加了
#ifdef ES
#undef ES
#endif
编译继续。我不知道 #undef
是否会破坏任何东西。
4
文件aws-sdk-cpp/aws-cpp-sdk-waf/include/aws/waf/model/GeoMatchConstraintValue.h has ES
, GS
, and SS
enumeration value that conflict with the ES
, GS
, and SS
register #define
's in /usr/include/sys/regset.h
.
同样,我刚刚添加了一些 #undef
的:
#ifdef ES
#undef ES
#endif
#ifdef GS
#undef GS
#endif
#ifdef SS
#undef SS
#endif
我真的很想知道为什么 sys/regset.h
在 AWS SDK 的几乎所有内容中都被 #include
。
5
aws-sdk-cpp/aws-cpp-sdk-waf-regional/include/aws/waf-regional/model/GeoMatchConstraintValue.h 中存在同样的问题。同样的修复,添加:
#ifdef ES
#undef ES
#endif
#ifdef GS
#undef GS
#endif
#ifdef SS
#undef SS
#endif
请注意,在 SPARC 硬件上编译意味着 sys/regset.h
中的 #define
值将完全不同,并且任何错误都将完全不同。
6
文件aws-sdk-cpp/aws-cpp-sdk-core-tests/utils/FileSystemUtilsTest.cpp incorrectly assumes the POSIX NAME_MAX
value is defined. Per the POSIX Pathname Variable Values standard(加粗我的):
Pathname Variable Values
The values in the following list may be constants within an
implementation or may vary from one pathname to another. For example,
file systems or directories may have different characteristics.
A definition of one of the symbolic constants in the following list
shall be omitted from the <limits.h>
header on specific
implementations where the corresponding value is equal to or greater
than the stated minimum, but where the value can vary depending on the
file to which it is applied. The actual value supported for a specific
pathname shall be provided by the pathconf()
function.
再次:"definition ... shall be omitted ... where the value can vary".
AWS 代码错误地假设 NAME_MAX
必须 是 #define
。
我只是硬编码了一个 255
的值来克服这一点,尽管使用 _POSIX_NAME_MAX
或 _XOPEN_NAME_MAX
之类的值可能更好。
7
File aws-sdk-cpp/ws-cpp-sdk-core-tests/http/HttpClientTest.cpp seems to be incorrectly assuming a std::shared_ptr
will be 8 bytes. 提供了一个很好的例子来说明这是错误的。
我只是忽略了这个错误,因为它只是一个测试并继续 gmake -i
,它在这个错误之外成功完成。
我正在尝试在 Solaris 上构建 AWS C++ SDK,但我无法成功。
我在 AWS C++ SDK 页面上发现 this 未解决的问题,说这是可能的,但没有关于它的指南,我希望这里有人可以提供帮助。
这是我用来构建它的命令:
$ cmake ../aws-sdk-cpp/ -DCMAKE_BUILD_TYPE=Debug -DBUILD_ONLY="s3"
这是输出:
-- TARGET_ARCH not specified; inferring host OS to be platform compilation target
-- Building AWS libraries as shared objects
-- Generating linux build config
-- Building project version: 1.7.134
-- Configuring done
-- Generating done
-- Build files have been written to: /workspace/dmoini/sdk_build/.deps
gmake: Warning: File 'Makefile' has modification time 267 s in the future
gmake[1]: Warning: File 'CMakeFiles/Makefile2' has modification time 267 s in the future
gmake[2]: Warning: File 'CMakeFiles/AwsCCommon.dir/progress.make' has modification time 267 s in the future
gmake[2]: warning: Clock skew detected. Your build may be incomplete.
gmake[2]: Warning: File 'CMakeFiles/AwsCCommon.dir/progress.make' has modification time 267 s in the future
[ 4%] Performing build step for 'AwsCCommon'
[ 1%] Building C object CMakeFiles/aws-c-common.dir/source/array_list.c.o
In file included from /usr/include/stdio.h:37:0,
from /workspace/dmoini/sdk_build/.deps/build/src/AwsCCommon/include/aws/common/common.h:22,
from /workspace/dmoini/sdk_build/.deps/build/src/AwsCCommon/include/aws/common/array_list.h:18,
from /workspace/dmoini/sdk_build/.deps/build/src/AwsCCommon/source/array_list.c:16:
/opt/gcc-5.1.0/lib/gcc/i386-pc-solaris2.11/5.1.0/include-fixed/sys/feature_tests.h:405:2: error: #error "Compiler or options invalid for pre-UNIX 03 X/Open applications and pre-2001 POSIX applications"
#error "Compiler or options invalid for pre-UNIX 03 X/Open applications \
^
gmake[5]: *** [CMakeFiles/aws-c-common.dir/build.make:63: CMakeFiles/aws-c-common.dir/source/array_list.c.o] Error 1
gmake[4]: *** [CMakeFiles/Makefile2:484: CMakeFiles/aws-c-common.dir/all] Error 2
gmake[3]: *** [Makefile:139: all] Error 2
gmake[2]: *** [CMakeFiles/AwsCCommon.dir/build.make:112: build/src/AwsCCommon-stamp/AwsCCommon-build] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:68: CMakeFiles/AwsCCommon.dir/all] Error 2
gmake: *** [Makefile:84: all] Error 2
CMake Error at CMakeLists.txt:193 (message):
Failed to build third-party libraries.
此外,这是我的系统信息:
$ uname -a
SunOS bld-dmoini-01-sv4b 5.11 omnios-r151020-4151d05 i86pc i386 i86pc
非常感谢help/guidance。
我已经在原装 Solaris 11.4 上成功完成了 AWS C++ SDK 的编译,并发现了几个可能导致上述问题的问题。
从干净的源代码树开始。
删除-Werror
要做的第一件事是删除 -Werror
编译器选项。 Solaris 11.4 上默认安装的 OpenSSL 版本有很多已弃用的功能,-Werror
选项在 运行 进入这些弃用时会导致构建失败。我从 AWS SDK 源代码树的最顶层目录中使用此 find
命令 运行 删除所有 -Werror
选项:
vi `find . | xargs grep -l Werror`
您将获得大约三四个文件,其中只有两个实际上将 -Werror
设置为编译器选项。只需从这些文件中删除 "-Werror"
字符串。
修复POSIX定义
然后运行 cmake .
在最顶层目录。它会失败,因为它下载的 cmake 文件会有不正确的 POSIX command-line 选项 - -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=500
。 500
是错误的。 _POSIX_C_SOURCE=200809L
对应_XOPEN_SOURCE=700
。 _XOPEN_SOURCE=500
是 SUSv2, circa 1997。用C99编译SUSv2应用程序是不合适的。
根据 2.2.1 Strictly Conforming POSIX Application, paragraph 8:
- For the C programming language, shall define
_POSIX_C_SOURCE
to be200809L
before any header is included
和2.2.4 Strictly Conforming XSI Application, paragraph 8:
- For the C programming language, shall define
_XOPEN_SOURCE
to be700
before any header is included
Per the Illumos sys/feature_tests.h
file(基于 OpenSolaris,它也是 Solaris 11 的基础):
* Feature Test Macro Specification
* ------------------------------------------------ -------------
* _XOPEN_SOURCE XPG3
* _XOPEN_SOURCE && _XOPEN_VERSION = 4 XPG4
* _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED = 1 XPG4v2
* _XOPEN_SOURCE = 500 XPG5
* _XOPEN_SOURCE = 600 (or POSIX_C_SOURCE=200112L) XPG6
* _XOPEN_SOURCE = 700 (or POSIX_C_SOURCE=200809L) XPG7
通过git
下载的文件cmake
需要编辑:
vi `find .deps | xargs grep -l XOPEN_SOURCE`
将任何 -D_XOPEN_SOURCE=500
更改为 -D_XOPEN_SOURCE=700
并重新 运行 cmake .
。这次应该会成功完成。
然后运行gmake
。 (我发现 gmake
对于几乎所有开源项目在 Solaris 上工作得更好,因为许多开源项目使用 GNU-specific make
扩展。)
现在您可以修复任何损坏的源代码 运行。
修复损坏的源代码
1
file aws-sdk-cpp/aws-cpp-sdk-core/source/platform/linux-shared/OSVersionInfo.cpp
有如下错误代码:
Aws::String ComputeOSVersionString()
{
utsname name;
int32_t success = uname(&name);
Per POSIX,正确的类型是struct utsname
,而不仅仅是utsname
:
int uname(struct utsname *name);
AWS 代码需要是:
Aws::String ComputeOSVersionString()
{
struct utsname name;
int success = uname(&name);
不,考虑到 this, umm, laugher:
,AWS 代码的质量肯定不会给我留下深刻印象 while (!feof(outputStream))
是的,一个实际的 while (!feof())
循环...
2
文件aws-sdk-cpp/aws-cpp-sdk-mediaconvert/include/aws/mediaconvert/model/M2tsSegmentationMarkers.h uses an enumeration with the value EBP
, which conflicts with the EBP
register #define
in /usr/include/sys/regset.h
.
我只是将其更改为 EBP_HASH
,因为它似乎与代码有些匹配:
vi `find . | xargs grep -l EBP`
3
文件aws-sdk-cpp/aws-cpp-sdk-route53domains/include/aws/route53domains/model/CountryCode.h creates an enumeration value ES
that conflicts with the ES
register #define
in /usr/include/sys/regset.h
。我刚刚添加了
#ifdef ES
#undef ES
#endif
编译继续。我不知道 #undef
是否会破坏任何东西。
4
文件aws-sdk-cpp/aws-cpp-sdk-waf/include/aws/waf/model/GeoMatchConstraintValue.h has ES
, GS
, and SS
enumeration value that conflict with the ES
, GS
, and SS
register #define
's in /usr/include/sys/regset.h
.
同样,我刚刚添加了一些 #undef
的:
#ifdef ES
#undef ES
#endif
#ifdef GS
#undef GS
#endif
#ifdef SS
#undef SS
#endif
我真的很想知道为什么 sys/regset.h
在 AWS SDK 的几乎所有内容中都被 #include
。
5
aws-sdk-cpp/aws-cpp-sdk-waf-regional/include/aws/waf-regional/model/GeoMatchConstraintValue.h 中存在同样的问题。同样的修复,添加:
#ifdef ES
#undef ES
#endif
#ifdef GS
#undef GS
#endif
#ifdef SS
#undef SS
#endif
请注意,在 SPARC 硬件上编译意味着 sys/regset.h
中的 #define
值将完全不同,并且任何错误都将完全不同。
6
文件aws-sdk-cpp/aws-cpp-sdk-core-tests/utils/FileSystemUtilsTest.cpp incorrectly assumes the POSIX NAME_MAX
value is defined. Per the POSIX Pathname Variable Values standard(加粗我的):
Pathname Variable Values
The values in the following list may be constants within an implementation or may vary from one pathname to another. For example, file systems or directories may have different characteristics.
A definition of one of the symbolic constants in the following list shall be omitted from the
<limits.h>
header on specific implementations where the corresponding value is equal to or greater than the stated minimum, but where the value can vary depending on the file to which it is applied. The actual value supported for a specific pathname shall be provided by thepathconf()
function.
再次:"definition ... shall be omitted ... where the value can vary".
AWS 代码错误地假设 NAME_MAX
必须 是 #define
。
我只是硬编码了一个 255
的值来克服这一点,尽管使用 _POSIX_NAME_MAX
或 _XOPEN_NAME_MAX
之类的值可能更好。
7
File aws-sdk-cpp/ws-cpp-sdk-core-tests/http/HttpClientTest.cpp seems to be incorrectly assuming a std::shared_ptr
will be 8 bytes.
我只是忽略了这个错误,因为它只是一个测试并继续 gmake -i
,它在这个错误之外成功完成。