G++编译器:选项 -s 已过时并被忽略 C++
我正在尝试使用 g++ 编译器(Mac OSX 上的 4.6.0)编译和剥离 C++ 中的一个非常简单的程序。但在编译时我收到警告。
源代码:
#include </usr/local/Cellar/gcc/4.6.0/gcc/include/c++/4.6.0/iostream>
int main(){
std::cout << ("Hello World\n") ;
}
终端代码:
g++ hello.cc -Wall -std=c++0x -s
/* or an alternative: */
g++ hello.cc -Wall -std=c++0x -o test -Wl,-s
编译器警告:
ld: warning: option -s is obsolete and being ignored
有人对这个奇怪的警告有任何想法吗?
编辑:
奇怪的是,使用 -s 标志时,大小确实减少了,从 9,216 字节减少到 9,008 字节。
但是,当我使用以下内容时,大小会减少到 8,896 字节。
cp hello hello_stripped
strip hello_stripped
I'm trying to compile and strip a very simple program in C++ with the g++ compiler (4.6.0 on Mac OSX). But while compiling i get a warning.
source code:
#include </usr/local/Cellar/gcc/4.6.0/gcc/include/c++/4.6.0/iostream>
int main(){
std::cout << ("Hello World\n") ;
}
Terminal code:
g++ hello.cc -Wall -std=c++0x -s
/* or an alternative: */
g++ hello.cc -Wall -std=c++0x -o test -Wl,-s
Compiler warning:
ld: warning: option -s is obsolete and being ignored
Somebody any idea's about this weird warning?
Edit:
The weird thing is the size does decrease when using the -s flag, the decreases from 9,216 bytes to 9,008.
However when i use the following the size decreases to 8,896 bytes.
cp hello hello_stripped
strip hello_stripped
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
错误消息来自
ld
,而不是来自gcc
或g++
。 (gcc
和g++
命令是调用编译器、链接器和其他工具的驱动程序。)gcc
传递-s链接器的
选项,如 gcc 4.6.1 手册;显然,gcc
的 MacOS 端口仍然这样做。GNU 链接器 (GNU
ld
) 仍然接受具有通常含义的-s
选项。但 MacOS 链接器(也称为 ld )会忽略它,如 MacOS ld 手册:和 MacOS gcc 手册,与 GNU 的 gcc 手册不同,没有提到“-s”。
The error message is from
ld
, not fromgcc
org++
. (Thegcc
andg++
commands are drivers that invokes the compiler, the linker, and other tools.)gcc
passes the-s
option to the linker, as documented in the gcc 4.6.1 manual; apparently the MacOS port ofgcc
still does that.The GNU linker (GNU
ld
) still accepts the-s
option with its usual meaning. But the MacOS linker (also calledld
) ignores it, as documented in the MacOS ld manual:And the MacOS gcc manual, unlike GNU's gcc manual, doesn't mention "-s".
显然
-s
标志已过时。您可以使用条
程序代替。Apparently the
-s
flag is obsolete. You can use thestrip
program instead though.