Gabriel Proulx
Gabriel Proulx

Reputation: 59

g++ include directory in the headerfile

The path to my .cpp and .h files: /home/quasiturbine/ServerProject/Network/NetworkIncludes/

There you can find TCP_Connexion.h and TCP_Connexion.cpp

In the .cpp file, I got #include "NetworkIncludes\TCP_Connexion.h" and default constructor/destructor. That's it.

G++ command:

g++ -o program -I/home/quasiturbine/ServerProject/Network/ /home/quasiturbine/ServerProject/Network/NetworkIncludes/TCP_Connexion.cpp

fatal error: /home/quasiturbine/ServerProject/Network/NetworkIncludes/TCP_Connexion.cpp:1:43: fatal error: NetworkIncludes\TCP_Connexion.h: No such file or folder #include "NetworkIncludes\TCP_Connexion.h"

What is wrong and how can I fix it?

Upvotes: 0

Views: 125

Answers (1)

nyronium
nyronium

Reputation: 1278

The problem is, that you are using backslashes \ when you should be using forward slashes /. Backslashes in include paths are undefined behavior before C++11 and implementation defined afterwards (reference).

So change your include to

#include "NetworkIncludes/TCP_Connexion.h"

and you should be good to go.

Upvotes: 6

Related Questions