Reputation: 1448
I'm trying to compile a basic c++ program with 3 files: main.cpp, file.h, and file.cpp.
When I put
c++ -pthread *.cpp
it give me an error saying;
fatal error: file.h: No such file or directory
compilation terminated.
main.cpp and file.cpp both have #include "file.h"
Upvotes: 3
Views: 5442
Reputation: 3890
g++ -I. *.cpp
This tell the compiler to find the header files on the current directory, and not only in the default directories (/usr/include and /include).
I suggest you for compiling this trivial example to use GNU Make. The standard rules will work for you.
make file.cpp main.cpp
Maybe, if you have the same issue (file.h not found) you can set CXXFLAGS=-I.
Upvotes: 1