GStreamer C++ on Visual Studio 2010? - c++

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

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 can I tell Visual studio where my additional .dll files are?

I have recently switched my IDE to Visual Studio 2019 for C++ projects. I easily followed a tutorial into setting up a new library like SFML into visual studio, and tell it where the additional include and library directories are.
But there is something else that is required for it to work, which are the .dll files. Every page I followed, even the Documentation by the SFML website, it says that they have to be in the same directory as my project. That means I need to copy-paste the 7-8 files into my project directory. This really makes the folder look untidy. I would like to create a new folder and tell Visual Studio where those files are. I tried going doing this
Project -> Properties -> Linker -> Input -> Additional dependencies
Usually, the lines that would work are
sfml-system-d.lib
sfml-window-d.lib
...
I tried doing $(ProjectDir)valid path\ sfml-files.lib but this gives me the linker error, saying that It could not find the file.
If I simply move the .dlls into a folder without doing anything, the code would compile and link fine. But when it runs, Windows gives me a pop-up box with the same error message.
Here is how it currently looks
Looks really messy, I just want to be able to move them into dependencies like how src contains the source files.
How can I achieve this?
As it is now, it works perfectly fine. The issue only occurs when I try to create a new folder.
I hope I have covered the important information required for a good answer, If not please let me know what more I should add
Microsoft Visual Studio 2019
Currently running 64-bit platform with Debug configuration. Hence the -d suffix
You could create a path environment for your specified directory, which is like drescherjm’s suggestion. The steps:
Right-click “This PC” -> “Properties”-> “Advance System settings”
Click “Environment Variables”
In the System Variables group, edit “Path”
Add your directory, for example: ”D:\ SFML-2.5.1\bin”
Restart your visual studio and re-open your project
The easier solution might be to put them in the x64 subdirectory. This allows you to have various builds side by side (x86/x64, debug/release).
Since this x64 directory is where the EXE is located, it is the first directory searched for DLL's. It will take precedence over the Path solution suggested in the other answer. The Path directories are searched last of all.

Build failed with no stated reason on Segger Embedded Studio after adding custom source files

I'm modifying a simple example project (blinky) from the nRF SDK. I added a header file and a .c file in a new folder inside the project directory then added that path ./lib to the common preprocessor user include directories. I then included the header to main.c.
I can compile the new library on its own but when I build the whole project, I get Build failed error with no stated reason to follow up.
Here is an image of that:
Does anyone here know how to beat this?
I haven't used Segger Studio specifically, but it seems to be the CrossWorks IDE underneath.
In CrossWorks, you have to do the following:
Download & install all relevant libs from inside the IDE, under Tools -> Packages -> Install packages. Grab your specific target MCU as well as any specific boards or libraries you'll be using. In case some needed lib is missing here, you will get very weird errors.
In the project, click on the project name itself in "project explorer". Then in the properties window, check settings (this is a bit different in different versions of CrossWorks, might have to right click and pick properties in older versions). Under "user include directories" you should have something like this:
$(DeviceIncludePath)
$(TargetsDir)/NameOfMCU/Include
$(PackagesDir)/CMSIS_4/CMSIS/Include
$(ProjectDir)/NameOfDirectory
Where "NameOfMCU" is the name of the MCU family used, CMSIS should be there in case you are using any ARM, "NameOfDirectory" is the name of your custom directory (you can add several).
Also, get the debug build working first, before switching to release build.

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'

cairo + openGL + Glut + VS 2010 + Windows 7

I'm pretty dump :) So could anybody help and write step-by-step manual, how to install "cairo", "glut" and use it in VS 2010 project (C++) on Windows 7?
PS: the most fun thing that i managed to do that without any problem in Linux.
I don't know cairo, but setting up GLUT is rather straightforward.
Download FreeGLUT
Unpack the downloaded archive
Go the directory unpack-dir/freeglut-x.x.x/VisualStudio2008
Open the visual studio project
Rebuild the project for each target (release, debug) you want to create
This should create a DLL file and a lib file with the same name. Now if you want to create a new project that uses GLUT, just configure the project correctly:
Create new project
Create a main C/C++ file (otherwise, you won't be able to set the include settings)
Go to project settings (right click project -> Configuration properties)
C/C++ -> General: add the freeglut include directory to Additional Include Directories
Linker -> General: add the path to the built .lib (freeglut) file under Additional Library Directories
Under Linker (input) settings: add the name of the .lib file under Additional Dependencies
If you follow this setup, you should be able to use GLUT (#include <GL/glut.h>) in your code and it should compile nicely. Not sure how you can also add cairo, but it will probably be a very similar process.