2012-01-18 2 views
6

다음 코드를 코드에 포함 시켰습니다.두 개의 외부 라이브러리에서 같은 이름을 가진 함수의 충돌 유형을 해결합니다.

#include <minix/drivers.h> 
#include <curl/curl.h> 
#include <sys/stat.h> 
#include <time.h> 
#include <assert.h> 
#include <string.h> 

지금 나는 다음과 같은 오류가 발생합니다 :

In file included from /usr/local/include/curl/curlbuild.h:152 
       from /usr/local/include/curl/curl.h:34 
       from xxx.c:2 
/usr/pkg/gcc44/lib/gcc/i686-pc-minix/4.4.3/include-fixed/sys/socket.h:134: error: conflicting types for '_send' 
/usr/include/minix/ipc.h:152: note: previous declaration was here 

지금까지 내가이 _send 두 개의 라이브러리 (minix/drivers.hcurl/curl.h)이 가능한 경우, 궁금 해서요에 선언 된 것을 의미한다 알고 이 문제를 해결하거나 해결하려면 어떻게해야합니까?

+2

이 토론에서 몇 가지 전략이있다 : http://stackoverflow.com/questions/678254/c-function-conflict – TJD

+0

내가 요청할 수도 있습니다 경우, 정확히 어떤 코드가 일을 할 것이다. 이런 종류의 겹침이 이전에 실행되지 않았을 것이라는 것은 이상하게 보입니다. –

+0

문제는 링크 시간이 아닌 컴파일 타임에 표시됩니다. 프로그램에'curl.h'와'drivers.h' 둘 다 필요합니까? –

답변

1

미성년자이므로 objcopy으로 라이브러리 중 하나 또는 모두를 수정할 수 있습니다. 당신이 라이브러리 중 하나에서 _send 필요하지 않은 경우,

--redefine-sym old=new 
     Change the name of a symbol old, to new. This can be useful when 
     one is trying link two things together for which you have no source, 
     and there are name collisions. 

나 : 남자 페이지에서

-L symbolname 
--localize-symbol=symbolname 
     Make symbol symbolname local to the file, so that it is not visible 
     externally. This option may be given more than once. 

물론을, 당신은 그에 따라 헤더를 업데이트해야합니다. 또한 수정 된 라이브러리의 이름을 지정하고 머리글을 다른 이름으로 지정하여 수정 한 것이 확실합니다.

+0

질문에 Linux가 정확히 어디에 표시되어 있습니까? – mlp

+0

좋은 지적. 나는 실수로 미닉스가 리눅스라고 생각했다 ([그것은 아니다] (http://www.minix3.org/)). 그러나 [objcopy는 계속 사용할 수 있습니다] (http://wiki.minix3.org/en/DevelopersGuide/NewBuildSystem). –