[英]include libraries that are used in header file of self-made static library
In a static library project I have "myClass.h" that is somehow like below: 在一个静态库项目中,我有“myClass.h”,它在某种程度上如下所示:
class myClass{
.
.
#include "tensorflow/....h" //some tensorflow header file
.
.
using tensorflow::Tensor;
.
.
void CopyTensorImage2Cv(tensorflow::Tensor &Tensor);
.
.
}
} }
and I have "myClass.cpp" that has definition of CopyTensorImage2Cv()
. 我有“myClass.cpp”,它有CopyTensorImage2Cv()
定义。
I want to make a static library, so I build the project and get "myClass.lib" successfully. 我想创建一个静态库,所以我构建项目并成功获得“myClass.lib”。
Now, I make a Console App with source code "test.cpp" to use this lib file. 现在,我创建一个源代码为“test.cpp”的控制台应用程序来使用此lib文件。 When I add lib file and copy "myClass.h" next to "test.cpp" and build the project, Visual Studio rises an error that can't understand #include "tensorflow/....h"
and "using tensorflow::Tensor"
当我添加lib文件并复制“test.cpp”旁边的“myClass.h”并构建项目时,Visual Studio会出现一个无法理解的错误#include "tensorflow/....h"
和"using tensorflow::Tensor"
What can I do in this case, which I want to use a static library that uses another library in its header file? 在这种情况下我该怎么做,我想使用在其头文件中使用另一个库的静态库?
I found the solution, I used Forward Declaration to avoid using #include in my header file. 我找到了解决方案,我使用Forward Declaration来避免在我的头文件中使用#include。 It works for me. 这个对我有用。 for more detail you can search about Forward Declaration in header file. 有关更多详细信息,您可以在头文件中搜索Forward Declaration。 for example in this case I use following code: 例如,在这种情况下,我使用以下代码:
namespace tensorflow{
class Tensor;
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.