Haldean Brown
Haldean Brown

Reputation: 12731

Compiling C++ with cygwin doesn't search provided include paths

I am working within a tree that compiles fine on any Unix machine I throw it at, but Cygwin is being difficult and I'm not really sure where to start. I have the following directory structure:

buildwin/
|-- main.cpp
|-- other project files
|-- include/
    |-- tclap
        |-- CmdLine.h
        |-- other files (including CmdLine.cpp)
    |-- eigen
        |-- (appropriate files)
    |-- rapidxml
        |-- (appropriate files)

When I try to compile this, I get the following error from g++:

$ g++ main.cpp -lglut32 -lglu32 -lopengl32 -Iinclude/eigen -Iinclude/rapidxml -Iinclude/tclap
main.cpp:6:27: fatal error: tclap/CmdLine.h: No such file or directory
compilation terminated.

I know it's finding the other libraries (eigen and rapidxml) fine because if I remove the respective include flags, it throws an error saying that it can't find eigen or what have you.

The include statement in question is:

// snip
#include <Eigen/StdVector>
#include <cmath>
#include <iostream>
#include <fstream>

#include <tclap/CmdLine.h>
// snip

Ideas? Thanks!

Upvotes: 0

Views: 1972

Answers (2)

Phil
Phil

Reputation: 2307

Does using -Iinclude work? You probably don't need to be explicitly adding the subdirs of include because you refer to them in the names in the #include statements.

Upvotes: 1

Thomas
Thomas

Reputation: 182093

You're specifying -Iinclude/tclap, then include tclap/CmdLine.h, so the compiler goes hunting for include/tclap/tclap/CmdLine.h.

Either use -Iinclude, or include CmdLine.h without the path.

Upvotes: 1

Related Questions