开发者

G++ compiler: option -s is obsolete and being ignored C++

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 << ("H开发者_Go百科ello 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


The error message is from ld, not from gcc or g++. (The gcc and g++ 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 of gcc still does that.

The GNU linker (GNU ld) still accepts the -s option with its usual meaning. But the MacOS linker (also called ld) ignores it, as documented in the MacOS ld manual:

-s Completely strip the output, including removing the symbol table. This file format variant is no longer supported. This option is obsolete.

And the MacOS gcc manual, unlike GNU's gcc manual, doesn't mention "-s".


Apparently the -s flag is obsolete. You can use the strip program instead though.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜