如何在头中包含依赖项,而不将其包含在包含头的项目中 [英] How to include a dependency in a header without including it in projects that include the header
问题描述
你有两个选择。
1.您可以使用glew和glfw库静态链接项目,然后调用GLFWwindow函数
2.或者使用LoadLibrary()在c ++代码中加载glew和glfw库,然后使用GetProcAddess调用GLFWwindow函数()
So when you #include a header in C++, the compiler just copies the content of the header and pastes it where the #include was. I'm making a small game engine/framework and I'm including GLEW & GLFW in my Engine.h because I need things like GLFWwindow. But I get a compiler error in my Test Game 1 Project that uses the engine because since the compiler is just copying the code form engine.h and pasting it in test game 1's main.cpp, It's trying to include glew and glfw in my test game 1, which I don't want it to and I haven't linked against the glew and glfw libs in that project. How do I fix it so I can still access glew and glfw in engine.h without including them in test game 1?
You have two options. 1. Either you statically link your project with glew and glfw libraries and then call GLFWwindow function 2. Or you load glew and glfw libraries in the c++ code using LoadLibrary() and then call GLFWwindow function using GetProcAddess()
这篇关于如何在头中包含依赖项,而不将其包含在包含头的项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!