omniyo
omniyo

Reputation: 340

Set up Visual studio library project dependencies

I'm struggling to find out the proper way to set up dependencies in Visual Studio (i.e. 2015) given the following case:

I have 2 projects:

At this stage, Engine project compiles successfully.

I hoped that Game project would work too but when I try to compile this project with a simple main.cpp, the compiler shows this error(referencing a file from Engine project):

-- Error C1083 Cannot open include file: 'GL/glew.h': No such file or directory

I don't want to include opengl, glew and glfw libraries and include directories to my Game project, since the user shouldn't access to this API.

So... what's the proper way to achieve this (the simpler the better)?

Thanks in advance

Upvotes: 5

Views: 7180

Answers (1)

Just Jake
Just Jake

Reputation: 76

Steps to link a static library to another project in same solution:

Make your Engine project a library if it isn't already. Build it.

Right click your solution or one of your projects and go to Build dependencies -> Project dependencies. Select your Game project in the dropdown, then check the box next to Engine. This will let the compiler know that Game can't start without Engine.

Go to your "Game" project properties -> C/C++ -> General -> Additional include directories, make sure you have the location of your Engine project's header file here.

Go to C/C++ -> Code Generation, make sure both projects use the same Runtime Library as eachother in debug and release.

Go to "Game" Project properties -> Linker and put the location of your other project's lib file here.

Go to Linker -> Input Add Engine.lib or equivalent to this list.

You should have a project linked to a library. Reply to my response if this didn't help.

Upvotes: 3

Related Questions