Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/148.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在cygwin中包含头文件_Cygwin_C++ - Fatal编程技术网

如何在cygwin中包含头文件

如何在cygwin中包含头文件,cygwin,c++,Cygwin,C++,我有一个基类a,(在C++中)并希望有另一个继承类a的类B class A{ public: int n; A(){n=0;} void Test(int m); }; class B:public A{ public: int func(); }; 我分别有A.cpp和B.cpp。但是,当我在cygwin中编译B.cpp时,会弹出一个错误,指出“未定义的引用”函数属于A。因此我想知道如何在cygwin中定义#include“A.h”?include Path 要添加包含路径,请使用-I标

我有一个基类a,(在C++中)并希望有另一个继承类a的类B

class A{
public:
int n;
A(){n=0;}
void Test(int m);
};


class B:public A{
public:
int func();
};

我分别有A.cpp和B.cpp。但是,当我在cygwin中编译B.cpp时,会弹出一个错误,指出“未定义的引用”函数属于A。因此我想知道如何在cygwin中定义#include“A.h”?

include Path

要添加包含路径,请使用
-I
标志

g++ -I/include/path/here -I/another/include/path -o program source.cpp
g++ -L/lib/path/here -L/another/lib/path -o program source.cpp
要在编译期间查看包含文件搜索,请使用
-v
(详细)标志


库路径

要添加库路径,请使用
-L
标志

g++ -I/include/path/here -I/another/include/path -o program source.cpp
g++ -L/lib/path/here -L/another/lib/path -o program source.cpp

“我试过:
g++-L/cygdrive/c/cygwin/home/Win7 A.h B.cpp

尝试:

g++-o程序A.cpp B.cpp


我想知道我如何定义#在cygwin中包含“A.h?”


<>这与CygWin无关。它是C++的基本知识。请阅读。< /P>你试过了吗?你没有提到有头文件。我试过:G++-L/CyGrave/C/CygWy/HON/WI7A.B.CPPATH,它说,对函数B的未定义引用来自A。包含头文件的命令不包括其他.CPP文件。根据你在《代码> STACKOPPORION < /CODE >中的声誉猜测,你问我们这个问题的原因是因为你不能在那里问。你需要对类如何工作做更多的研究。CygWin与类或C++无关。而且,在论坛中的名声不表示编程技巧,因此不猜测,肯定是关于你所说的。