Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resolving conflicting type for functions with the same name in two external libraries

Tags:

c

minix

I have included the following libraries into my code.

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

Now I get the following error:

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

As far as I know this means that _send has been declared in two libraries (minix/drivers.h and curl/curl.h), I was wondering if it is possible to resolve this problem or work around it in some way?

like image 226
Joost Avatar asked Jan 18 '12 21:01

Joost


1 Answers

Since you're on minix, you can modify one (or both) of the libraries with objcopy. From the man page:

--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.

or, if you don't need _send from one of the libraries:

-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.

Of course, you will need to update your headers accordingly. I would also recommend naming the modified library and headers something else so it's clear that you've modified them.

like image 133
Timothy Jones Avatar answered Sep 30 '22 19:09

Timothy Jones