moving a opencv visual studio project - c++

I have been working on a opencv project with visual studio 2013 and the version of opencv is 2.4.8. The problem I am having is when I move the .exe file that is produced from the visual studio to another location it complains about not finding the .dll files from the opencv library, which are located in C:\opencv directory. Here is the error message:
System error: The Program can't start because opencv_core248d.dll is missing from your
computer. Try reinstalling the program to fix this problem.
thank you in advance for your help.

You either need to add the directory that contains all those dlls to your system PATH, or put all those needed dlls in the same directory as the executable(or your executable where your dlls are located). They are DYNAMIC libraries, so the program needs access to them when it tries to execute.

Related

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

C++ executable only starts from Visual Studio

I have a program written in C++ which is compiled with Visual Studio 2013. It also uses Qt5. I can start the program from Visual Studio (debug/release), but if I try to start the .exe file outside of VS nothing happens. My assumption was that it's missing DLL files. According to "dumpbin /dependents" I need these DLLs:
File Type: EXECUTABLE IMAGE
Image has the following dependencies:
Qt5OpenGL.dll
Qt5Gui.dll
Qt5Widgets.dll
Qt5Core.dll
MSVCP120.dll
MSVCR120.dll
KERNEL32.dll
SHELL32.dll
I have those lying in the same directory as the .exe file. I copied msvcp120.dll and msvcr120.dll from "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\redist\x86\Microsoft.VC120.CRT" and the Qt5 DLLs from "C:\Qt\5.4\msvc2013\bin".
What am I doing wrong? I'm new to C++, so I'm probably missing some knowledge here.
My .exe was missing 3 DLLs: icudt53.dll, icuin53.dll, icuuc53.dll. "Dependency Walker" was actually showing them as missing, but I misinterpreted what it meant and thought they aren't on my system at all. But they can be found in $(QTDIR)\bin and my VS project added that path to the PATH variable, so in VS the DLLs weren't missing.
EDIT: It's actually way easier just to do this from the command line:
windeployqt C:\Path\To\My.exe
It will copy all needed DLLs into the .exe folder. It's even more DLLs than I thought. For example "qwindows.dll" is needed if you want to deploy the program on a machine without Qt.

I can't link my Visual Studio 2010 project with Poco C++ libraries

I'm trying to use Poco C++ library in a Visual Studio 2010 project. I've done everything that is specified in these instructions, but still getting an error when I try to execute my code, because PocoFoundation.dll can't be found. I've checked that the DLL is where I tell Visual Studio to find it, but still getting same error
I am assuming the error is "dll-name.dll is not found"
The instructions posted, in the link you've provided, are for static linking of the poco libraries.
DLL's are linked at the runtime of the executable, where as the instructions tell you how to compile the program successfully
You have to tell OS and not Visual studio where to look for the DLL.
Search path for DLL -specifies where the OS looks for DLL and in what order
The link tells you the order which is roughly the following :
1) Directory in which the executable resides.
2) The current directory ( i.e working directory if you are running the executable from visual studio)
3)Windows system directory ( you don't want to add anything manually here)
4)Windows directory ( same as above , don't tinker with this one as well)
5)All the locations specified using PATH variable ( NOTE: PATH can be set using this from visual studio or can be set through control panel as well)
So two ways to solve the problem :
1)your dll-name.dll should reside in any of the specified folders above.
Or
2) if your dll is in folder C:\path\where\dll\is\
set PATH = PATH;C:\patj\where\dll\is

SDL.dll is missing from my computer - VS 2010

I'm trying to compile a SDL-program I've written, but when I do, this error shows up:
The program can't start because SDL.dll is missing from your computer.
Try reinstalling the program to fix this problem
I have no idea as to why. I have SDL.dll.
I have put it in the correct folder: C:\Windows\System32.
I have the correct PATHS to all the SDL headers and such as well.
VS says:
Build succeeded: 1
and THEN the error above pops up on screen.
Add it into your debug folder or whatever directory your program is currently located at.
SDL.dll has to either be in the same directory as your application, or in a directory that's in the PATH environment variable.
IfSDL.dll is 32-bit and you're running a 64-bit system you have to place the dll into /Windows/SysWOW64/ rather than /Windows/System32/, which is used for 64-bit dlls.
EDIT:
You probably shouldn't be deploying your DLLs by copying them into the System32 directory, unless they're common libraries that are used by several applications, and even then I would use discretion. For example, an application could update the DLL, which could break other applications that rely on an older version of the library.
Instead, copy the DLLs into the same directory that the executable is being built in. If you're building and executing with Visual Studio it will look for the DLL in the Project directory, where your source files are probably located.
Just place your SDL.dll in the same folder and your problem will be solved.
And to answer to your problem with the PATH, you can specify in visual studio where he will look for executables while debugging. Maybe this isn't set correctly and that's why VS can't find SDL.dll?

glew32.dll run time error

I successfully compiled my OpenGL program in MSVC 2008, But I am getting a Run time error as follows
"This application has failed to start because glew32.dll was not found. Re-installing the application may fix this problem."
I have no idea how you managed to link the object files without the GLEW .lib file. Have you downloaded the GLEW library and put the .DLL file in the wrong place, perhaps? The .DLL file should be in the same directory as your OpenGL application that uses it, or in your Windows directory.
Also note that if you launch the application from within Visual Studio, it looks for the .DLL files in the project directory instead of the release/debug directories.
Try putting the file glew32.dll into the same directory as the binary exe that you compiled.