[英]Can I change the boost lib files' names?
I installed boost with cmd sudo apt-get install libboost-dev
. 我用cmd
sudo apt-get install libboost-dev
。 I find my boost lib files under /usr/lib
are these: 我在
/usr/lib
下发现我的boost lib文件是:
$ ls /usr/lib | grep boost
libboost_filesystem.so.1.46.1
libboost_iostreams.so.1.46.1
libboost_python-py27.so.1.46.1
libboost_python-py32.so.1.46.1
libboost_regex.a
libboost_regex-mt.a
libboost_regex-mt.so
libboost_regex.so
libboost_regex.so.1.46.1
libboost_serialization.so.1.46.1
libboost_system.so.1.46.1
libboost_thread.so.1.46.1
libboost_wserialization.so.1.46.1
Now I want to link my program with boost. 现在,我想将程序与boost链接起来。
G++: g++ test.cc -lboost_regex -lboost-iostreams -g -o prog
G ++:
g++ test.cc -lboost_regex -lboost-iostreams -g -o prog
Result: /usr/bin/ld: cannot find -lboost_iostreams
结果:
/usr/bin/ld: cannot find -lboost_iostreams
Does the lib file name libboost_iostreams.so.1.46.1
cause this problem? lib文件名
libboost_iostreams.so.1.46.1
是否会导致此问题? If so, can I rename it to libboost_iostreams.so
? 如果是这样,我可以将其重命名为
libboost_iostreams.so
吗?
And why I have libboost_regex.so
and libboost_regex.so.1.46.1
? 以及为什么我有
libboost_regex.so
和libboost_regex.so.1.46.1
? Are they the same or not? 他们是一样的吗?
I would advise against renaming the library. 我建议不要重命名该库。 Creating a soft link is preferable.
创建软链接是可取的。 I am not sure how
apt-get
deals with files that are deleted or renamed by a user instead of by apt-get
itself. 我不确定
apt-get
如何处理由用户而不是apt-get
本身删除或重命名的文件。
libboost_regex.so
is most likely a soft link to libboost_regex.so.1.46.1
libboost_regex.so
最有可能是libboost_regex.so.1.46.1
的软链接
It makes more sense to create symbolic links named what you want pointing to the actual files. 创建符号链接以命名指向实际文件的名称更有意义。 For example, on the Mac OS X, if I run:
例如,在Mac OS X上,如果运行:
ls -l `which lynx` | more
then I see all of the links. 然后我看到所有链接。 Some of which look like:
其中一些看起来像:
c++ -> clang++
cc -> clang
jar -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/jar
The link creation command is ln
. 链接创建命令是
ln
。 To make a symbolic link use the -s
option like so: 要创建符号链接,请使用
-s
选项,如下所示:
ln -s /path_to_source_file /path_to_symbolic_link
Example for the boost iostream library path above: 上面的boost iostream库路径示例:
ln -s /usr/lib/libboost_iostreams.so.1.46.1 /usr/lib/libboost_iostreams.so
Be prepared to prepend sudo
in front of the ln
command. 准备在
ln
命令之前添加sudo
。 Every time I have modified the /usr/..
area, I have had to use sudo
on my MacBook Pro. 每次修改
/usr/..
区域时,都必须在MacBook Pro上使用sudo
。 I expect the same from Ubuntu. 我希望Ubuntu也能提供同样的服务。 To remove a symbolic link type:
要删除符号链接类型:
rm /path_to_symbolic_link
Keep in mind that sudo
may be necessary again. 请记住,可能再次需要
sudo
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.