boost iostreams库存在,但我无法链接它
boost iostreams library exist but i am unable link it
我知道有很多类似的问题,但我的问题有点不同,没有它们对我有帮助。
我正在使用boost iostreams库,这是我的问题,我试图将我的程序与库链接:
ld -I/usr/include/boost/iostreams/ -I/usr/include/boost/iostreams/device/ -L/usr/lib/libboost_iostreams.so -lboost-iostreams fd.o -o x
结果是:
ld: cannot find -lboost-iostreams
当我试图明确地写它时:
ld -I/usr/include/boost/iostreams/ -I/usr/include/boost/iostreams/device/ --library /usr/lib/libboost_iostreams.so -lboost-iostreams fd.o -o x
它告诉我图书馆不存在:
ld: cannot find -l/usr/lib/libboost_iostreams.so
ld: cannot find -lboost-iostreams
但确实如此:
$ ls -l /usr/lib/libboost_iostreams*
-rw-r--r-- 1 root root 204682 feb 4 05:28 /usr/lib/libboost_iostreams.a
lrwxrwxrwx 1 root root 20 feb 4 05:28 /usr/lib/libboost_iostreams-mt.a -> libboost_iostreams.a
lrwxrwxrwx 1 root root 28 feb 4 05:28 /usr/lib/libboost_iostreams-mt.so -> libboost_iostreams.so.1.49.0
lrwxrwxrwx 1 root root 28 feb 4 05:28 /usr/lib/libboost_iostreams.so -> libboost_iostreams.so.1.49.0
-rw-r--r-- 1 root root 94280 feb 4 05:28 /usr/lib/libboost_iostreams.so.1.49.0
关于我:
- 操作系统:Debian 7 Wheezy
- prog。语言:c++
- 编译器:g++(Debian 4.7.2-5)4.7.2
- 链接器:GNU ld(Debian的GNU Binutils)2.22
- boost库版本:1.49(来自debian repo)
谢谢!
编辑:
正确的选项应该是-lboost_iostreams
,而不是-lboost-iostreams
第2版:
编辑后,我的命令是:
ld fd.o -I/usr/include/boost/iostreams/ -I/usr/include/boost/iostreams/device/ -o x $(LIB_PATH) -lboost_iostreams
其中libpath是以下之一:
LIB_PATH=
LIB_PATH=-L/usr/lib/
LIB_PATH=/usr/lib/libboost_iostreams.so
LIB_PATH=/usr/lib/libboost_iostreams.a
但结果仍然是:
ld: warning: cannot find entry symbol _start; defaulting to 000000000804cc10
fd.o: In function `__static_initialization_and_destruction_0(int, int)':
fd.cpp:(.text+0xd6): undefined reference to `__dso_handle'
ld: x: hidden symbol `__dso_handle' isn't defined
ld: final link failed: Bad value
make: *** [x] Error 1
一般来说,您不会直接调用ld
,而是调用gcc
或g++
。这可能会在链接时添加正确的搜索路径。
如果显式链接,则不能包含-l标志。只需将/usr/lib/libboost_iostreams.a
或/usr/lib/libboost_iostreams.so
添加到要链接的文件列表中即可。
-l
标志添加lib
前缀和.so
或.a
后缀。
相关文章:
- lambda参数转换为constexpr技巧,然后获取带链接的数组
- CMake-按正确顺序将项目与C运行时对象文件链接
- 从链接列表c++中删除一个项目
- 有根的二进制搜索树.保留与其父级的链接
- 读取文件的最后一行并输入到链接列表时出错
- 静态数据成员的问题-修复链接错误会导致编译器错误
- node-gyp 在 macOS 上未正确链接库
- 基于boost的程序的静态链接——zlib问题
- 无法链接 CMake 中的本地库
- 内联函数中具有内部链接的全局变量
- 链接阶段在Ubuntu上失败,但在MacOS上失败
- 使用gcc从静态链接的文件中查找可选符号
- 我可以将一个用clang c++11编译的对象与另一个用c++17编译的对象链接起来吗
- 将--whole archive链接器选项与CMake和具有其他库依赖项的库一起使用
- 下面是我为检测链接列表中的循环而制作的代码
- 有了gcc,是否可以链接库,但前提是它存在
- 使用C链接在函数内部创建C++模板
- 使用 BOOST property_tree / iostreams / 文件系统 / foreach - 结果出现链接
- boost iostreams库存在,但我无法链接它
- Ubuntu 下的 C++ 链接 Boost 库与 cMake:未定义的引用 'boost::iostreams::zlib::ok'