Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

macos

g++

I'm trying to compile and strip a very simple programm in C++ with the g++ compiler (4.6.0 on Mac OSX). But while compiling i get an 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
like image 346
Tieme Avatar asked Sep 13 '11 21:09

Tieme


2 Answers

The error message is from ld, not from gcc or g++. (The gcc and g++ commands are a 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".

like image 196
Keith Thompson Avatar answered Nov 07 '22 22:11

Keith Thompson


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

like image 27
Seth Carnegie Avatar answered Nov 07 '22 22:11

Seth Carnegie