编译 C++使用 cygwin 不会搜索提供的包含路径
我正在一棵树中工作,该树在我扔给它的任何 Unix 机器上都可以正常编译,但是 Cygwin 很困难,我不太确定从哪里开始。我有以下目录结构:
buildwin/
|-- main.cpp
|-- other project files
|-- include/
|-- tclap
|-- CmdLine.h
|-- other files (including CmdLine.cpp)
|-- eigen
|-- (appropriate files)
|-- rapidxml
|-- (appropriate files)
当我尝试编译它时,我从 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.
我知道它找到其他库(eigen
和 rapidxml
)很好,因为如果我删除相应的包含标志,它会抛出一个错误,指出它找不到eigen
或你有什么。
有问题的包含语句是:
// snip
#include <Eigen/StdVector>
#include <cmath>
#include <iostream>
#include <fstream>
#include <tclap/CmdLine.h>
// snip
想法?谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您指定 -Iinclude/tclap,然后包含
tclap/CmdLine.h
,因此编译器会寻找include/tclap/tclap/CmdLine.h< /代码>。
使用
-Iinclude
,或包含不带路径的CmdLine.h
。You're specifying
-Iinclude/tclap
, then includetclap/CmdLine.h
, so the compiler goes hunting forinclude/tclap/tclap/CmdLine.h
.Either use
-Iinclude
, or includeCmdLine.h
without the path.使用
-Iinclude
有效吗?您可能不需要显式添加include
的子目录,因为您在#include
语句的名称中引用了它们。Does using
-Iinclude
work? You probably don't need to be explicitly adding the subdirs ofinclude
because you refer to them in the names in the#include
statements.