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

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.

Related

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.

How to use SDL locally in Visual Studio 2013

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

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

Visual studio 2008 Qt Project configuration

I am trying to configure my dll project so that I can access QtCore4.dll and QtGui4.dll functions.
In my project properties under c/c++, Additional Include Directories I have added ...\Qt\4.6.0;
project properties under Linker Additional library directories I have added Qt\4.6.0\lib
Right, so what #include do I need to put in my header files so that I can get the functionality?
Before I was using dependencies and using the includes and but now I have removed the dependencies I am getting a 'cannot open file: 'QtCore/qcoreapplication.h': no such file or directory error.
This project is making me feel like a moron.
Thanks.
Your additional Include directory should be ..\qt\4.6.0\include. If you use qmake or the VS plugin all this is done automatically.
Save yourself time and hassle, get the plugin: http://qt.nokia.com/downloads