本文介绍了G ++编译器:选项-s已过时,将被忽略C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用g ++编译器(在Mac OSX上为4.6.0)在C ++中编译和剥离一个非常简单的程序.但是在编译时会收到警告.

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.

源代码:

#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


有人对这个奇怪的警告有任何想法吗?


Somebody any idea's about this weird warning?

奇怪的是,使用-s标志时,大小确实减小减小了,从9216字节减小到9008字节.

The weird thing is the size does decrease when using the -s flag, the decreases from 9,216 bytes to 9,008.

但是,当我使用以下内容时,大小会减少到8,896字节.

However when i use the following the size decreases to 8,896 bytes.

cp hello hello_stripped
strip hello_stripped

推荐答案

错误消息来自 ld ,而不是 gcc g ++ .( gcc g ++ 命令是调用编译器,链接器和其他工具的驱动程序.)

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 -s 选项传递给链接器,如 gcc 4.6.1手册;显然, gcc 的MacOS端口仍然可以做到这一点.

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.

GNU链接器(GNU ld )仍然接受 -s 选项,其通常含义是.但是MacOS链接器(也称为 ld )会忽略它,如 MacOS ld手册:

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:

MacOS gcc手册与GNU的gcc手册不同,它没有提到"-s".

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

这篇关于G ++编译器:选项-s已过时,将被忽略C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 09:55
查看更多