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.
Related
I use CMake to create C++ projects. Then I would like to use Visual Studio as my IDE. But the issue I face is that I can't get files to be structured properly.
Here is the problem:
Let's assume I have the following file structure on the disk.
And here is my CMakeLists.txt:
cmake_minimum_required(VERSION 3.20)
set(sourceDirectory src)
set(includeDirectory include)
set(targetName vulkan-tutorial)
set(targetVersion 1.0.0)
project(${targetName} VERSION ${targetVersion})
file(GLOB src
${sourceDirectory}/*.cpp
${sourceDirectory}/**/*.cpp
${sourceDirectory}/**/**/*.cpp
)
add_executable(${targetName} ${src})
target_include_directories(${targetName} PRIVATE ${includeDirectory})
Here is what this project looks like in Visual Studio with filters.
Or without using VS-filters.
I can create new files, but they're not going to land, where I want them to. The behavior I want to achieve is extremely simple: I want to see the root directory of my project and its "src" and "include" folders. I want to be able to right-click them and create new folders and files. Then I want Visual Studio to create them inside the selected folder. Like it would be in every normal file-explorer.
One solution I could imagine is to generate project files not inside a "build folder", but in the root directory of the project itself, which is obviously a terrible solution and leads to a pollution of the project structure.
Summarized - here is the result I want to end up with (now I can achieve it only by generating the project in the root). But all the build files should be located in the corresponding "build" folder in the root of the project.
I also would like to add that I tried to use different functions for CMake that kind of group my files together, but I just ended up with lots of filters that reflect my project structure on the disk. Of course, I still wasn't able to add new folders and files dynamically.
I appreciate any help. Thanks in advance.
Simply use the Open Folder option in visual studio.
This will open the directory and automatically configure the project using CMake. It will display the tree independently from the CMake configuration structure.
Microsoft has a page CMake projects in Visual Studio, that explains how to properly import CMake projects in visual studio
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.
How do I go about to make Visual Studio add a folder from my project into the build directory (for example \x64\Release)? I have a folder for images that I want to be included when I build my application so that they can easily be accessed in relation to the executable's location. The problem with doing it manually is that I have to copy it over manually for both my debug and release folders instead of keeping it all compact withing my project. It also helps with uploading to github.
So is there any way to do this? And if so, how?
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?
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.