How to use SDL locally in Visual Studio 2013 - c++

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

Related

How to add a library to my project in a visual studio 2019?

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.

How to add Include directories in Visual Studio while cross-compiling to a Raspberry Pi?

I'm working on a c++ project on my Raspberry Pi. I'm using Visual Studio 2017 to cross-compile the project to my Raspberry.
But when I try to compile the project, I get the error"cannot open source file" in lots of header files.
I already managed to compile simple projects, but now I need to Include Directories and I don't know the proper syntax to set, on Visual Studio's project properties page, the Include Directories to tell the compile where the header files are stored.
For the PCL library, e.g., I was able to include directories using '$(INCLUDE_PCL)'.
But when I try to include pi's directory '/usr/Include/ni' I can't correctly set the absolute path. Here's an screenshot of my properties page (https://ibb.co/G2dszrx). I haven't set the Linker directories yet, since I'm currently getting errors on the compiling phase.
Does anyone knows how to set absolute path to include directories correctly?
EDITED:
Trying to figure this out, I created a new project (Proj) in which I include the file 'try.cpp' stored in the raspberry's "home/pi/projects" folder. This project is in the "/home/pi/projects/Proj" folder.
In the project property page, I have:
Configuration Properties>General>Remote Build Root Directory --> ~/projects
Configuration Properties>General>Remote Build Project Directory --> $(RemoteRootDir)/$(ProjectName)
C/C++>General>Additional Include Directories --> $(RemoteRootDir)
When I compile the project this path gets created correctly, and the project is saved at the correct place, even if go further into more folders in the remote build project directory, but it can't find the include file "try.h".
How can Visual Studio know where to save the project using '$(RemoteRootDir)', but is not able to add that path include directory?
After some searching I managed to correctly add the Additional Include Directories, and Additional Libraries.
Firstly I was also using OpenNI, to work with the PCL. After many tries, I discovered that OpenNI was not correctly installed. So I managed to install it with apt-get.
Secondly, If you want to include the "/home/pi/someDIR" directory at the Raspberry device, just add "/home/pi/someDIR" to Visual Studio's additional include directories.
For you still trying to achieve this, Merlyn Oppenheim, from visual studio, set up a sample project using VS 2019 and Raspberry PI template -> https://github.com/merlynoppenheim/sample-rasp-inc-headers
For this sample project the Visual Studio properties page should have:
C/C++ -> General -> Additional Include Directories = '/home/pi/projects/vcpkg/packages/sqlite3_x64-linux/include;%(AdditionalIncludeDirectories)'
C/C++ -> Linker -> General -> Additional Library Directories = '/home/pi/projects/vcpkg/packages/sqlite3_x64-linux/debug/lib;%(AdditionalLibraryDirectories)'
C/C++ -> Linker -> Input -> Library Dependencies = 'wiringPi;sqlite3;pthread;dl'

Where is Visual Studio source file directory change option

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.

GStreamer C++ on Visual Studio 2010?

Following instructions on http://docs.gstreamer.com/display/GstSDK/Installing+on+Windows to install GStreamer and compile tutorials/examples on Windows 7, for compilation using Visual Studio 2010.
After installing the SDKs, I try to compile the "hello world" example...
Cannot open include file: 'gst/gst.h': No such file or directory.
Odd - the tutorials were supposedly configured with the paths to these files. Nevertheless, we can manually add them...
Add C:\gstreamer-sdk\0.10\x86\include\gstreamer-0.10 to project include directories
Cannot open include file: 'glib.h': No such file or directory
Add C:\gstreamer-sdk\0.10\x86\include\glib-2.0 to project include directories
Cannot open include file: 'glibconfig.h': No such file or directory
At this point it seems to be a dead-end, as there isn't a glibconfig.h file anywhere on PC.
Was some step missing from the gstreamer documents?
p.s. I see a similar question, but its accepted answer seems to be a dead-link.
This question was posted on 2014. However, for everyone that needs to install Gstreamer on Visual Studio , I am explaining how you configure your library on Windows.
First of you need to download the library from https://gstreamer.freedesktop.org/data/pkg/windows/
You need to download and install both installers for developers and non-developers.
For instance for 1.14 it is the now latest version,
gstreamer-1.0-devel-x86-1.14.1.msi
gstreamer-1.0-x86-1.14.1.msi
You will install and setup both of them in the same directory like C:\gstreamer. (I guess gstreamer automatically adds its /bin to the Path environment. If not just ask it.)
After that you will open your Visual Studio. Create your C++ project. Create your main.cpp file. Right click on your project and click properties.
We need to do 3 steps:
Include the necessary directory paths.
Define the where the .lib paths are.
Specify which .libs you want to use.
After clicking properties:
C/C++ -> Additional Include Directories -> define your include paths such as
C:\gstreamer\1.0\x86_64\lib\glib-2.0\include;C:\gstreamer\1.0\x86_64\include\gstreamer-1.0;C:\gstreamer\1.0\x86_64\include\glib-2.0\;C:\gstreamer\1.0\x86_64\include\glib-2.0\glib;%(AdditionalIncludeDirectories)
Linker -> General -> Adding Library Directories -> write your lib directory path such as
C:\gstreamer\1.0\x86_64\lib;%(AdditionalLibraryDirectories)
Linker -> Input -> Additional Dependencies -> Write your .lib files you want to use such as
gobject-2.0.lib;glib-2.0.lib;gstreamer-1.0.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
gobject-2.0.lib;glib-2.0.lib;gstreamer-1.0.lib are the ones we added, others are done by default.
That's all. You can just write in your main.cpp file
#include <gst/gst.h> and use your GStreamer Library
I think this will work for almost all libraries.
(1) Install Windows Driver Development Kit
(2) When creating new projects, use the "gstreamer" template in Visual Studio, rather than the "Windows application" template. Then it doesn't need anything changing in the include/linker settings to make #include <gst/gst.h> work properly.
The standard gstreamer installation on windows has a glibconfig.h located in: (assuming your gstreamer installation is in C:\gstreamer) C:\gstreamer\1.0\x86_64\lib\glib-2.0\include
The official way is using the "Property Sheet" feature of Visual Studio.
In Visual Studio, click View→Property Manager or View→Other Windows→Property Manager on the menu bar.
Click Property Manager tab near the Solution Explorer.
Right click your project name and choose Add Existing Property Sheet..., and navigate to %GSTREAMER_ROOT_X86%\share\vs\2010\libs and load gstreamer-1.0.props.
This will add Addittional Include Directories, Addittional Libraries Directories and Additional Dependencies to your Project Properties.
Build your project.
Sources:
Creating new projects manually:
https://gstreamer.freedesktop.org/documentation/installing/on-windows.html?gi-language=c#creating-new-projects-manually
Share or reuse Visual Studio project settings:
https://learn.microsoft.com/en-us/cpp/build/create-reusable-property-configurations

Visual Studio 2010: dll missing

I googled for a whole day and I'm goin' mad..
Well, that's my problem: I've written my vs project, I've specified all the "include" (by selecting project properties -> configuration properties -> VC++ directories) and all the extern libraries directories (in the same way).
Then I specified all the additional libraries by selecting project properties -> Linker -> input -> Additional Dependencies and adding all the .lib files paths.
I press F7, it compiles with no errors.
I run the project and.. System Error: libsndfile-1.dll is missing.
That's okay, so I opened the vs console, I moved to libsndfile-1.def (and libsndfile-1.lib) path and I executed: "lib.exe libsndfile.def". Here I got another error: "LINK: fatal error lnk1104 lib.exe, impossible to open libsndfile.lib"
I tried to download libsndfile.dll from web but it still don't works. I've also tried to put all the libraries in my source files in visual studio.. but again, no way.
Where am I wrong?
Thank you in advance
EDIT: I've seen that vs doesn't find the other dll also!
Please do not copy the DLL into the folder... this is annoying for other developers in your organisation; instead right-click your app and click properties, go into the Configuration Properties->Debugging and set the Environment value to:
PATH=C:\PathToInclude;%PATH%
this will add the path to your environment and merge it to your application environment.
Do that for all Configurations of your app.
I solved simply placing all the dll files in the same directory of the .exe file