0

I have one C++ solution in my Visual Studio 2013. The solution contains 2 projects. One is a Game Engine project, the other is a Game project.

The default project which launches is Game (it is .exe), the project depends on Game Engine project(Which is only .lib the Game project uses).

The problem is, the GameEngine project uses always the $(ProjectDir) or working directory of Game, which I do not want. Even if it says in properties it will use the path to GameEngine folder, it eventually wont.

I want the GameEngine project code to use working directory of GameEngine project file (When I load files or Images from it`s folders).

Please can you help me with this issue?

Wrymn
  • 173
  • 1
  • 2
  • 13
  • What you are asking for just doesn't make any sense. A .lib gets linked into the final executable, it does not have a "working directory". If you want to share assets between different games that all link that .lib then just store them in a well-know %appdata% subdirectory. Use a post-build event to copy the files there with xcopy /d – Hans Passant Jun 26 '15 at 15:11

1 Answers1

0

That's not how project references work. The idea is to produce a complete working folder in the $(Outdir) of the default project - in your example C:\folder\Game\bin\x64\release or similar - which you can later package into an installer and distribute.

Presumably, you want your GameEngine project code to run in GameEngine's ProjectDir - in your example C:\folder\GameEngine\bin\x64\release or similar - because you want the code to access additional files in that directory. If that's the case, you should add those files to GameEngine.csproj with Build Action = Content and Copy to Output Directory = Copy if newer (see screenshot below). Then they will be copied to Game's $(Outdir), and your code will be able to access them.

Visual Studio - Content Copy if newer

Jonathan
  • 6,939
  • 4
  • 44
  • 61
  • Thanks Jonathan for reply. I use C++ project, and i`m not sure I have the same options as is in your screenshot above. The "items" or folders I want to include contain shaders or textures, and I do not have included in project, they are just in folders near my GameEngine.vcxproj – Wrymn Jun 26 '15 at 12:19
  • You're right, my answer applies to C# projects. The concept still applies - you should find out what makes your files (shaders etc) get included in the GameEngine project, so the Game project knows to copy them to its output directory. – Jonathan Jun 26 '15 at 13:27
  • Sorry I am googling and searching, I have no idea how to I make the picture lets say in "MyFolder/picture.png" be included, so code in project can refer to that even if the project is as library project in my solution. – Wrymn Jun 26 '15 at 14:14
  • I believe you can include your files as [Resources](https://msdn.microsoft.com/en-us/library/zabda143.aspx). There seem to be [tricks for putting resources in a static library](http://stackoverflow.com/questions/531502/vc-resources-in-a-static-library). – Jonathan Jun 26 '15 at 16:41