gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 02:49:00 25 4
gpt4 key购买 nike

我正在尝试编译 msp430 debug stack在 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

但是在没有静态链接的情况下运行时,它会正确地找到 boost 库并将所有内容链接起来。 MSPDebug 需要 libbost 版本 1.53,这是我拥有的版本。

这里有什么 secret ? 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

最佳答案

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

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

关于c - GNU ld 不能与 libboost 静态链接,但可以动态链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24105826/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com