gpt4 book ai didi

c++ - 升级到 Ubuntu 14.04 是否破坏了 C++ 链接器?

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

我有一个基于 Linux 的应用程序,在 Ubuntu 12.04 LTS 下运行,编译、链接和运行都没有问题。

我最近将我的 Ubuntu 升级到 14.04 LTS,但在编译和链接应用程序时遇到了问题。

通过在两个文件(include/boost/config/stdlib/libstdcpp3.hpp 和 include/boost/thread/xtime.hpp).至此app编译成功。

我遇到的问题是链接失败并显示错误消息:

c++: error: unrecognized command line option ‘-Wl’

我使用 CMake 在多个平台上编译应用程序。这是 CMake 生成的链接描述文件。请注意,“-Wl”选项现在莫名其妙地无法被/usr/bin/c++ 识别:

/usr/bin/c++ 
-fno-stack-protector
-g
-Wl
CMakeFiles/Project.dir/main.cpp.o
CMakeFiles/Project.dir/TestCallback.cpp.o
CMakeFiles/Project.dir/utils.cpp.o
CMakeFiles/Project.dir/Request1.cpp.o
CMakeFiles/Project.dir/Response1.cpp.o
CMakeFiles/Project.dir/TextChatRequest.cpp.o
CMakeFiles/Project.dir/TextChatResponse.cpp.o
-o
/home/user/private/Project/Project_Release_1_2_Codename/Build/bin/Debug/Project
-L/home/user/Libraries/Ubuntu32_12.04/boost_1.48/lib
-L/home/user/Libraries/Ubuntu32_12.04/SqlLite_3.6/lib
-L/home/user/Libraries/Ubuntu32_12.04/taglib_1.7/lib
-L/home/user/Libraries/Ubuntu32_12.04/JSON_1.0/lib/Debug
-L/home/user/private/Project/Project_Release_1_2_Codename/Build/../lib/libUbuntu32/Debug
-rdynamic
/home/user/private/Project/Project_Release_1_2_Codename/lib/libUbuntu32/Debug/libAPI.a
/home/user/private/Project/Project_Release_1_2_Codename/lib/libUbuntu32/Debug/libInternals.a
-lboost_thread
-lboost_system
-lboost_filesystem
-lboost_program_options
-ltaglib
-lJSON
-lpthread
-Wl,-Bstatic
-lsqlite3
-Wl,-Bdynamic
-ldl
-Wl,-rpath,/home/user/Libraries/Ubuntu32_12.04/boost_1.48/lib:/home/user/Libraries/Ubuntu32_12.04/SqlLite_3.6/lib:/home/user/Libraries/Ubuntu32_12.04/taglib_1.7/lib:/home/user/Libraries/Ubuntu32_12.04/JSON_1.0/lib/Debug:/home/user/private/Project/Project_Release_1_2_Codename/Build/../lib/libUbuntu32/Debug

这是我正在使用的软件的版本信息:

Ubuntu:
14.04.1 LTS (trusty)

c++ compiler/linker:
(Ubuntu 4.8.2-19ubuntu1) 4.8.2

CMake:
Version 2.8.12.2

为什么链接器无法识别“-Wl”命令?我升级到 14.04 LTS 是否修改了链接器软件库?如何备份和链接我的应用程序?

最佳答案

在命令的第 4 行,您有 -Wl,但没有任何实际的链接器选项。

https://gcc.gnu.org/gcc-4.7/porting_to.html

本页顶部的内容如下:

Earlier releases did not warn or error about completely invalid options on gcc/g++/gfortran etc. command lines, if nothing was compiled, but only linking was performed. This is no longer the case. For example,

gcc -Wl -o foo foo.o -mflat_namespace

Now produces the following error

error: unrecognized command line option ‘-Wl’

error: unrecognized command line option ‘-mflat_namespace’

Invalid options need to be removed from the command line or replaced by something that is valid.

12.04 LTS 打包了 GCC 4.6,你现在已经跳到 4.8 并且 -Wl 本身不再是一个有效的选项(或者更确切地说,它从来不是,GCC 现在更加迂腐)。

关于c++ - 升级到 Ubuntu 14.04 是否破坏了 C++ 链接器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26292071/

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