GNU ld不能与libboost静态链接,但动态可以

时间:2014-06-08 11:49:15

标签: c boost linker

我正在尝试编译msp430 debug stack pon OpenSUSE。 已安装所有先决条件。当我使用静态链接选项运行它时,链接器会说:

_filesystem -lboost_date_time -lboost_system -lbsl430 -lusb-1.0 -lrt -Wl,-Bdynamic  -lpthread
/usr/lib/gcc/i586-suse-linux/4.8/../../../../i586-suse-linux/bin/ld: cannot find -lboost_thread
/usr/lib/gcc/i586-suse-linux/4.8/../../../../i586-suse-linux/bin/ld: cannot find -lboost_filesystem
/usr/lib/gcc/i586-suse-linux/4.8/../../../../i586-suse-linux/bin/ld: cannot find -lboost_date_time
/usr/lib/gcc/i586-suse-linux/4.8/../../../../i586-suse-linux/bin/ld: cannot find -lboost_system
/usr/lib/gcc/i586-suse-linux/4.8/../../../../i586-suse-linux/bin/ld: cannot find -lusb-1.0
/usr/lib/gcc/i586-suse-linux/4.8/../../../../i586-suse-linux/bin/ld: cannot find -lrt
collect2: error: ld returned 1 exit status

但是当没有静态链接运行时,它正确地找到了升级库并将所有内容链接起来。 MSPDebug需要libbost版本1.53,它是我的版本。

这里的秘密是什么? Libboost安装在/ usr / lib。

> ls -l /usr/lib/libboost* | grep 1.53
lrwxrwxrwx 1 root root      25 04-13 15:55 /usr/lib/libboost_atomic-mt.so -> libboost_atomic.so.1.53.0
lrwxrwxrwx 1 root root      25 04-13 15:55 /usr/lib/libboost_atomic.so -> libboost_atomic.so.1.53.0
-rwxr-xr-x 1 root root    5420 2013-09-28  /usr/lib/libboost_atomic.so.1.53.0
lrwxrwxrwx 1 root root      25 04-13 15:55 /usr/lib/libboost_chrono-mt.so -> libboost_chrono.so.1.53.0
lrwxrwxrwx 1 root root      25 04-13 15:55 /usr/lib/libboost_chrono.so -> libboost_chrono.so.1.53.0
-rwxr-xr-x 1 root root   30300 2013-09-28  /usr/lib/libboost_chrono.so.1.53.0
lrwxrwxrwx 1 root root      26 04-13 15:55 /usr/lib/libboost_context-mt.so -> libboost_context.so.1.53.0
lrwxrwxrwx 1 root root      26 04-13 15:55 /usr/lib/libboost_context.so -> libboost_context.so.1.53.0
-rwxr-xr-x 1 root root    5372 2013-09-28  /usr/lib/libboost_context.so.1.53.0
lrwxrwxrwx 1 root root      28 04-13 15:55 /usr/lib/libboost_date_time-mt.so -> libboost_date_time.so.1.53.0
lrwxrwxrwx 1 root root      28 04-13 15:55 /usr/lib/libboost_date_time.so -> libboost_date_time.so.1.53.0
-rwxr-xr-x 1 root root   59064 2013-09-28  /usr/lib/libboost_date_time.so.1.53.0
lrwxrwxrwx 1 root root      29 04-13 15:55 /usr/lib/libboost_filesystem-mt.so -> libboost_filesystem.so.1.53.0
lrwxrwxrwx 1 root root      29 04-13 15:55 /usr/lib/libboost_filesystem.so -> libboost_filesystem.so.1.53.0
-rwxr-xr-x 1 root root   92172 2013-09-28  /usr/lib/libboost_filesystem.so.1.53.0
lrwxrwxrwx 1 root root      24 04-13 15:55 /usr/lib/libboost_graph-mt.so -> libboost_graph.so.1.53.0
lrwxrwxrwx 1 root root      33 04-13 15:55 /usr/lib/libboost_graph_parallel-mt.so -> libboost_graph_parallel.so.1.53.0
lrwxrwxrwx 1 root root      33 04-13 15:55 /usr/lib/libboost_graph_parallel.so -> libboost_graph_parallel.so.1.53.0
-rwxr-xr-x 1 root root  265044 2013-09-28  /usr/lib/libboost_graph_parallel.so.1.53.0
lrwxrwxrwx 1 root root      24 04-13 15:55 /usr/lib/libboost_graph.so -> libboost_graph.so.1.53.0
-rwxr-xr-x 1 root root  322280 2013-09-28  /usr/lib/libboost_graph.so.1.53.0
lrwxrwxrwx 1 root root      28 04-13 15:55 /usr/lib/libboost_iostreams-mt.so -> libboost_iostreams.so.1.53.0
lrwxrwxrwx 1 root root      28 04-13 15:55 /usr/lib/libboost_iostreams.so -> libboost_iostreams.so.1.53.0
-rwxr-xr-x 1 root root   96200 2013-09-28  /usr/lib/libboost_iostreams.so.1.53.0
lrwxrwxrwx 1 root root      25 04-13 15:55 /usr/lib/libboost_locale-mt.so -> libboost_locale.so.1.53.0
lrwxrwxrwx 1 root root      25 04-13 15:55 /usr/lib/libboost_locale.so -> libboost_locale.so.1.53.0
-rwxr-xr-x 1 root root  860656 2013-09-28  /usr/lib/libboost_locale.so.1.53.0
lrwxrwxrwx 1 root root      28 04-13 15:55 /usr/lib/libboost_math_c99f-mt.so -> libboost_math_c99f.so.1.53.0
lrwxrwxrwx 1 root root      28 04-13 15:55 /usr/lib/libboost_math_c99f.so -> libboost_math_c99f.so.1.53.0
-rwxr-xr-x 1 root root   50920 2013-09-28  /usr/lib/libboost_math_c99f.so.1.53.0
lrwxrwxrwx 1 root root      28 04-13 15:55 /usr/lib/libboost_math_c99l-mt.so -> libboost_math_c99l.so.1.53.0
lrwxrwxrwx 1 root root      28 04-13 15:55 /usr/lib/libboost_math_c99l.so -> libboost_math_c99l.so.1.53.0
-rwxr-xr-x 1 root root   50920 2013-09-28  /usr/lib/libboost_math_c99l.so.1.53.0
lrwxrwxrwx 1 root root      27 04-13 15:55 /usr/lib/libboost_math_c99-mt.so -> libboost_math_c99.so.1.53.0
lrwxrwxrwx 1 root root      27 04-13 15:55 /usr/lib/libboost_math_c99.so -> libboost_math_c99.so.1.53.0
-rwxr-xr-x 1 root root   63400 2013-09-28  /usr/lib/libboost_math_c99.so.1.53.0
lrwxrwxrwx 1 root root      28 04-13 15:55 /usr/lib/libboost_math_tr1f-mt.so -> libboost_math_tr1f.so.1.53.0
lrwxrwxrwx 1 root root      28 04-13 15:55 /usr/lib/libboost_math_tr1f.so -> libboost_math_tr1f.so.1.53.0
-rwxr-xr-x 1 root root  260384 2013-09-28  /usr/lib/libboost_math_tr1f.so.1.53.0
lrwxrwxrwx 1 root root      28 04-13 15:55 /usr/lib/libboost_math_tr1l-mt.so -> libboost_math_tr1l.so.1.53.0
lrwxrwxrwx 1 root root      28 04-13 15:55 /usr/lib/libboost_math_tr1l.so -> libboost_math_tr1l.so.1.53.0
-rwxr-xr-x 1 root root  236248 2013-09-28  /usr/lib/libboost_math_tr1l.so.1.53.0
lrwxrwxrwx 1 root root      27 04-13 15:55 /usr/lib/libboost_math_tr1-mt.so -> libboost_math_tr1.so.1.53.0
lrwxrwxrwx 1 root root      27 04-13 15:55 /usr/lib/libboost_math_tr1.so -> libboost_math_tr1.so.1.53.0
-rwxr-xr-x 1 root root  239868 2013-09-28  /usr/lib/libboost_math_tr1.so.1.53.0
lrwxrwxrwx 1 root root      22 04-13 15:55 /usr/lib/libboost_mpi-mt.so -> libboost_mpi.so.1.53.0
lrwxrwxrwx 1 root root      29 04-13 15:55 /usr/lib/libboost_mpi_python-mt.so -> libboost_mpi_python.so.1.53.0
lrwxrwxrwx 1 root root      29 04-13 15:55 /usr/lib/libboost_mpi_python.so -> libboost_mpi_python.so.1.53.0
-rwxr-xr-x 1 root root   80064 2013-09-28  /usr/lib/libboost_mpi_python.so.1.53.0
lrwxrwxrwx 1 root root      22 04-13 15:55 /usr/lib/libboost_mpi.so -> libboost_mpi.so.1.53.0
-rwxr-xr-x 1 root root  170452 2013-09-28  /usr/lib/libboost_mpi.so.1.53.0
lrwxrwxrwx 1 root root      35 04-13 15:55 /usr/lib/libboost_prg_exec_monitor-mt.so -> libboost_prg_exec_monitor.so.1.53.0
lrwxrwxrwx 1 root root      35 04-13 15:55 /usr/lib/libboost_prg_exec_monitor.so -> libboost_prg_exec_monitor.so.1.53.0
-rwxr-xr-x 1 root root   59284 2013-09-28  /usr/lib/libboost_prg_exec_monitor.so.1.53.0
lrwxrwxrwx 1 root root      34 04-13 15:55 /usr/lib/libboost_program_options-mt.so -> libboost_program_options.so.1.53.0
lrwxrwxrwx 1 root root      34 04-13 15:55 /usr/lib/libboost_program_options.so -> libboost_program_options.so.1.53.0
-rwxr-xr-x 1 root root  428764 2013-09-28  /usr/lib/libboost_program_options.so.1.53.0
lrwxrwxrwx 1 root root      25 04-13 15:55 /usr/lib/libboost_python-mt.so -> libboost_python.so.1.53.0
lrwxrwxrwx 1 root root      25 04-13 15:55 /usr/lib/libboost_python.so -> libboost_python.so.1.53.0
-rwxr-xr-x 1 root root  299512 2013-09-28  /usr/lib/libboost_python.so.1.53.0
lrwxrwxrwx 1 root root      25 04-13 15:55 /usr/lib/libboost_random-mt.so -> libboost_random.so.1.53.0
lrwxrwxrwx 1 root root      25 04-13 15:55 /usr/lib/libboost_random.so -> libboost_random.so.1.53.0
-rwxr-xr-x 1 root root    9712 2013-09-28  /usr/lib/libboost_random.so.1.53.0
lrwxrwxrwx 1 root root      24 04-13 15:55 /usr/lib/libboost_regex-mt.so -> libboost_regex.so.1.53.0
lrwxrwxrwx 1 root root      24 04-13 15:55 /usr/lib/libboost_regex.so -> libboost_regex.so.1.53.0
-rwxr-xr-x 1 root root  988512 2013-09-28  /usr/lib/libboost_regex.so.1.53.0
lrwxrwxrwx 1 root root      32 04-13 15:55 /usr/lib/libboost_serialization-mt.so -> libboost_serialization.so.1.53.0
lrwxrwxrwx 1 root root      32 04-13 15:55 /usr/lib/libboost_serialization.so -> libboost_serialization.so.1.53.0
-rwxr-xr-x 1 root root  432572 2013-09-28  /usr/lib/libboost_serialization.so.1.53.0
lrwxrwxrwx 1 root root      26 04-13 15:55 /usr/lib/libboost_signals-mt.so -> libboost_signals.so.1.53.0
lrwxrwxrwx 1 root root      26 04-13 15:55 /usr/lib/libboost_signals.so -> libboost_signals.so.1.53.0
-rwxr-xr-x 1 root root   83744 2013-09-28  /usr/lib/libboost_signals.so.1.53.0
lrwxrwxrwx 1 root root      25 04-13 15:55 /usr/lib/libboost_system-mt.so -> libboost_system.so.1.53.0
lrwxrwxrwx 1 root root      25 04-13 15:55 /usr/lib/libboost_system.so -> libboost_system.so.1.53.0
-rwxr-xr-x 1 root root   13824 2013-09-28  /usr/lib/libboost_system.so.1.53.0
lrwxrwxrwx 1 root root      25 04-13 15:55 /usr/lib/libboost_thread-mt.so -> libboost_thread.so.1.53.0
lrwxrwxrwx 1 root root      25 04-13 15:55 /usr/lib/libboost_thread.so -> libboost_thread.so.1.53.0
-rwxr-xr-x 1 root root   83832 2013-09-28  /usr/lib/libboost_thread.so.1.53.0
lrwxrwxrwx 1 root root      24 04-13 15:55 /usr/lib/libboost_timer-mt.so -> libboost_timer.so.1.53.0
lrwxrwxrwx 1 root root      24 04-13 15:55 /usr/lib/libboost_timer.so -> libboost_timer.so.1.53.0
-rwxr-xr-x 1 root root   18008 2013-09-28  /usr/lib/libboost_timer.so.1.53.0
lrwxrwxrwx 1 root root      38 04-13 15:55 /usr/lib/libboost_unit_test_framework-mt.so -> libboost_unit_test_framework.so.1.53.0
lrwxrwxrwx 1 root root      38 04-13 15:55 /usr/lib/libboost_unit_test_framework.so -> libboost_unit_test_framework.so.1.53.0
-rwxr-xr-x 1 root root  629872 2013-09-28  /usr/lib/libboost_unit_test_framework.so.1.53.0
lrwxrwxrwx 1 root root      23 04-13 15:55 /usr/lib/libboost_wave-mt.so -> libboost_wave.so.1.53.0
lrwxrwxrwx 1 root root      23 04-13 15:55 /usr/lib/libboost_wave.so -> libboost_wave.so.1.53.0
-rwxr-xr-x 1 root root 1141884 2013-09-28  /usr/lib/libboost_wave.so.1.53.0
lrwxrwxrwx 1 root root      33 04-13 15:55 /usr/lib/libboost_wserialization-mt.so -> libboost_wserialization.so.1.53.0
lrwxrwxrwx 1 root root      33 04-13 15:55 /usr/lib/libboost_wserialization.so -> libboost_wserialization.so.1.53.0
-rwxr-xr-x 1 root root  309416 2013-09-28  /usr/lib/libboost_wserialization.so.1.53.0

1 个答案:

答案 0 :(得分:2)

Linux中的静态库具有“.a”扩展名。

您的boost lib目录只包含“.so”,它们是共享对象(动态链接)。