Using g ++ to compile, how do I point it to other .h files?

I am trying to compile a .cpp + .h file that includes newmat.h and tinyxml.h. I have libnewmat.a and libtinyxml.a in the same directory as the .cpp and .h files, m works

g++ -lnewmat -ltinyxml test.cpp test.h

but still getting newmat.h and tinyxml.h was not found at the start of compilation. I am obviously a complete C ++ newb, because it seems like this should be trivial.

+3
source share
3 answers

Try the following:

g++ -lnewmat -ltinyxml -I. test.cpp 

-I.to view the header files in the current folder and include the required .h in your .c files

+2
source

Use the flag -Ito indicate which directory to search for included files.

+5

-I, :

g++ -I/usr/include -lnewmat -ltinyxml test.cpp test.h

And if you want to add the path to the library search path, you use -L, for example:

g++ -L/usr/lib -lnewmat -ltinyxml test.cpp test.h
+2
source

Source: https://habr.com/ru/post/1757707/


All Articles