• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Visual C++ 2010 Express (Again)

mgh

Messages
1,413
Country
unitedkingdom
I've been using Visual C++ 2010 Express to experiment with the sample applications in the DirectX SDK.

These samples compile and run in their original folders within the SDK.

When I copy a folder containing a sample to another location the sample fails to compile - giving error messages about being unable to find files. (It's common-sense to make a copy before making any changes.)

I discovered the reason is Microsoft chose to use relative paths to the include, etc. files so they aren't found when the folder's moved. The only solution I've found is to go through the source and supporting files and change the paths manually.

Does anyone know of a better way?
 
Whenever you create a project with VC++, a very tight organized structure is created by VC++. This includes mainly the source folder, the release folder and the debug folder. Over the years I made the experience, that relative paths are the better choice. If you migrate the project to another computer with different drive letters, the compilation works immediately. For this, you copy the project folder and its entire subfolder structure to the destination. If you use absolute paths in your project, it would never work. The result is, if you migrate, you better copy the entire project to the destination. Not only single files.
If you use include directives in your source code which include absolute paths, I would recommend to use only the file names and to specify a relative entry in 'Additional Include Directories' in the Project options.
The only disadvantage of relative paths is the necessity of strict organization of your projects. You need to develop some rules for that.
Regards
Mike
 
My point is that Microsoft chose to use relative paths in the samples it provided in the DirectX SDK.

For example a relative path in the .vcxproj file is

..\..\DXUT11\Core

when the full path is

C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Samples\C++\DXUT11\Core

If the complete folder containing a particular sample is moved that relative path no longer points to the correct folder and the sample simply won't compile.

On the wider point, I prefer to control where my folders are myself and not have the compiler decide for me.
 
For include files I make an include with no path, and use Additional Include Directories and Additional Library Directories in Project Properties. These link to absolute path, and I can change without having to modify in many places in code.
 
I admit that I'm inexperienced with Visual C++ but in the Microsoft DirectX sample I've been using the following line

<AdditionalIncludeDirectories>..\..\DXUT11\Core;..\..\DXUT11\Optional;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>

appears six times in the .vcxproj file.

In addition in the file vcxproj.filters lines of the form

<ClInclude Include="..\..\DXUT11\xxxxxx\yyyyy.h">

appear 10 times and lines of the form

ClCompile Include="..\..\DXUT11\xxxxxx\yyyyy.cpp">

appear 6 times where xxxxxx is either Core or Optional.

Isn't this over-elaborate or am I missing something?
 
I had to because the sample wouldn't build until I changed those paths manually.
 
You mean, you don't have an option like this?
 

Attachments

  • properties.jpg
    properties.jpg
    554.9 KB · Views: 400
Yes I do. But changing the relative path for Additional Include Directories to an absolute one doesn't change them in .vcxproj and building still fails because it still contains now incorrect relative paths.
 
Going directly to the project files is not the preferred method. The content follows a specific syntax and producing errors is a probable result. The entire content can be controlled from the option dialogs. When changing the paths it is important to know how the VC++ interprets the different directives.
The entire development system with its 'include' and 'lib' directories are defined in system variables. This is done when you install VC++ on your computer. Therefore you need not to take care for paths if you include the standard 'includes' like <windows.h> and <stdio.h>. Includes like this are defined in angle brackets .
If you work with an additional SDK like directX or FSX SDK, then the required includes and libs are anywhere, unknown to VC++. Now you have two choices. You may use direct paths in your source code like this:
#include "C:\program Files\xxxx\yyyy.h"
which is not the best choice. The better choice is to identify the location of the includes an add this to the Property pages in C/C++/General/Additional Include Directories. You need to take care, that your entry is made in the right configuration (debug, release ...) . You can be sure, that the definition is stored in the project file at the right location. With such a definition you may include the above example as
#include "yyyy.h"
The quotes let VC++ search in the local directory, where the source resides and, if nothing is found, in the location defined in ' Additional Include Directories'. You even may define more than one directory in 'Additional Include Directories'. So you can cover different SDK at a time. In case of additional SDKs it makes sense to define absolute paths in 'Additional Include Directories'. If an include directory is bound close to your project, because it is in a neighbouring directory, it makes more sense to define a relative path. It makes migrations easier. This works for me and I never had trouble with it. The definition for libraries follow a similar logic and are defined in the linker section of the property pages.
Regards
Mike
 
That is all very true but doesn't alter the fact the Microsoft provided sample projects in the DirectX SDK that use relative paths to other folders also in the SDK. The samples would not build if they were moved to another location. They could no longer find the necessary files.

All my attempts to change this from within Visual C++ 2010 Express failed. The only solution I could find was to change them manually myself in the supporting files. Now I know what to do it is quick and reliable.
 
Back
Top