作者laughingman (笑面男)
看板C_and_CPP
标题[问题] C++ DataFrame 编译问题
时间Tue Mar 26 22:59:55 2024
开发平台(Platform): (Ex: Win10, Linux, ...)
Linux
编译器(Ex: GCC, clang, VC++...)+目标环境(跟开发平台不同的话需列出)
g++ (GCC) 14.0.1 20240306
额外使用到的函数库(Library Used): (Ex: OpenGL, ...)
https://github.com/hosseinmoein/DataFrame 这个开源专案的函式库
问题(Question):
我是使用vcpkg来安装这个函式库的,我确定libDataFrame.a有被放到
/home/vcpkg/installed/x64-linux/lib,但在我用底下指令编译:
g++ main.cpp -o main -I /home/vcpkg/installed/x64-linux/include/ -L /home/vcpkg/installed/x64-linux/lib/ -lDataFrame --std=c++23
得到以下错误资讯:
/opt/rh/devtoolset-7/root/usr/bin/ld: /tmp/ccSFiQME.o: undefined reference to symbol 'pthread_create@@GLIBC_2.2.5'
//lib64/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
我以为是我的ld版本太旧的关系,所以在编译的时候加上-Wl,-fuse-ld=/opt/rh/devtoolset-11/root/bin/ld,
但编译的时候似乎还是使用/opt/rh/devtoolset-7/root/usr/bin/ld 这个linker,
所以我的问题有两个,这个错误讯息真的是因为我的ld版本的关系吗?还是有其他原因?
如果是版本的关系,我要如何使用新版的ld,
如果有知道的大神,请救救小弟,感谢感谢!
--
生死去来,棚头傀儡,一线断时,落落磊磊。
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 114.34.48.174 (台湾)
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/C_and_CPP/M.1711465240.A.F3F.html
1F:推 lc85301: 怎麽感觉是要加 -lpthread 03/26 23:05
2F:→ Lipraxde: undefined reference to symbol 'pthread,少 link pth 03/27 00:09
3F:→ Lipraxde: read 03/27 00:09
4F:→ Lipraxde: 可能那个 DataFrame 有用到,它看起来有提供 CMake pac 03/27 00:12
5F:→ Lipraxde: kage,建议使用 CMake 去生 make,比较不会漏东西 03/27 00:12
6F:推 melsonlai: 1. gcc 可以下 -v,它会把实际上执行了什麽指令印出来 03/27 20:31
7F:→ melsonlai: ,可以看 linker 有没有拿到 -lpthread 03/27 20:31
8F:→ melsonlai: 2. -fuse-ld 是 gcc driver 层的 option,不用透过 -W 03/27 20:31
9F:→ melsonlai: l 去使用。-Wl 是拿来传参数给 linker 的。 03/27 20:31
10F:→ melsonlai: 3. 有 @@ 的 symbol 是 versioned symbol,可以看一下 03/27 20:31
11F:→ melsonlai: linker 用的 glibc/pthread 是不是够新的版本 03/27 20:31
12F:推 Dracarys: 你如果要portable,最好别-lpthread而是-pthread让comp 03/28 02:22
13F:→ Dracarys: iler driver去判断,不过这种事最好还是交给CMake。然 03/28 02:22
14F:→ Dracarys: 後除了楼上说的之外,-Wl後面能接什麽还得看driver用的 03/28 02:22
15F:→ Dracarys: linker有没有支援,比如macOS上ld64/ld64.lld 就跟GNU 03/28 02:22
16F:→ Dracarys: ld/ld.lld很不同,这个都能透过CMake在configure time 03/28 02:22
17F:→ Dracarys: 确认 03/28 02:22
18F:→ laughingman: 感谢各位大神的建议,我先试看看用CMake的方式好了。 03/28 18:31