c++项目从aws服务器转移到mac编译
一,确认要迁移的目录和引用的包,查看Makefile文件,发现用到库目录/data/mrun/pcks,把当前的nm.s目录和/data/mrun/pcks打包,下载到mac上
二,下载到mac上之后,更改Makefile
三,遇到的报错
1,fatal error: 'ini.h' file not found
需要执行 brew install inih,成功后在/opt/homebrew/include目录下会有ini.h
2,fatal error: 'ixwebsocket/IXWebSocket.h' file not found
需要重新下载项目编译
#如果cmake找不到,就安装一下
brew install cmake
cd /Users/mini04/Desktop/data/zl/c++/pcks
git clone https://github.com/machinezone/IXWebSocket.git
cd IXWebSocket
mkdir build
cd build
cmake ..
make
安装成功
.h 文件找不到的,路径加在这里
3,fatal error: 'LightGBM/c_api.h' file not found
brew install lightgbm
安装成功之后在这里会有/opt/homebrew/include
4,fatal error: 'sodium.h' file not found
brew install libsodium
安装成功在这里/opt/homebrew/include
5,fatal error: 'cpprest/http_client.h' file not found
brew install cpprestsdk
6,
long out_len; // 原代码 改成
int64_t out_len; // 修改为 int64_t
g++ -std=c++17 -Wall -g -I./src -I/Users/mini04/Desktop/data/zl/c++/pcks/uWebSockets/src -I/Users/mini04/Desktop/data/zl/c++/pcks/uWebSockets/uSockets/src -I/Users/mini04/Desktop/data/zl/c++/pcks/spdlog/include -I/opt/homebrew/include/ -Isrc/wsclients -Isrc/exchangeinfo -Isrc/client -Isrc/stgs -I/Users/mini04/Desktop/data/zl/c++/pcks/IXWebSocket-master/ -c src/stgs/Stgs.cpp -o build/stgs/Stgs.o
src/stgs/Stgs.cpp:303:17: error: no matching function for call to 'LGBM_BoosterPredictForMat'303 | if (LGBM_BoosterPredictForMat(| ^~~~~~~~~~~~~~~~~~~~~~~~~
/opt/homebrew/include/LightGBM/c_api.h:1281:23: note: candidate function not viable: no known conversion from 'long *' to 'int64_t *' (aka 'long long *') for 11th argument1281 | LIGHTGBM_C_EXPORT int LGBM_BoosterPredictForMat(BoosterHandle handle,| ^1282 | const void* data,1283 | int data_type,1284 | int32_t nrow,1285 | int32_t ncol,1286 | int is_row_major,1287 | int predict_type,1288 | int start_iteration,1289 | int num_iteration,1290 | const char* parameter,1291 | int64_t* out_len,| ~~~~~~~~~~~~~~~~
src/stgs/Stgs.cpp:729:13: error: no matching function for call to 'LGBM_BoosterPredictForMat'729 | if (LGBM_BoosterPredictForMat(| ^~~~~~~~~~~~~~~~~~~~~~~~~
/opt/homebrew/include/LightGBM/c_api.h:1281:23: note: candidate function not viable: no known conversion from 'long *' to 'int64_t *' (aka 'long long *') for 11th argument1281 | LIGHTGBM_C_EXPORT int LGBM_BoosterPredictForMat(BoosterHandle handle,| ^1282 | const void* data,1283 | int data_type,1284 | int32_t nrow,1285 | int32_t ncol,1286 | int is_row_major,1287 | int predict_type,1288 | int start_iteration,1289 | int num_iteration,1290 | const char* parameter,1291 | int64_t* out_len,| ~~~~~~~~~~~~~~~~
src/stgs/Stgs.cpp:837:18: warning: unused variable 'ret' [-Wunused-variable]837 | bool ret = orders->cancel(p.get(), pred);| ^~~
src/stgs/Stgs.cpp:858:18: warning: unused variable 'ret' [-Wunused-variable]858 | bool ret = orders->cancel(p.get(), pred);| ^~~
In file included from src/stgs/Stgs.cpp:1:
src/stgs/Stgs.h:36:19: warning: private field 'p_exinfo' is not used [-Wunused-private-field]36 | ExchangeInfo* p_exinfo;| ^
3 warnings and 2 errors generated.
make: *** [build/stgs/Stgs.o] Error 1
7,library ':lib_lightgbm.so' not found
在 macOS 上,动态库的扩展名与 Linux 系统不同。在 macOS 上,动态库使用 .dylib
作为文件扩展名,而在 Linux 系统上,动态库通常使用 .so
(Shared Object)作为扩展名。这是操作系统之间的一个标准差异。
brew install lightgbm
安装成功:
8,
ld: archive member '/' not a mach-o file in '/Users/mini04/Desktop/data/zl/c++/pcks/uWebSockets/uSockets/libuSockets.a'
cd /Users/mini04/Desktop/data/zl/c++/pcks
git clone https://github.com/uNetworking/uWebSockets.git
cd uWebSockets如果报错:/bin/sh: lib.exe: command not found修改 Makefile文件,lib.exe /out:uSockets.a *.o || ar rvs uSockets.a *.o改成ar rcs uSockets.a *.o
需要下面的两个包
git clone https://github.com/uNetworking/uSockets.git
cd uSockets
make
cd ..
git clone https://github.com/ebiggers/libdeflate.git
cd libdeflate
make
cd ..
如果报错 clang: error: unsupported option '-fopenmp'如果不需要 OpenMP 支持,可以直接从 Makefile 中删除 -fopenmp 选项。找到使用 cc 编译的那一行,去掉 -fopenmp,然后再尝试执行 make
9,如果找不到某个文件,看下文件名称是否是 lib需要的文件名.后缀 ,如果不是,改成这样的格式