7
我在嘗試靜態鏈接libDuma時遇到了以下錯誤,請問如何讓g ++使用libDuma中的malloc?如何解決gcc linux中的多重定義錯誤?
[email protected]:~/CodeTest$ g++ ./testDuma.cpp -g -o testDuma -static -lduma -pthread
/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/libc.a(malloc.o): In function `free':
(.text+0x4b00): multiple definition of `free'
/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/libduma.a(duma.o):(.text+0x25f0): first defined here
/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/libc.a(malloc.o): In function `malloc':
(.text+0x4bc0): multiple definition of `malloc'
/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/libduma.a(duma.o):(.text+0x2730): first defined here
/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/libc.a(malloc.o): In function `realloc':
(.text+0x5950): multiple definition of `realloc'
/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/libduma.a(duma.o):(.text+0x23d0): first defined here
collect2: ld returned 1 exit status
與它沒有編制,我需要靜態鏈接libDuma -nodegaultlibs,它是強制性的我,這裏是我得到的錯誤http://pastebin.com/ydrdqN0J – SunnyShah 2011-05-21 10:14:03
@SunnyShah:我不確定它能否正常工作,但可以試試'-z muldefs'鏈接器標誌。像:'g ++ testDuma.cpp -static -g -o testDuma -lduma -lpthread -Xlinker -z -Xlinker muldefs' – 2011-05-21 10:41:50
感謝您的回覆,有一點疑問,關於如何讓G ++使用杜馬的符號而不是libc的? – SunnyShah 2011-05-21 10:58:32