Ubuntu sys/byteorder.h 和 sys/endian.h 在构建 MySQL Connector/C++ 时丢失

Ubuntu sys/byteorder.h 和 sys/endian.h 在构建 MySQL Connector/C++ 时丢失

请记住,在从源代码构建方面我是一个初学者(尝试了几次,几乎总是失败)。

我正在尝试为运行 Ubuntu 19 的 Raspberry Pi 3b 构建 MySQL Connector/C++ 8。我遵循官方说明并安装了所有先决条件(不能 100% 确定是否codecvt_utf8存在)。

我的构建没有使用 JDBC 和 BOOST。我已经从源代码构建了 OpenSSL 1.1.1。

我正在运行的命令(我--target install直接添加 - 不确定这是否是一个问题):

cmake .
cmake --build . --target install --config Release

AFAIK 失败了,因为:

CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:10:致命错误:sys/endian.h:没有这样的文件或目录

CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:10:致命错误:sys/byteorder.h:没有这样的文件或目录

我查了一下/usr/include,没有目录sys。它endian.h直接位于顶层,byteorder.h根本不存在。

为什么有些文件丢失了?


如上所述这里,该sys目录位于 Ubuntu 上的不同位置。所以我运行了这个:

ln -s /usr/include/aarch64-linux-gnu/sys /usr/include/sys

但丢失的文件实际上也不在该目录中。


跑步

find /usr/include -type f -name endian.h
find /usr/include -type f -name byteorder.h

显示,这些文件实际上位于 和 中/usr/include/aarch64-linux-gnu/bits/endian.h/usr/include/aarch64-linux-gnu/asm/byteorder.h我应该链接它们吗?似乎是个坏主意。


完整输出(使用缓存的进度):

[  2%] Built target uuid_gen
[  4%] Building protobuf
[ 27%] Built target protobuf-lite
[ 28%] Building CXX object CMakeFiles/protobuf.dir/protobuf-3.6.1/src/google/protobuf/descriptor.cc.o
c++: fatal error: Killed signal terminated program cc1plus
compilation terminated.
make[5]: *** [CMakeFiles/protobuf.dir/build.make:115: CMakeFiles/protobuf.dir/protobuf-3.6.1/src/google/protobuf/descriptor.cc.o] Error 1
make[4]: *** [CMakeFiles/Makefile2:73: CMakeFiles/protobuf.dir/all] Error 2
make[3]: *** [Makefile:84: all] Error 2
make[2]: *** [cdk/CMakeFiles/build_protobuf.dir/build.make:58: cdk/protobuf/build.stamp] Error 2
make[1]: *** [CMakeFiles/Makefile2:297: cdk/CMakeFiles/build_protobuf.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

完整错误日志:

Performing C++ SOURCE FILE Test HAVE_IS_SAME failed with the following output:
Change Dir: /home/ubuntu/mysql-connector-c++-8.0.18-src/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_dadf7/fast"
/usr/bin/make -f CMakeFiles/cmTC_dadf7.dir/build.make CMakeFiles/cmTC_dadf7.dir/build
make[1]: Entering directory '/home/ubuntu/mysql-connector-c++-8.0.18-src/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_dadf7.dir/src.cxx.o
/usr/bin/c++    -DHAVE_IS_SAME  -std=c++11   -o CMakeFiles/cmTC_dadf7.dir/src.cxx.o -c /home/ubuntu/mysql-connector-c++-8.0.18-src/CMakeFiles/CMakeTmp/src.cxx
/home/ubuntu/mysql-connector-c++-8.0.18-src/CMakeFiles/CMakeTmp/src.cxx:1:1: error: ‘::main’ must return ‘int’
    1 | void main() { return is_same<bool,char>::value; }
      | ^~~~
/home/ubuntu/mysql-connector-c++-8.0.18-src/CMakeFiles/CMakeTmp/src.cxx: In function ‘int main()’:
/home/ubuntu/mysql-connector-c++-8.0.18-src/CMakeFiles/CMakeTmp/src.cxx:1:22: error: ‘is_same’ was not declared in this scope
    1 | void main() { return is_same<bool,char>::value; }
      |                      ^~~~~~~
/home/ubuntu/mysql-connector-c++-8.0.18-src/CMakeFiles/CMakeTmp/src.cxx:1:30: error: expected primary-expression before ‘bool’
    1 | void main() { return is_same<bool,char>::value; }
      |                              ^~~~
/home/ubuntu/mysql-connector-c++-8.0.18-src/CMakeFiles/CMakeTmp/src.cxx:1:30: error: expected ‘;’ before ‘bool’
    1 | void main() { return is_same<bool,char>::value; }
      |                              ^~~~
      |                              ;
/home/ubuntu/mysql-connector-c++-8.0.18-src/CMakeFiles/CMakeTmp/src.cxx:1:34: error: expected unqualified-id before ‘,’ token
    1 | void main() { return is_same<bool,char>::value; }
      |                                  ^
/home/ubuntu/mysql-connector-c++-8.0.18-src/CMakeFiles/CMakeTmp/src.cxx:1:35: error: expected unqualified-id before ‘char’
    1 | void main() { return is_same<bool,char>::value; }
      |                                   ^~~~
make[1]: *** [CMakeFiles/cmTC_dadf7.dir/build.make:66: CMakeFiles/cmTC_dadf7.dir/src.cxx.o] Error 1
make[1]: Leaving directory '/home/ubuntu/mysql-connector-c++-8.0.18-src/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_dadf7/fast] Error 2

Source file was:
void main() { return is_same<bool,char>::value; }
Determining if the include file sys/endian.h exists failed with the following output:
Change Dir: /home/ubuntu/mysql-connector-c++-8.0.18-src/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_a570b/fast"
/usr/bin/make -f CMakeFiles/cmTC_a570b.dir/build.make CMakeFiles/cmTC_a570b.dir/build
make[1]: Entering directory '/home/ubuntu/mysql-connector-c++-8.0.18-src/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_a570b.dir/CheckIncludeFile.c.o
/usr/bin/cc    -o CMakeFiles/cmTC_a570b.dir/CheckIncludeFile.c.o   -c /home/ubuntu/mysql-connector-c++-8.0.18-src/CMakeFiles/CMakeTmp/CheckIncludeFile.c
/home/ubuntu/mysql-connector-c++-8.0.18-src/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:10: fatal error: sys/endian.h: No such file or directory
    1 | #include <sys/endian.h>
      |          ^~~~~~~~~~~~~~
compilation terminated.
make[1]: *** [CMakeFiles/cmTC_a570b.dir/build.make:66: CMakeFiles/cmTC_a570b.dir/CheckIncludeFile.c.o] Error 1
make[1]: Leaving directory '/home/ubuntu/mysql-connector-c++-8.0.18-src/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_a570b/fast] Error 2


Determining if the include file sys/byteorder.h exists failed with the following output:
Change Dir: /home/ubuntu/mysql-connector-c++-8.0.18-src/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_e560b/fast"
/usr/bin/make -f CMakeFiles/cmTC_e560b.dir/build.make CMakeFiles/cmTC_e560b.dir/build
make[1]: Entering directory '/home/ubuntu/mysql-connector-c++-8.0.18-src/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_e560b.dir/CheckIncludeFile.c.o
/usr/bin/cc    -o CMakeFiles/cmTC_e560b.dir/CheckIncludeFile.c.o   -c /home/ubuntu/mysql-connector-c++-8.0.18-src/CMakeFiles/CMakeTmp/CheckIncludeFile.c
/home/ubuntu/mysql-connector-c++-8.0.18-src/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:10: fatal error: sys/byteorder.h: No such file or directory
    1 | #include <sys/byteorder.h>
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
make[1]: *** [CMakeFiles/cmTC_e560b.dir/build.make:66: CMakeFiles/cmTC_e560b.dir/CheckIncludeFile.c.o] Error 1
make[1]: Leaving directory '/home/ubuntu/mysql-connector-c++-8.0.18-src/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_e560b/fast] Error 2

cmake 3.13.4
g++ 9.2.1
openssl 1.1.1d

答案1

C++ 编译器似乎内存不足。尝试在使用 make 构建时指定 1 个线程,例如:

$ cd path/to/connector/source
$ mkdir build && cd build
$ cmake .. -DCMAKE_BUILD_TYPE=Release
$ make -j1

(这被称为“无源”建造)

如果失败,并且 Pi 仍然没有足够的内存,请使用该raspi-config工具(以 root 身份运行)调整 Pi 的内存分配,尽可能少地分配给 GPU,并禁用图形登录,以尝试增加内存量释放内存用于编译。然后,重新启动以使更改生效,然后像从控制台一样进行构建。如果一切顺利,您可以raspi-config再次使用将之前修改的设置调整回原始值。如果失败,那么您可能需要考虑在另一台具有更多内存的 Linux 计算机上进行交叉编译。有关如何使用 为 Pi 构建交叉编译工具链crosstool-ng,然后使用它构建 CMake 项目的指南,可以在此处找到:https://blog.kitware.com/cross-compiling-for-raspberry-pi/

相关内容