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