Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve include file names conflicts in GCC?

I have two header files named string.h in different libraries, they are conflicted with each other and even conflicted with standard C include file of the same name.

There is no need to use any string.h except standard one, but I need to include libraries headers paths in GCC search path. Currently I use something like -I /usr/local/include/lib1 -I /usr/local/include/lib2, but that way I can not include standard C string.h.

What is the right way to resolve such conflicts?

like image 843
actual Avatar asked Nov 24 '25 15:11

actual


2 Answers

You can probably use #include <lib1/string.h> and compile with gcc -I/usr/local/include.

like image 148
Schnouki Avatar answered Nov 26 '25 06:11

Schnouki


The problem is that directories added to the search path via -I get looked up before the standard ones which for gcc are (in order)

/usr/local/include/
/usr/include/
/usr/local/lib/
/usr/lib/

So you can follow Schnouki's advice, except that there is no need to add -I/usr/local/include

like image 23
Jasmeet Avatar answered Nov 26 '25 05:11

Jasmeet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!