ubuntu 12.04(gcc降級)編譯android代碼遇到”_FORTIFY_SOURCE”的解決方案

來源:互聯網
上載者:User

一、編譯報錯

external/yaffs2/yaffs2/yaffs_tagsvalidity.h:23:6: warning: redundant redeclaration of ‘yaffs_InitialiseTags’ [-Wredundant-decls]

external/yaffs2/yaffs2/yaffs_guts.h:888:6: note: previous declaration of ‘yaffs_InitialiseTags’ was here

host C: mkyaffs2image <= external/yaffs2/yaffs2/yaffs_tagsvalidity.c

host C++: obbtool <= frameworks/base/tools/obbtool/Main.cpp

<command-line>:0:0: warning: "_FORTIFY_SOURCE" redefined [enabled by default]

<built-in>:0:0: note: this is the location of the previous definition

<command-line>:0:0: error: "_FORTIFY_SOURCE" redefined [-Werror]

<built-in>:0:0: note: this is the location of the previous definition

In file included from external/yaffs2/yaffs2/yaffs_tagsvalidity.c:17:0:

external/yaffs2/yaffs2/yaffs_tagsvalidity.h:23:6: warning: redundant redeclaration of ‘yaffs_InitialiseTags’ [-Wredundant-decls]

external/yaffs2/yaffs2/yaffs_guts.h:888:6: note: previous declaration of ‘yaffs_InitialiseTags’ was here

host C: parseStringTest <= external/srec/tools/parseStringTest/parseStringTest.c

cc1plus: all warnings being treated as errors

make: *** [out/host/linux-x86/obj/EXECUTABLES/obbtool_intermediates/Main.o] Error 1

make: *** Waiting for unfinished jobs....

host C++: post_trace <= sdk/emulator/qtools/post_trace.cpp

<command-line>:0:0: warning: "_FORTIFY_SOURCE" redefined [enabled by default]

<built-in>:0:0: note: this is the location of the previous definition

<command-line>:0:0: warning: "_FORTIFY_SOURCE" redefined [enabled by default]

<built-in>:0:0: note: this is the location of the previous definition

二、解決方案

問題原因:ubuntu 12.04中的gcc版本為4.6版本過高,需要降級為4.4

操作方法:

1. 查看gcc版本和g++版本

xumingtao@huaserver1:/usr/bin$ ls -l gcc*

lrwxrwxrwx 1 root root      7 Aug 30 19:26 gcc -> gcc-4.6

-rwxr-xr-x 1 root root 353216 Apr 16 07:37 gcc-4.6

xumingtao@huaserver1:/usr/bin$ ls -l g++*

lrwxrwxrwx 1 root root      7 Mar 14 04:05 g++ -> g++-4.6

-rwxr-xr-x 1 root root 357312 Apr 16 07:36 g++-4.6

2. 安裝gcc和g++ 4.4版本

sudo apt-get install gcc-4.4 g++-4.4 g++-4.4-multilib

3. 修改gcc連結

sudo mv gcc gcc.bak

sudo ln -s gcc-4.4 gcc

xumingtao@huaserver1:/usr/bin$ ls -l gcc*

lrwxrwxrwx 1 root root      7 Sep  6 10:43 gcc -> gcc-4.4

-rwxr-xr-x 1 root root 259232 Apr 16 14:20 gcc-4.4

-rwxr-xr-x 1 root root 353216 Apr 16 07:37 gcc-4.6

lrwxrwxrwx 1 root root      7 Aug 30 19:26 gcc.bak -> gcc-4.6

4. 修改g++連結

sudo mv g++ g++.bak

sudo ln -s g++-4.4 g++

xumingtao@huaserver1:/usr/bin$ ls -l g++*

lrwxrwxrwx 1 root root      7 Sep  6 10:45 g++ -> g++-4.4

-rwxr-xr-x 1 root root 263328 Apr 16 14:18 g++-4.4

-rwxr-xr-x 1 root root 357312 Apr 16 07:36 g++-4.6

lrwxrwxrwx 1 root root      7 Mar 14 04:05 g++.bak -> g++-4.6

5.查看gcc和g++版本號碼

gcc-v

g++-v

三、OK!

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.