1

I have 2 separate working projects on a raspberry running raspbian. i am having some problems when joining them together and as i am not that good with the compiler itself(still learning) i don't know how to work it out.

Error (finish_with_error can be ignored):

In file included from main.c:20:0:
/usr/local/include/wiringPi.h:216:21: error: conflicting types for ‘bcm2835_delayMicroseconds’
bcm2835.h:912:17: note: previous declaration of ‘bcm2835_delayMicroseconds’ was here
main.c:200:6: warning: conflicting types for ‘finish_with_error’ [enabled by default]
main.c:124:33: note: previous implicit declaration of ‘finish_with_error’ was here

The command i am using to compile is:

 gcc config.c rfid.c rc522.c main.c -o rc522_reader -lbcm2835 -lwiringPi -lwiringPiDev `mysql_config --cflags --libs`

Bcm2835.h(line 912):

extern void bcm2835_delayMicroseconds (uint64_t micros);

wiringPi.h(line 216):

extern void         delayMicroseconds (unsigned int howLong) ;

The problem is that i cant see where i there is two declarations the same way, these are libraries so i would prefer not to modify to avoid malfunctioning on the libs, is there something i can do to tell the compiler what to do?

Thanks,

pato.llaguno
  • 741
  • 4
  • 20
  • It looks as if someone forgot to say `extern "C" ...`, so the compiler is using C++ style name-mangling. Are you willing to recompile the libraries? – Beta Jul 21 '15 at 02:58
  • the bcm2835.h does have this, `#ifdef __cplusplus extern "C" { #endif` and the other one also – pato.llaguno Jul 21 '15 at 03:00
  • im not really sure or familiar what that extern C stands for, would it be a good thing to post both complete header files? they are a bit extensive. – pato.llaguno Jul 21 '15 at 03:09
  • Can you reduce this to a [minimal complete example](http://stackoverflow.com/help/mcve)? That is, remove as much code as you can while still producing the error, then post all that remains, so that we can reproduce the error ourselves? – Beta Jul 21 '15 at 04:29
  • @Beta i can try, but how can i do this to the libraries? should i modify them also? – pato.llaguno Jul 21 '15 at 04:34
  • so, i am not sure if i can get you a minimal complete example since you need a bcm chip to make the library work, but i did find this. not sure what this means. `// Historical name compatibility #ifndef BCM2835_NO_DELAY_COMPATIBILITY #define delay(x) bcm2835_delay(x) #define delayMicroseconds(x) bcm2835_delayMicroseconds(x) #endif` – pato.llaguno Jul 21 '15 at 05:00
  • Yes, make a reduced version of the libraries. Remove several files from a library and see if the linking error persists; if it does not, put those files back in. When you have removed as many files as possible, attack the remaining files, removing as much code as possible. What remains might not require the bcm chip. – Beta Jul 21 '15 at 05:13

0 Answers0