VS2010 can never find my DLLs - visual-studio-2010

I've tried all day to get VS2010 to run my program. I can only get the program to find the DLLs if I copy and paste them into the same folder as the output exe.
I have listed the folders containing the DLLs I need included under Linker > General. But running the program still gives me errors such as:
"The program can't start because tbb_debug.dll is missing from your computer. Try reinstalling the program to fix this problem."
What can be going wrong? I am trying to include 2 packages which have VS2010 DLL binaries; TBB (Intel package) and Open-CV (Which comes with both DLLs and LIB files). For the lib files I am also setting them as linker inputs, though the TBB package does not come with vs2010 lib files.
I am entering full paths in the Linker settings, such as: "C:\opencv\build\common\tbb\ia32\vc10", where each folder contains DLL files.

The linker is only looking for .lib files, which "point" the executable to the adresses of the functions in the dll. It has nothing to do where your executable will find the DLLs.
You need to have the DLL either in the directory of the exe - this is default search path, and is the simplest solution.
It gets slightly more complicated if you have different versions of DLLs installed which require side-by-side configuration. Then you need a manifest which tells your exe where to look for the dlls. Then you give the dll to the windows SxS cache.

Related

Executable is split to .lib and .exe

I'm trying to build from source the Qt Installer Framework (https://github.com/qtproject/installer-framework) and have a problem - some executables (e.g. archivegen) for unknown reason tries to be split to two different files - static library .lib and executable .exe. I don't know why is this could happen - there is a setting which is set to "Application (exe)", so where the ".lib" file has got from I don't know. I try to build it with MSVS 2019. Maybe somebody know the reason of the problem?

Linker Error When Changing Visual Studio Output to System32

For a research, I'm developing a Proxy DLL for nvcuda.dll (NVIDIA CUDA runtime) which resides in System32. To ease up debugging I change linker output to System32, however, I receive
LINK : fatal error LNK1104: cannot open file 'C:\Windows\System32\nvcuda.dll'
Here are the solutions I have tried:
Disabled the UAC.
Took ownership of System32 folder.
Ran the program as admin.
There are no white-spaces in the path to the file and no other program uses the DLL (it can be removed and renamed manually). The linker works fine for any other location, am I missing something?
EDIT:
An interesting observation is that I am able to build the same solution using msbuild as follows:
msbuild nvcuda.sln /p:Configuration=Debug /p:Platform=x64

C++ Program compiled with QT does not find automatically QT dlls in Windows

I have succesfully compiled a QT program for windows. I can not directly run the program in the build directory. The Dependency Walker shows that the paths to Qt5Gui.dll Qt5Widgets.dll Qt5Core.dll are not found. I am copying the dlls to the build directory and the program runs as expected. My question is how can I avoid copying the dlls in the build directory. Is there an option that I should add to the CMakeLists.txt to help in this situation ? I am using windows 10.

Visual Studios 2010 the program can't start because opencv_core243.dll is missing

I am learning how to use OpenCV and as practice I ran a program (in Release mode, x64). I had 0 compiler errors but got a pop-up screen that said:
"the program can't start because opencv_core243.dll is missing"
However, I made sure I declared the correct environment variables and specified the necessary libraries/directories. My problem was fixed when I copied the following .dll files into x64/Release:
opencv_core243.dll
opencv_highgui243.dll
opencv_imgproc243.dll
My program compiles fine now and works. However, I would like to know why. It feels cheap to copy and paste these .dll files. Did I miss a step where these .dll files would be generated automatically?
The actual solution for this problem is to append the path of opencv bin directory to the System PATH environment variable.
Have a look at this answer describing the complete procedure to install OpenCV in Visual Studio 2010.
There is a disadvantage of this approach. The prebuilt OpenCV x86 and x64 binaries have same names. So by appending the path of OpenCV to the PATH variable, you can execute either the 32 bit version or the 64 bit version at a time. To run the other version, you have to change the PATH variable.
An alternative to this, (my personal favorite) also involves copying the dlls to output directory, but this is done automatically at the end of compilation. What I do, is to create new environment variables for x86 and x64 dll paths. I create the User Variables CV_BIN32 and CV_BIN64 containing the paths of x86 and x64 dlls respectively.
After creating the User Variables, open your OpenCV project, go to Project Properties -> Build Events -> Post-Build Event -> Command Line.
Add the copy commands for the dlls you require at the runtime.
This one is for Win32 Release Configuration:
copy "$(CV_BIN32)\opencv_core243.dll" "$(OutDir)"
copy "$(CV_BIN32)\opencv_highgui243.dll" "$(OutDir)"
You can change them for all the 4 configurations, (Debug/Release),(Win32/x64)
Now when the project build procedure completes, the specified dlls will be copied to the output directory automatically, and the error will not be shown.

Visual Studio 2010 can't see /bin library of OpenCV

I'm trying to use OpenCv 2.2 in Visual Studio 2010.
I've configured everything by instruction:
http://opencv.willowgarage.com/wiki/VisualC%2B%2B
and by instruction from the book:
So I've added all /lib and /include paths.
When I build project, it compiles and before starting app, VS displays an error message that opencv_core220d.dll is missing.
This file is in C:/OpenCV2.2/bin as all .dll files. If I add this file to my working directory - it will be fine. Then VS displays error about every .dll file that I added in Linker-Input configuration ( but with .lib extension ).
So, if I add all .dlls file that I've added as .lib in Linker configuration - to my working directory, project will start.
But why? Why VC doesn't see OpenCV2.2/bin folder? Where is this pointed?
Because it doesn't know to look there by default. However, it does know to check the current directory for the DLLs.
You can tell it where to look by adding C:/OpenCV2.2/bin to your Path variable, or if you would rather not muck up your global Path you can set the Environment variable local to the C++ project.
I think that is the syntax for appending to the Path in VS2010, but I'm not sure, so Google it if that doesn't work :)

Resources