Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import files with directory structure into visual studio 2013

I have the source code for a C++ library (its a version of Box2D)
I'd like to add parts of it to a new project and build it to a .dll

However when I add the directory of files I want to the new project it adds them all to the root of the project and as a result most if the include statements are wrong.. for example...

#include <Box2D/Dynamics/b2Body.h>
#include <Box2D/Dynamics/b2Fixture.h>
#include <Box2D/Dynamics/b2World.h>

The "Box2D/Dynamics/" part is now wrong.
I add the new files by putting the directory containing the files I want in the new project directory, then clicking the "show all files" button, then clicking on the folder and saying "include in project"

Heres what the original project (from which I'm copying the directories of of files) looks like..
enter image description here

and heres what my new project looks like. As you can see the whole project is 'flat' all the files are in the project root (though in the actual project directory the sub-directory structure is still present)
enter image description here

tbh I've always found this file management aspect of visual studio weird and confounding

like image 687
Guye Incognito Avatar asked Oct 31 '22 17:10

Guye Incognito


2 Answers

The reason you do not see folders when you import files is that there is no folder to speak of. As you can see the filter overlay on the folder icons, there are just filters. You can also view properties of these folders to find out which files listed under that folder.

VS2013 uses projectFile.vcxproj.filters file to manage filters. You may try copying that file (or manually creating one) to your new directory and then import code/header/other files. AFAIK, VS should pick correct folder for file by looking file extension.

like image 128
Erdogan Kurtur Avatar answered Jan 04 '23 13:01

Erdogan Kurtur


I made an extension for this purpose: https://visualstudiogallery.msdn.microsoft.com/5a3251d7-3228-4813-a67e-6b9cc83d0507

Sources being here: https://github.com/Dllieu/VisualStudioCppExtensions

Once you import all your files (e.g. same as your second screenshot), you just need to right-click on your C++ project and click on "Generate C++ Project Filters", it will create all the filter to replicate the folder hierarchy of your files

like image 43
Stephane Molina Avatar answered Jan 04 '23 15:01

Stephane Molina