Ubuntu

Ubuntu sys/byteorder.h & sys/endian.h 缺失,同時建構 MySQL 連接器/C++

  • January 1, 2020

請記住,在從原始碼建構方面我是初學者(嘗試了幾次,幾乎總是失敗)。

我正在嘗試為執行 Ubuntu 19 的 Raspberry Pi 3b 建構 MySQL 連接器/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,沒有目錄sysendian.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.hand中/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

似乎 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/ .

引用自:https://unix.stackexchange.com/questions/559575