Scott
Scott

Reputation: 63

C++ includes not found but added in CMakeLists.txt

I am currently having trouble with compiling using make. Upon using the command it only builds to 50% before receiving an error shown below.

[ 50%] Building CXX object CMakeFiles/laminar.dir/laminar.o/home/uqslines/Documents/Laminar/laminar.cpp:25:34: fatal error: mechsys/adlbm/Domain.h: No such file or directory compilation terminated.

The directory and file is there, in my .cpp file its directed there via:

#include <mechsys/adlbm/Domain.h>

I have tried changing the format to see if that resolves the problem and I have tried compiling numerous files as I have multiple examples to test.

I'm fairly new to this, so if anyone has some idea of how I might be able to fix this issue your help would be much appreciated, I've checked the forums and have been unable to find an answer that works.

Upvotes: 2

Views: 1961

Answers (1)

Charlie OConor
Charlie OConor

Reputation: 867

Try using quotes instead.

    #include "mechsys/adlbm/Domain.h"

The difference is in the location where the preprocessor searches for the included file.

For #include "filename" the preprocessor searches in the same directory as the file containing the directive. This method is normally used to include programmer-defined header files.

For #include the preprocessor searches in an implementation dependent manner, normally in search directories pre-designated by the compiler/IDE. This method is normally used to include standard library header files.

clang 7.0.2 actually gives you more useful errors

 main.cpp:9:10: error: 'mechsys/adlbm/Domain.h' file not found with <angled> include; use "quotes" instead

Upvotes: 3

Related Questions