简体   繁体   中英

Can I change the boost lib files' names?

I installed boost with cmd sudo apt-get install libboost-dev . I find my boost lib files under /usr/lib are these:

$ 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.

G++: g++ test.cc -lboost_regex -lboost-iostreams -g -o prog

Result: /usr/bin/ld: cannot find -lboost_iostreams

Does the lib file name libboost_iostreams.so.1.46.1 cause this problem? If so, can I rename it to libboost_iostreams.so ?

And why I have libboost_regex.so and 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.

libboost_regex.so is most likely a soft link to 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:

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 . To make a symbolic link use the -s option like so:

ln -s /path_to_source_file /path_to_symbolic_link


Example for the boost iostream library path above:

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. Every time I have modified the /usr/.. area, I have had to use sudo on my MacBook Pro. I expect the same from Ubuntu. To remove a symbolic link type:

rm /path_to_symbolic_link

Keep in mind that sudo may be necessary again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM