I am writting a game, and at the same time building an engine for it and for other games I may make in the future. During testing on both the game logic and the engine (separately) run well. However when I try to link them together, I encountered some problem with the inclusion of header files.
To be specific, here is what I did:
The engine is built as Static Library (.lib), and depends on GLFW static library (glfw3.lib). It contains a Window.h file:
// Window.h #pragma once #include <glfw3.h> // include other library's header #include <iostream> //test if the linking success void test() { std::cout << "this is Window.h"; } class Window { // Window class code (declaration, function prototype, etc...) } *Note that the location of GLFW library is separated from engine/game project location.
The game project is hosted under the same Solution with the engine project. In the game's Properties, I have add the engine as dependencies as well as engine's .lib and include location. Then I try the following:
// game's main file #include <Window.h> void main() { test(); // call the test function from Window.h } When building the game, I got an error says that it can not find such file called "glfw3.h". However, if I comment out the inclusion of glfw3.h in Window.h file:
# Window.h #pragma once //#include <glfw3.h> then the game build and run normally, and prints out the test line in test function.
I want to build the engine as a single .lib with header files that prototypes functions for its classes; so that in the game project I only need to include/depend the engine library and no need to care about GLFW or such. How can I achive that? I found a similar question, but it seems the answers don't solve my question.