Reputation: 45
I'm fairly new to Visual Studio and git so please bear with me!
I'm using VS2017 C++ for Windows development and I have 2 machines, a desktop PC which is my main and a laptop which I use when I'm travelling. I have created a VS solution on the main PC and pushed it to a new git repository. I am using SDL libraries which are installed on a drive labelled F:
.
I have cloned the repository to my laptop, but the SDL libraries are on the D:
drive (there is no F:
drive) so I have to edit the properties to get it to find the libraries. The problem is that because the project file is version controlled, when it gets pushed back to GitHub and then pulled back to my main machine, the paths are wrong again and I have to edit the properties. This is obviously not a good solution.
The only workaround I can think of is to have the libraries installed in the C:
drive which does exist on both machines, but I'm not sure if there is a more 'elegant' way of doing this.
Any advice would be greatly appreciated.
Upvotes: 1
Views: 150
Reputation: 2758
You are on the right track with fixing your problem, and I think that with just one more tool you will be able to get it working!
If you have library files, a common solution is to use environment variables to be able to have different paths on different systems, without having to change your solution files. If you open your start menu, and search for "Edit environment variables for your account", you should be able to open a window where you can add environment variables. There you can click "New...", and add a variable with a name, for example SDL_LIBRARY
and with a path to where this library is located. On your other machine, you add a variable with the same name SDL_LIBRARY
, but with the path to the library on this machine.
In your visual studio project, you can then use the environment variable SDL_LIBRARY
, as described here in the documentation. You could as an example add a line to "Additional Library Directories" to a C++ project that reads:
$(SDL_LIBRARY)\libs
or to the "Additional include directories":
$(SDL_LIBRARY)\include
and then your project file should be able to work on both of your machines.
Upvotes: 2