Organizing a Visual Studio Solution with common source for multiple projects - c++

The title describes what I try to achieve since I started developing in VS2013.
I basically have a folder which contains all the projects linked to the solution (in this case, EditorRenderer, Engine, FileEditor and PhysicsWorkbench are project directories) which share the same source files which are placed in Source folder.
I organized the Source folder as an Filter in Visual Studio and I made filters to match the entire folder hierarchy that Source has in Windows Explorer. The problem is when I have 2 projects and I add a new folder to the Source, I have to add the folder and the files individually for each project. My question is: Is there any way to make a global project that will be included in every other project that I choose, and to make changes only one time?

Related

Visual Studio 2019: Linking to folder

I am trying to link to a folder that is not inside the project directory. To give an example,
If my project is in C:\project and I have a folder C:\shared, how can I manage to link C:\shared into the project (and being able to edit/view the files in Solution Explorer) without making a copy of the directory and placing it into the project directory.
I need this due to the fact that many projects will use this folder and it would be ideal to have them edit/use the same files rather than copy the folder into each project individually. That way if a bug is fixed in one project, all other projects will now use the fixed files as well.
For more context, this is a C++ project using Visual Studio 2019.
What I've tried/considered.
Additional include directories
Problem: This does not show the files in the Solution Explorer
Dragging/dropping the folder (or copy/pasting) as seen in another StackOverflow thread.
Problem: This just crashes my visual studio completely. The folder is quite large so I assume that's related to why.
Appreciate any insight on how to proceed. It's really unfortunate that this is a pain, I would think that something like this would be common, but all the posts I've seen related to it have either gone unanswered or could not be applied to my situation.
Thanks.
Shared Projects are the key here.. I just found out they existed. After creating one, drop the folder/files in the same directory that has .vcxitems file. Now in the project you want to include the shared folder, right click your solution, Add -> Existing Project and select your .vcxitems file.

How does Visual Studio and Github work together?

For example: I'm making an SFML game and I want to store my project on GitHub so my team members can have access to it. Since its made in Visual Studio does that mean I need to include: Solution file and .vcxproj file?
Also, I've seen projects on GitHub have a "src" folder to organize their repository, since mine was created in Visual Studio does that mean I need to rename my folder that is named after my project to "src" and reupload it? Or are people doing some sort of organization trick I'm missing?
Since the game is SFML, all my binaries (.dll) files are just thrown into my main folder of the project, I'd much prefer to throw them all into their respective folder, but if someone downloads my project does that mean they need to pull it out of that folder and throw it into the project file? (That way visual studio can find them)
TLDR: I'm having trouble organizing my GitHub repo with a Visual Studio C++ Project.
Since its made in Visual Studio does that mean I need to include:
Solution file and .vcxproj file?
Yes, you'll need to include solution and project files. You can see which files you can ignore at gitignore.io. Or, you can use cmake.
I'd much prefer to throw them all into their respective folder, but if
someone downloads my project does that mean they need to pull it out
of that folder and throw it into the project file?
Yes, each collaborator will have to download libraries and make it available to project on their end. And if you have lots of libraries and libraries depending on other libraries, updating them can be painful.
I use cmake and vcpkg. It isn't as straight forward as keeping libraries in project folder but requires reasonable effort for keeping project organized and clean. I'll recommend this approach.

Visual Studio 2010 Creating Packages/Folders in project

I am new to Visual Studio 2010 C++, I am trying to create packages in my project like we do in Java Eclipse but to my surprise the only option I found available was Creating a Folder so I selected that and created several folders added my classes to them then I tried including my header files in the folders I had created but it keeps giving me an error to hat I cannot locate the file, I checked in the Project directory and the folders are not in there but very visible and editable from Visual studio, I tried manually adding a folder with my classes from windows explore and still could not locate them in VC
The logic is organized slightly different than in Eclipse.
With Visual Studio, you create a solution (one directory) in which you will create one or more projects (either in the solution's directory, or in one or several subdirectories. I you have in your components a shared library for example, you would put in a separate project.
The source files in each project are organized in the same directory. If you use folders in a project, these are virtual and not materialized in the OS directories.
Remark: If you really want to organise project files within "hard" subdirectories, you can always force the directory in the item creation dialog. This is particularly practical if you add to a visual studio projects existing items stored according to a more complex OS structure. Unfortunately such a directory structure is not at all displayed in the solution explorer, so it is somewhat confusing.

c++ visual studio 2010 - How to create a project under a different folder name?

I would like to have a the following structure of folders:
Myproj\src
Myproj\include
Myproj\lib
Myproj\src should include all sources and project files etc.
EDIT: also, $(projectDir) should equal Myproj\src
The problem is with Myproj\src, when I create a new project in VS2010 a folder named \Myproj is created and in it all sources are placed. How can I break this connection and have my desired structure made?
A TFS friendly solution would be nice.
After you create a project, you can change the folders where certain files are stored. When you right-click the project in solution browser, there will be option for VC++ Directories - Include Directories.
If you add your $(ProjectDir)\src and $(ProjectDir)\include to this field, you will be able to put your files in these places. However, default VS creators, such as "Add Class" will still add your files to Project folder.
As for "lib" - I am guessing you are trying to create a library project. For that, you must find the "General->Output directory", and change it accordingly.

Creating a good directory structure

This might be a silly question but I am still learning. I have read several books on creating application and creating a good directory structure. When people talk about creating a directory structure, do they mean the folders you make within the solution explorer (folders you actually find inside of a .sln file) or do they mean setting up and creating folders that reside in the same folder as your .sln file or your compiled application (.exe). I figured the solution explorer folders are different from a typical windows folder cause the folders I create inside my .sln file are no where to be found on my windows system.
Visual Studio has a strange way of dealing with "folders" in solutions. A "Solution Folder" is not actually a physical folder, but more of a virtual folder managed by Visual Studio. Your files may end up in the root directoy, but VS will treat them as if they are in a "folder." This is configured and managed in the VS .sln or project file.
I'm not a fan of how this works in Visual Studio, I don't get why they don't just put files in physical folders. It's up to you whether you want to fight VS and try to keep your files in physical folders, or if you want to just let VS manage it, but ultimately, it really doesn't matter.
a typical directory struction will be like
bin (binaries)
Src
->.sln
->common
->.prj
->Project1
->.prj
->Project2
->.prj
Lib (3rd party lib's)
Doc (documentation)
Tools (3rd party tools)
Setup (setup projects)
Test (test cases)
With C++ in Visual Studio your solution directories need not match the filesystem, but they can.
Typically people refer to the directory structure as the filesystem layout of the project.
It's typical to have visual studio directories called headers and source, you wouldn't lay your project out like this on your filesystem though.
Visual Studio directories aren't just virtual folders though, they can contain filter rules so when you add a file to your project it will automatically get added to the correct filtered folder. They can also specify whether the folder should be under version control or not. And whether they should be parsed for auto complete or not.
Typically on filesystem I will create 1 folder per project and rarely create subfolders inside an individual project. But in the solution explorer I will create top level folders which I put projects into (For example: "Server Components" and "Client Components"), as well as in project folders to group things logically together (For example: Config, GUI, Controllers, ...) so I can find what i'm looking for faster.