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

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

问题描述

当我编译我的库时,我已经打开了 -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已经完成。嗯,这意味着它是多余的,很好。

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无用的警告。 / p>

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

推荐答案

就个人而言,我只是在makefile中添加os检测。

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忽略目标(所有代码都是位置无关的),无用的警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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