-fPIC忽略目标(所有code是与位置无关),无用的警告 [英] -fPIC ignored for target (all code is position independent), useless warning

查看:1737
本文介绍了-fPIC忽略目标(所有code是与位置无关),无用的警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我编译我的图书馆我已经切换ONT -fPIC ,因为我希望能够编译为一个共享库也作为静态的。

When I compile my library I have switched ont -fPIC because I want to be able to compile it as a shared library but also as static.

在Cygwin上使用gcc 3.4.4,我得到的所有的源文件这样的警告:

Using gcc 3.4.4 on cygwin I get this warning on all source files:

-fPIC ignored for target (all code is position independent)

和我真的不知道什么是它的点。它告诉我,我用其中有因为什么开关应该avieche已经完成了没有效果的开关。嗯,这意味着它是多余的,挺好的。但是,什么是它的点,我怎么能燮preSS呢?

And I really wonder what's the point of it. It tells me that I use a switch which has no effect because what the switch should avieche is already accomplished. Well, it means it's redundant, fine. But what's the point of it and how can I suppress it?

我不是在谈论为什么使用PIC与否,只是它为什么产生IMO无用的警告。

I'm not talking about why using PIC or not, just why it generates that IMO useless warning.

推荐答案

就个人而言,我只是添加OS检测到makefile文件。沿着

Personally, I'd just add os detection to the makefile. Something along the lines of

TARGET_TRIPLE := $(subst -, ,$(shell $(CC) -dumpmachine))
TARGET_ARCH   := $(word 1,$(TARGET_TRIPLE))
TARGET_OS     := $(word 3,$(TARGET_TRIPLE))

ifeq      ($(TARGET_OS),mingw32)
else ifeq ($(TARGET_OS),cygwin)
else
CFLAGS += -fPIC
endif

这篇关于-fPIC忽略目标(所有code是与位置无关),无用的警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆