How can I make my application find a third-party DLL using Visual Studio? - c++

I have read many issues regarding and followed each one but nothing seems to work.
I am trying to include the rdkafka library into my project, but every time I run the application I am getting
The program can't start because librdkafka.dll is missing from your computer.
I can clearly see that librdkafka.dll as well as librdkafka.lib exist in the same directory. I have added the include files to the project, and I have also added the librdkafka.lib to the additional directories in the Linker section. The project builds fine but it throws that error at runtime.
Does anyone know how I can solve this issue?

When in Visual Studio by default it is searching for dlls in the project directory and running the application on its own will try to find the dlls in the current working directory. Moving the dlls to this location seems to solve the issue.

Related

Missing libgcc_s_seh-1.dll starting the .exe on Windows

Intro
I have a CMake-based C++ project. Until now I build and ran the project via CLion. Everything worked fine until I tried to run the .exe-file directly (not via CLion).
Problem
When I navigate to the cmake build directory in order to start my program via the executable file, it fails with the following message in the popup: Cannot continue the code execution because libgcc_s so-1.dll was not found. Reinstalling the program may resolve the issue.
I have the following questions
If I interpret the error message correctly, then this dll is missing on my computer. So I ask myself, why does my program still work when I start it via the development environment (CLion), although the error message expressly states that the source code requires this dll?
Is it the fault of my application/source code that the error appears or rather the current state of my computer? If the former, how can I prevent this error from appearing for other users?
What is the best way to fix this error? It's obvious that I need to download this dll, but where is the best place to put it (which directory and environment variable to use on Window)?
Which source is trustworthy to download this dll? I don't want to download any malware under this dll-name.
Optional: What kind of library is that? What functionalities does it offer?
Additional information
I use CMake as my build tool, CLion as the IDE and MinGW as the compiler.
What I have did so far?
I made sure it still works through the IDE.
I found this dll does not exist in the MinGW installation folder.
I searched the web for more information. Unfortunately, there are only pages unknown to me that only offer the download of this dll. That doesn't satisfy me.
I found the cause of my problem: I had two MingGW installations on my machine. Once the installation that comes with CLion and a separate one. The latter did not have the required dll. However, CLion used its own installation, which in turn owns the DLL. So the solution was to remove the separate installation and include the path to the CLion installation's bin/ directory in the PATH environment variable.
This file is part of MinGW-w64 when using SEH as exception model (as opposed to Dwarf or SJLJ). You need to distribute the .dll files your .exe file(s) depend on in the same folder as the .exe file(s).
If you don't have that file, then you probably have been using libraries compiled with different versions of GCC/MinGW(-w64). I recommend building everything with the same compiler to ensure stable binaries.
Tools like Dependency Walker can help you figure out which .dll files your .exe file depends on.
Or use the command line tool copypedeps -r from https://github.com/brechtsanders/pedeps to copy the .exe files along with it's dependencies.

OpenCV: Code Execution Cannot Proceed, DLLs Missing

I'm making a program using OpenCV and I need feature matching. I was previously using OpenCV3 but apparently getting SURF to work is a bit of a hassle so I switched to OpenCV2.4
I downloaded the pre-built libraries and I want to use them on Visual studio but I have a problem, when I run the program I get messages like this:
When I click ok I get more follow up messages complaining about other missing dlls. I tries re-installing but still get this error.
Here are my settings:
Under C/C++>General: Additional Include Directores:
C:\opencv2.4\opencv\build\include
Under Linker>General: Additional Library Directories:
C:\opencv2.4\opencv\build\x64\vc14\lib
C:\opencv2.4\opencv\build\x64\vc14\bin
Under Linker>Incput: Additional Dependencies:
opencv_calib3d2413.lib
opencv_contrib2413.lib
opencv_core2413.lib
opencv_features2d2413.lib
opencv_flann2413.lib
opencv_gpu2413.lib
opencv_highgui2413.lib
opencv_imgproc2413.lib
opencv_legacy2413.lib
opencv_ml2413.lib
opencv_nonfree2413.lib
opencv_objdetect2413.lib
opencv_ocl2413.lib
opencv_photo2413.lib
opencv_stitching2413.lib
opencv_superres2413.lib
opencv_ts2413.lib
opencv_video2413.lib
opencv_videostab2413.lib
I've also tried editing the Environment Variables under Path I've added the include\ bin\ and lib\ directories. I have absolutely no idea how to fix this problem. I know the dlls are there.
I copied and pasted the dlls from the bin\ directory into my solution directory and everything works fine now.
I'm not sure why adding the bin\ to the path didn't work but anyway here's the solution to that problem.
The execution program did not find the DLL.
Under "Linker>General: Additional Library Directories" it expect the path for .lib files, but the DLL are searched by the program during the executio, so in the current folder and in the PATH folders.
Put the Dll's into the execution folder or modify the PATH to add the DLL's folder (in this last case remember to restart Visual Studio).
Cheers

Linking libpqxx from Visual Studio 2015 on Windows 10

I've recently decided to try out PostgreSQL as the database platform for some C++ development I'm working on. I decided to use libpqxx as the connection library for my project, and quickly found out this would be an uphill battle to do from VS 2015 on a Windows 10 machine.
After much teeth-gnashing and nail-biting, I have gotten libpqxx to compile on Windows 10.
This leaves me with the following directory structure
Per libpqxx's documentation, I also placed a copy of libpq.dll in my project's executable directory. Please note: I have done this for both debug and release builds, tried to build both, and ended up with the same result.
All the tutorials I've seen seem to indicate that the library can be used after linking it and simply #including pqxx/pqxx, so I set up a small project to do just that. I receive the error:
fatal error C1083: Cannot open include file: 'pqxx/pqxx': No such file or directory
When attempting to build the project. I have also tried this will both debug and release builds, to no avail.
Here is a screenshot of my linker settings.
Does anyone have any suggestions for how I might be able to link and use this library from Visual Studio 2015?
As Sami Kuhmonen pointed out, this was not actually a linker error, but a compiler error. I needed to include an actual header, which Visual Studio needed to be able to find. After adding the correct folder (C:\libpqxx\include in my case) to Visual Studio's "additional include directories" setting under C\C++ -> General per drescherjm's suggestion, the program compiles just fine.
For future reference:
I did also run into unresolved external linker errors after solving the initial issue. This is because you need to make sure to also link to ws2_32.lib and libpq.lib. You also need to copy some other DLL files that libpq also relies on into your libpqxx lib folder. On my system, I believe these were ssleay32.dll, libeay32.dll, and libintl-8.dll. These files reside under the root of the PostgreSQL install. The DLL step is mentioned under libpqxx's INSTALL.txt file, however I believe it stated that the DLLs resided one folder under where I actually found them.
I have also faced same issue. Then I realized that I was building ,my application as a 32bit. I changed the target to x64 and it compiled successfully

"The application was unable to start correctly" after including vld.h

I included vld.h, vld.lib and vld_x86.dll on my Win32 project with visual studio 2010. It builds properly but when I execute, it crashes with this message:
"The application was unable to start correctly (0xc0150002). Click OK to close the application."
I run it with Dependency Walker but it shows side by side error as follows:
Error: The Side-by-Side configuration information for "D:\project\..\debug\VLD_X86.DLL" contains errors. The application has failed to start because its side-by-side configuration is incorrect.)
I have tried various ways including tinkering around with the manifest as suggested here:
https://vld.codeplex.com/discussions/360243
It only runs properly if I commented the following line on vld.h
// Force a symbolic reference to the global VisualLeakDetector class object from
// the DLL. This ensures that the DLL is loaded and linked with the program,
// even if no code otherwise imports any of the DLL's exports.
//#pragma comment(linker, "/include:__imp_?g_vld##3VVisualLeakDetector##A")
However, if I commented out that line, the vld doesn't output anything at all (just like no vld integration)
Anyone having this problem before? Any suggestions will be appreciated, thanks in advance!
I had this problem too, you need to add all these files to the same directory as your vld_x86.dll/vl_x64.dll:
Microsoft.DTfW.DHL.manifest
dbghelp.dll
Which came from the Win32/Win64 bin folder from Visual Leak Detector. Found this from: https://vld.codeplex.com/wikipage?title=Building%20Visual%20Leak%20Detector%20from%20Source
I had this problem (this error message), too. In my case the vld_x86.dll, most likely in another than the expected version, was preinstalled and registered by some other software. (everybody likes VLD, it seems) Thus, it was loaded instead of the vld_x86.dll in the path VLD was built to. Unregistering the foreign DLL solved the problem.
Hence, you might want to check the output for loading of DLLs from exotic paths.
Other might still get into the issue;
A potential fix is to install VLD version 2.5.1, can be downloaded from github: https://github.com/KindDragon/vld/releases/tag/v2.5.1
It brings the fix explained above, it includes dbghelp.dll
I got such error when I tried to run a project just after installing vld. A solution for me was re-login. Because vld installer adds new paths to PATH and VS doesn't see them without re-login. Otherwise you can use a solution with copying files dbghelp.dll and .manifest.
If you are using Visual Studio
The simplest fix if you have not been messing with your project properties in the include, linker sections is to make sure that you did not manually add VLD. Instead clear the includes you made in here and save your project.
Close it then install the latest VLD and it will automatically create the includes parent inheritance for your Visual Studio projects including environment paths as well.

Application error - debug exe wont run

I've recently downloaded Assimp and I've run into some troubles.
I've linked the libraries and I can get the program to compile and it runs fine in Release mode; however, the Debug .exe hits me with this error:
The application was unable to start correctly (0xc0150002). Click OK to close the application.
Some more details:
I'm using VS2010 with Target Machine set to x86.
I am using the 32bit debug dll (Assimp32d.dll) that was provided, and I've tried setting runtime libraries to /MT, /MTd, /MD, and /MDd with no luck.
I read from other similar threads that I should run Dependency Walker on the .exe, but I'm not sure what the output means. I'll paste it here if this helps you guys.
Error: The Side-by-Side configuration information for "c:\users\-----\documents\visual studio 2010\projects\AssimpTest\debug\ASSIMP32D.DLL" contains errors. The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail (14001).
Error: At least one required implicit or forwarded dependency was not found.
Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module.
Error: Modules with different CPU types were found.
Rather than rebuilding the libraries, I downloaded a different set of libraries (it was the SDK installer) and the debug dll's from that are working perfectly.
Just in case anyone has the same problem with the same software, this was the exact name of the installer that worked for me: assimp-sdk-3.0-setup.exe
I ran into the same problem when trying to run a 64-bit project in Debug mode when using Assimp 3.0.
What I did was go to assimp/workspaces/vc9, open assimp.sln in Visual Studio 10, convert the project, then rebuild the 32 and 64-bit dll.
Mind you, you've got to install boost for that as well, and edit the project properties so it points to the boost directory for includes.
There's probably a way to do it using CMake as well, but I found the whole process too cumbersome to bother with in the first place.
My solution was just to link the debug build to the release .dll files. No more issues, and I wasn't that interested in debugging the Assimp library anyway!
I faced the same issue, later on I downloaded the "assimp-sdk-3.0-setup.exe" file & installed it as a standard windows application.
I pointed Visual Studio Solution Include & Lib directories to respective folders from newly installed location, copied DLL to my application location. The problem was resolved. Hope this helps someone.
Cheers.