Visual Studio 2010: dll missing - c++

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

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.

Getting dll include to work in Visual Studio

I am new to Visual Studio, and to using .dlls, and I am trying to get portaudio running, but have not had success.
I built the .dll file, and created a console application project in VS,
I added the portaudio .lib file to "Additional Dependencies" in the solution properties -> linker -> input options.
I then added the directory for portaudio.h to VC++ Directories --> "Include Directories"
After those steps, I was able to build example code without errors, but when I run the program I would get this error:
The program can't start because portaudio_x86.dll is missing from your computer. Try reinstalling the program to fix this problem.
I tried adding the directory to where the dll and lib files are to "Executable Directories" but still I get the same error.
I don't know what else I need to do to get the dll working in VS. Any help is much appreciated.
The easiest solution is to move the created DLL to the same directory where your executable is running. There is no need to make project setting changes.
The other solution is to move the DLL to a directory specified in your PATH statement, or will be found by Windows using the Dynamic Link Library Search Order criteria.

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 2012 - error LNK1104: cannot open file 'glew32.lib'

I am having issues compiling a basic openGL program on VS 2012. I get a build error upon compiltation giving me:
1>LINK : fatal error LNK1104: cannot open file 'glew32.lib'
I followed the instructions given to me by the documentation for GLEW.
In your OpenGL project open Project -> Properties -> Configuration Properties -> Linker -> Input -> Additional Dependencies -> add glew32.lib.
Also you must include #include in your sources; For that add path to your glew folder: Project -> Properties -> Configuration Properies -> General -> VC++ Directories -> Include Directories and Library Directories;
C/C++ Tab -> General -> Additional Include Directories - Add lib folder there
I have also added the glew32.dll onto my Debug folder within my project folder along with the executable. So far I keep getting this error.
If you need any more further clarification of the steps I have done please don't hesitate to ask
In all honesty, there is no real benefit to using the DLL version of glew (short of reduced executable size, but this hardly matters on modern Windows PCs).
It is not like you can simply drop a new version of the DLL into your application and use extensions that you never used before. Likewise, bug fixes are so infrequent/unnecessary with a library that basically just parses the extension spec. files that using the DLL as a means of fixing extension loading bugs in shipped software is also not practical. Statically linking to glew (this means glew32s.lib) makes much more sense in the long run.
The static linking library is also more portable on Windows, it will work with MSVC and MinGW (whereas the DLL library only works with MSVC). Link against glew32s and put that in whatever directory you decided to use for additional library dependencies.
Here is a sample solution configuration for a project I wrote that uses glew. I have established a convention for this particular software where compile-time dependencies are stored under platform/<Subsystem>. Thus, I have glew32s.lib (32-bit) and glew64s.lib (64-bit) in ./Epsilon/platform/OpenGL/glew{32|64}s.lib
Steps to Use Classes form another project (Add header and solver linker errors)
To be able to add the header from another project, first go to "Properties > c++ > General > Additional Include Directories" and add the directory that contains the header. Now you will be able to add the header of the class from the other project, but running the project will still cause Linker Errors.
Add __declspec(dllexport) before the class you are using for the other project. This can be added in the header file of that class. This should be added right before the function or variable or class name. Now you will get a lib file. (if placed in wrong place, you can get this warning: https://msdn.microsoft.com/en-us/library/eehkcz60.aspx)
"Properties > Linker > Additional Library Directories". Specify the location of the lib file that is generated.
"Properties > Linker > Input > Additional Dependencies”: Add the name of the lib file.
This sounds like the library has been specified as a dependency, but the linker/additional search path(s) has not been set to include the directory where the library is located.
This may help.
It happened to me under this situation, I clean the solution and build it again, then many errors like LNK1104 occur.
After trying to restart IIS, I build solution successfully without LNK1104 errors. I do not know why, but restarting IIS takes much more time than normal, so I guess something is used by other IIS worker process.
Just give a shot to see if this magic happens on you.
This question is old and marked solved, but I had a similar problem symptoms with a completely different solution. So just in case anyone else stumbles in here:
It appeared that because I had 2 projects under one solution (a dll and an exe), the building order was mixed (from the output window):
1> Rebuilding project1..
2> Rebuilding project1..
1> file1.cpp
2> file1.cpp
and so on. By the message you copied, it appears you too have more than one project under one solution. One project was looking for the *.lib file that the other build hadn't created yet.
Solution:
Right click on "main" project -> Build Dependencies -> Project Dependencies.. -> Mark which project the main one depends on.