boost iostreams库存在,但我无法链接它 [英] boost iostreams library exist but i am unable link it

查看:1222
本文介绍了boost iostreams库存在,但我无法链接它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我使用boost-iostreams库,这里是我的问题,我试图链接我的程序与图书馆:

  ld -I / usr / include / boost / iostreams / -I / usr / include / boost / iostreams / device / -L / usr / lib / libboost_iostreams.so -lboost-iostreams fd.o -ox 

结果是:

  ld:找不到-lboost-iostreams 

当我尝试明确写入时:

  ld -I / usr / include / boost / iostreams / -I / usr / include / boost / iostreams / device / --library /usr/lib/libboost_iostreams.so -lboost-iostreams fd.o -ox 

它告诉我图书馆不存在:

  ld:找不到-l / usr / lib / libboost_iostreams.so 
ld:找不到-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。 lang:c ++

  • 编译器:g ++(Debian 4.7.2-5)4.7.2

  • 链接器:GNU ld(GNU Binutils for Debian) 2.22

  • boost库版本:1.49(来自debian repo)



p>

EDIT:



正确的选项应为 -lboost_iostreams ,不是 -lboost-iostreams



EDIT2:



编辑后我的命令是:

  ld fd.o  - I / usr / include / boost / iostreams / -I / usr / include / boost / iostreams / device / -ox $(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:找不到条目符号_start;默认为000000000804cc10 
fd.o:在函数`__static_initialization_and_destruction_0(int,int)'中:
fd.cpp :( .text + 0xd6):未定义的引用`__dso_handle'
ld:x :隐藏符号`__dso_handle'未定义
ld:最终链接失败:错误值
make:*** [x]错误1
ld
,而是调用 $ d $>

解决方案

code> gcc g ++ 。这可能在链接时添加正确的搜索路径。



如果明确链接,则不能包含-l标志。只需将 /usr/lib/libboost_iostreams.a /usr/lib/libboost_iostreams.so 添加到文件列表



-l <​​/ code>标志添加 lib 前缀和 .so .a 后缀。


I know that the re plenty of similar questions, but mine is litle bit different and non them helped me.

I am using boost-iostreams library and here is my problem, i tried to link my program with libraries:

ld -I/usr/include/boost/iostreams/ -I/usr/include/boost/iostreams/device/  -L/usr/lib/libboost_iostreams.so -lboost-iostreams fd.o -o x 

And the result was:

ld: cannot find -lboost-iostreams

When i tried to write it explicitly:

ld -I/usr/include/boost/iostreams/ -I/usr/include/boost/iostreams/device/  --library /usr/lib/libboost_iostreams.so -lboost-iostreams fd.o -o x

It told me that the library dont exist:

ld: cannot find -l/usr/lib/libboost_iostreams.so
ld: cannot find -lboost-iostreams

But it does:

$ 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

About me:

  • OS: Debian 7 Wheezy
  • prog. lang.: c++
  • compiler: g++ (Debian 4.7.2-5) 4.7.2
  • linker: GNU ld (GNU Binutils for Debian) 2.22
  • boost library ver.: 1.49 ( from debian repo )

Thanks!

EDIT:

The right option should be -lboost_iostreams, not -lboost-iostreams

EDIT2:

After edit my command was:

ld fd.o -I/usr/include/boost/iostreams/ -I/usr/include/boost/iostreams/device/ -o x $(LIB_PATH) -lboost_iostreams

Where libpath is ONE of following:

LIB_PATH=
LIB_PATH=-L/usr/lib/
LIB_PATH=/usr/lib/libboost_iostreams.so
LIB_PATH=/usr/lib/libboost_iostreams.a

but the result is still:

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

解决方案

Generally speaking you do not call ld directly but rather call gcc or g++ instead. This might add the correct search paths when linking.

If you link explicitly, you must not include the -l flag. Just add /usr/lib/libboost_iostreams.a or /usr/lib/libboost_iostreams.so to the list of files that you are linking.

The -l flag add the lib prefix and the .so or .a suffix.

这篇关于boost iostreams库存在,但我无法链接它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆