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

1

6

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?

Ovular answered 18/1, 2012 at 21:27 Comment(4)
There are several strategies in this discussion: https://mcmap.net/q/172720/-what-should-i-do-if-two-libraries-provide-a-function-with-the-same-name-generating-a-conflictScottscotti
If I might ask, what exactly is your code going to be doing. It seems weird that this kind of overlap wouldn't have been run into before.Weiweibel
The problem is showing at compile time rather than link time. Are you sure you need both curl.h and drivers.h in your program?Laquitalar
@Jon they are required as I need to load files from the web and mount a filesystem based on the external files.Ovular
G
1

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.

Gynecology answered 19/1, 2012 at 0:44 Comment(2)
Precisely where is Linux indicated in the question?Gonocyte
Good point. I had erroneously thought minix was linux (it isn't). However, objcopy is still available.Gynecology

© 2022 - 2024 — McMap. All rights reserved.