I've been trying for hours to change the source path. I couldn't find anything on project properties, and I couldn't find anything on the internet either.
I want to put all my source files in a directory named "src"
like $mysolution-path)/src and I also want to put library files in the /lib directory, but I can't do it.
Where is this option? Is there an option like this. I want to keep my work clean and tidy, but it seems like it's impossible in Visual Studio unlike in IntelliJ IDE.
One way of doing it:
remove your files from the VS project
move the files in explorer
add the files to the VS project
In Project properties -> Configuration Properties -> C/C++ -> General there is the voice: "Additional Include Directories". You can specify there all the folders you are using for your project, thus you just need to create the folders you need manually and then add the paths there.
About lib files, under Project properties -> Configuration Properties -> Linker -> General there is the voice: Additional Library Directories. Just add there the paths to the lib folders.
Related
I needed to use zydis library in my VC2019 cpp project.
I have no idea how can I add it to my current project - I downloaded it from github.
There is msvc folder, inside I can find .sln file, some header files and .vcxproj files - what should I do, to just include it into my project and use it?
It can be done by adding a reference to the DLL file.
In Visual Studio, right click on the project, Add Reference. Give the path to the DLL file and add it to the project.
First, I suggest that you could download and install Zydis using the vcpkg dependency manager. The method is easy and convenient.
If you don't use vcpkg, you could follow the steps below.
Open the Zydis.sln in msvc with VS2019.
Copy files in include/Zycore, put them in zydis-master\include\Zycore. Because I find that there should be missing files when I compile Zydis.sln.
Right click Zydis, set Visual Studio 2019(v142) in Properties->General->Platform Toolset.
Compile it, and you will find Zydis.lib in zydis-master\msvc\bin\DebugX64.
Then, you could copy include floder and lib in your program floder.
You could set VS:
Right-click the project, select Properties->Configuration
Properties->C/C++->General, find the Additional Include Directories and set the directory.
Properties -> Configuration Properties -> Linker ->
General, find the Additional library directory in General, and set the lib.
Properties -> Configuration Properties -> Linker -> Input,
find Additional Dependencies and input the lib name.
Besides, you could set five build configurations.
I want to add SDL and SDL_image to my Visual Studio project. But can I do it locally only for this project? I don't want to put the dlls in System32 folder.
As described by Ciprian Khlud, you could simply put your DLLs next to the output binary (.exe). You could find output directory in
Right click on project -> Project Settings -> General -> Output Directory
Alternatively, you could add the folder where DLLs are into the list of search directories:
Right click on project -> Project Settings -> VC++ Directories -> Executable Directories
(same way as you add include dirs and library dirs)
An easy way is to copy them either manually into your output folder or to create a post build event.
Use Microsoft link to see where you can put your Dlls without conflicting with System32:
https://msdn.microsoft.com/en-us/library/7d83bc18.aspx
I am able to create Dlls and am able to access their header files by manually adding the file path of the .lib file to Project Properties -> VC++ Directories -> Library Directories as well as Proj Properties -> C/C++ -> Additional Include Directories. Everything works properly when I do this, BUT every time I open my project on a new machine I have to manually change all of these paths.
I tried setting them to relative paths instead (i.e. ..\ProjectName\Debug) but this did not work. Is there any way to include the necessary library files in my project so that the project will work automatically no matter which machine it is on?
Relative paths should be fine. It didn't work for you because you set incorrect paths I guess.
If .. confuses you and you are not sure what directory it refers to, you can use macros that are defined within Visual Studio IDE like $(SolutionDir) or $(ProjectDir). Note that these macros include / at the end so when you specify path by using them it looks like this: $(SolutionDir)dep/include.
Hope this helps.
I wonder why one of my projects has VDSERR.h listed under "External Dependencies" and another hasn't and gives me an "undefined symbol" compiler error about a symbol which is defined in there. How can I include this file in the other project as well?
The External Dependencies folder is populated by IntelliSense: the contents of the folder do not affect the build at all (you can in fact disable the folder in the UI).
You need to actually include the header (using a #include directive) to use it. Depending on what that header is, you may also need to add its containing folder to the "Additional Include Directories" property and you may need to add additional libraries and library folders to the linker options; you can set all of these in the project properties (right click the project, select Properties). You should compare the properties with those of the project that does build to determine what you need to add.
To resolve external dependencies within project. below things are important..
1. The compiler should know that where are header '.h' files located in workspace.
2. The linker able to find all specified all '.lib' files & there names for current project.
So, Developer has to specify external dependencies for Project as below..
1. Select Project in Solution explorer.
2 . Project Properties -> Configuration Properties -> C/C++ -> General
specify all header files in "Additional Include Directories".
3. Project Properties -> Configuration Properties -> Linker -> General
specify relative path for all lib files in "Additional Library Directories".
I am building an app on Qt 4.6.2 using visual studio 2008. I need to include the header <QtGui\QDir>.
Problem : The QDir header includes several headers. Once of them is qfile.h. Now the ide/compiler is unable to include this file and the error I get is this
c:\devprojects\myprojects\nttoolkit\trunk\external\qt\include\qtcore../../src/corelib/io/qfile.h(45)
: fatal error C1083: Cannot open
include file:
'Qt/include/QtCore/qiodevice.h': No
such file or directory
I cannot change the path in the file qfile.h since it is an external file to my project. How do I get it working.
Thanks.
The various places the preprocessor searches for include files is described in the Remarks section here.
Typically for an "SDK" like Qt people will change their VC++ Directories, Projects, Options under Tools | Options | "Projects and Solutions" | "VC++ Directories" so that the Include Files and Library Files lists include suitable Qt directories. That way, when the preprocessor searches for Qt include files, it will look in the right places and when the linker looks for .LIB files it will find them also.
One downside to changing those lists is that they apply to all projects built from that version of Visual Studio. That can be a pain in the neck if you have different projects that use different versions of an SDK. In those sorts of situations one solution is to create environment variables called INCLUDE and LIBPATH and then launch devenv with the /useenv switch to override the VC++ Directories settings from Tools | Options.
Finally, a third option is to provide the additional include and library folders via the project properties. In Project | Properties | C++ | General the first property is "Additional Include Directories". Values placed there are passed to the preprocessor via the /I switch. Similarly the Project | Properties | Linker | General tab has an "Additional Library Directories" property which gets passed to the linker via the /LIBPATH switch.
This third option seems attractive because it lets you set these additional directories on a project by project basis. The downside is that it "hard-codes" some directory names in the project. That can be a real pain if you move the project to a new machine where the Qt files are in a different directory or when you have to move the Qt directories to a different hard-drive, etc.
In VS2010, I go to:
Project Properties -> VC++ Directories -> Include Directories
And set the location of directories containing headers I need to include. I don't currently have access to a VS2008 install, but I think there is a similar configuration option available.