opencv_world341d.dll was not found error - c++

I am trying to run OpenCV on Visual Studios 2017. I built the libraries and bin with CMake, so far it is working good. However, when I try to run the code it says this:
This is the error code message that shows when I launch the "local windows debugger":
For some reason, it says that it can't find the DLL. I already assign the Aditional Dependencies in properties also I linked the "Included Directories" and "Included Libraries" to openCV in Visual Studios, the project is set to run in x64, and there are no errors on the programming it's just that error of DLL that shows.
The DLL can be found in a separate folder made by the compiler in a bin folder. However, it still says it can't be found.
This is the locations of the DLL files:
Is there a solution for this?
I tried to add pictures I'm new in the forum it doesn't let me post them yet. I am not sure if the ones I upload will show.
This is the code I tried to run and bring the error message. The same happen with any other code.
I will add more images that may help to understand what I did so far and thanks in advance for the help.
This are the Visual Studios C/C++ Directories:
This is the Linked section in Visual Studios properties:
This is the environment PATH from Environment Variables:
This is all I did so far in the process to install OpenCV in Visual Studios.
#include "stdafx.h"
#include <iostream>
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
int main() {
cv::Mat image;
std::cout << "This image is" << image.rows << "X" << image.cols << std::endl;
image = cv::imread("puppy.bmp");
if (image.empty()) {
}
cv::Mat result;
cv::flip(image, result, 1);
cv::waitKey(0);
return 0;
}

For me, restart to Visual Studio solved the problem, I guess that's because when I added the OpenCV to Environment Variable the Visual Studio was open

Just copy opencv_world341d.dll to the x64 debug folder, and run it.
I also restart my computer after I add it to PATH. So the solution is just restart your computer when you add to PATH for the first time

I've also faced this issue and solved it simply by adding the OpenCV bin path to the environment variable.

Related

cannot open include file 'Graphics.hpp' no such file or directory ,additional include for visual studio not working

i m trying to use sfml in my project using visual studio 2019. Following sfml documentation to perform setup for visual studio i have performed all the action required
i have included include folder in c/c++/additional include directory and also provided path for lib folder in linker setting and also provided additional dependencies in linker/input
but
#include <iostream>
#include <SFML/Graphics.hpp>
int main()
{
std::cout << "i cant tolerate" << std::endl;
return 0;
}
this code shows above mentioned error ,
cannot open include file 'Graphics.hpp' no such file or directory
it seems like include path is not working
how can i solve this issue
i tried many times but got same result
if anyone facing the same problem please check the platform in the project/properties win32 worked for my particular problem

LINK : fatal error LNK1181: cannot open input file 'opencv_world341d.lib'

I have found two similar questions this and this .
But they both use opencv, and opencv indeed provide the corresponding lib. I don't use opencv, and my project is very simple, just hello world.I have changed project default configuration like this
except for these configurations, others all take defaults
I just want to test my project configuration,that works find for win32 debug and release. But not work for x64 debug and release, they all tell me LINK : fatal error LNK1104: cannot open file 'opencv_world341d.lib'
I indeed know my project does not use any opencv lib, but why they tell me I need to use opencv_world341d.lib
my code
#include<iostream>
using namespace std;
int main()
{
cout << "hello world" << endl;
}
Thanks for everyone who comments on the question. I have solved the problem, although this problem not relevant to OpenCV to much, but I think the solution to the problem may be helpful to others. When I build project, visual studio 2019 tell me cannot link opencv_world341d.lib, so I go to Project->Properties->Linker->Input->Additional Dependencies , and I found opencv_world341d.lib. So I need to remove it, but it's readonly. From this we know visual studio using settings file (Microsoft.cpp..users.props) to control global settings including Global search path. These files are located at $(USERPROFILE)\appdata\local\microsoft\msbuild\v4.0 directory. Then I reedit Microsoft.cpp.<Platform>.users.props, delete opencv_world341d.lib, reboot visual studio, problem solved.

Struggling with libssh on Windows

The problem
I'm trying to build a project in Visual Studio 2015 on Win10 that makes use of libssh, but I'm having no luck getting it to work. I feel like I'm losing my mind here. I'm either completely blanking out or missing something incredibly obvious.
I've tried using the installer libssh-0.7.2-msvc.exe from the files section at https://red.libssh.org/projects/libssh/files. I then linked it to a test C++ project in VS2015. Using the sample code I'm able to compile it:
#include <iostream>
#define LIBSSH_STATIC
#include <libssh/libssh.h>
int main() {
std::cout << "Starting libssh test" << std::endl;
ssh_session my_ssh_session = ssh_new();
if (my_ssh_session == NULL) {
std::cout << "Failed to initialize" << std::endl;
}
ssh_free(my_ssh_session);
return 0;
}
(Note: I've tried both #define LIBSSH_STATIC and #define LIBSSH_STATIC 1 based on posts I've seen from my initial search for answers. I've even tried adding it to the preprocessor definitions in project properties.)
I can only compile it if my project is set to 32-bit, but I can't run the resulting executable. Doing so results in an error: "The code execution cannot proceed because ssh.dll was not found. Reinstalling the program may fix this problem." I'm statically linking ssh.lib, though, so I'm not sure why I'm even getting that error.
So I tried compiling libssh myself as 64-bit. It took some more tinkering than I expected (I had some issues with zlib, which eventually I just omitted since it's optional). I can compile my project as a 64-bit executable successfully, but once again, I can't actually run it. I get the same error about ssh.dll being missing.
For the sake of trying it, I removed the LIBSSH_STATIC define and tried to link just to the DLL. Copying the ssh.dll from the libssh distribution into my program folder and trying to run it, I get the error: "The application was unable to start correctly (0xc000007b). Click OK to close the application."
I'm not sure what I'm missing here, but I'm sure it's dumb and I'm overthinking it.
Project settings (all configurations, all platforms)
libssh is installed to G:\Libraries\libssh_0.7.2 on my machine.
Configuration Properties > VC++ Directories > Include Directories
G:\Libraries\libssh_0.7.2\include;$(IncludePath)
Configuration Properties > VC++ Directories > Library Directories
G:\Libraries\libssh_0.7.2\lib;$(LibraryPath)
Configuration Properties > Linker > Input > Additional Dependencies
ssh.lib;%(AdditionalDependencies)
libssh path summary
libssh_0.7.2
bin
ssh.dll
include
libssh
callbacks.h
legacy.h
libssh.h
libsshpp.hpp
server.h
sftp.h
ssh2.h
lib
ssh.lib
Install vkpkg
⊞ Win+X and open the powershell
Input vckpg install libssh:x64-windows
Integrate into Visual Studio: vcpkg integrate install
Then you can include <libssh.h> in Visual Studio.

many undefined functions in opencv 3.0.0 using visual studio 2013

I have just started out to learn opencv but facing many issues. i have installed opencv and linked it to visual studio 2013.
My first program which i copied from a video worked fine, which was
#include <cstdio>
#include <opencv2\opencv.hpp>
void main()
{
std::cout << "OpenCV Version: " << CV_VERSION << std::endl;
}
after this i created anew project and imported all the settings of the first project through import export settings option, but while compiling only it is showing many errors
#include <opencv/cv.h>
#include <opencv/highhui.h>
using namespace std;
using namespace cv;
int main(void)
{
Mat img = imread("C:/Users/shivamkumar07/Documents/Visual Studio 2013/Projects/ConsoleApplication2/shape.jpg");
imshow("inputfile", img);
img.release();
waitKey();
cvDestroyAllWindows();
return 0;
}
i am not able to understand why this is happening, please help me i am a beginner in this and not much tutorials are available on opencv 3.0.0
Thanks in advance!!
The first error is pretty clear, the compiler cannot find the file "opencv/cv.h" you included.
Try adding the correct folder to the include directories in the project settings.
After going through lots of stuff, i found out that i had not properly linked my opencv with this new project. That's why there were many undefined functions in my new project.
A better way to do this by using "Property sheet", once a property sheet is saved then it can be used in all of the new projects which you want.
steps to create Property Sheet
Right click on cpp file and add new items.
add property sheet here.
link opencv with your project by adding all the directories and lib files both in Release and Debug and save it by giving it some name.
steps to copy property sheet in new project
right click and click add existing item.
select the property sheet here and now the new project is linked with your opencv.
Thanks !
Clearly it has problem importing in that path. Try changing the path setting. Hope it helps.

OpenCV 2.3 and Visual Studio 2010

I am having so much trouble installing openCV 2.3 with visual studio 2010. Crash after crash, installation after installation and after several weeks I've had no luck.
Unfortunately there are no installation documents for openCV 2.3 and the directory structure and file locations are different from openCV 2.2 which makes the current tutorials almost useless. :(
Has anyone out there had any success with openCV 2.3? Can someone please try it and let me know if its an openCV build issue or my setup?
Or maybe someone can suggest an alternative to openCV. What my end goal is, is to get Pixel info, use inpaint functions, and basic image processing for After Effects and Maya.
EDIT: Sorry I thought I posed the error! This is what happens when I run the code:
#include <iostream>
#include <cv.h>
#include <highgui.h>
using namespace cv;
int main()
{
Mat image;
image = imread( "c:/image1.png", 1 );
namedWindow( "Gray image", CV_WINDOW_AUTOSIZE );
imshow( "Gray image", image );
waitKey(0);
return 0;
}
It runs until imshow. If I comment out imshow it runs fine with no errors.
Here is the errors when I add IMSHOW:
Unhandled exception at 0x76bfb727 in openCV_test.exe: Microsoft C++ exception: cv::Exception at memory location 0x0015ec20. and it gives me the option to break or continue.
This is what the output window shows:
First-chance exception at 0x76bfb727 in openCV_test.exe: Microsoft C++ exception: cv::Exception at memory location 0x0015ec20..
Unhandled exception at 0x76bfb727 in openCV_test.exe: Microsoft C++ exception: cv::Exception at memory location 0x0015ec20..
It then goes on to open SYSTEM.CPP and give me this:
- exc {msg="......\modules\core\src\array.cpp:2482: error: (-206) Unrecognized or unsupported array type
" code=-206 err="Unrecognized or unsupported array type" ...} const cv::Exception &
+ std::exception {_Mywhat=0x00000000 _Mydofree=false } std::exception
+ msg "......\modules\core\src\array.cpp:2482: error: (-206) Unrecognized or unsupported array type
" std::basic_string,std::allocator >
code -206 int
+ err "Unrecognized or unsupported array type" std::basic_string,std::allocator >
+ func "" std::basic_string,std::allocator >
+ file "......\modules\core\src\array.cpp" std::basic_string,std::allocator >
line 2482 int
Thanks!
I have OpenCV2.3 and had no problem to install it with Visual Studio v9.0.
What you should do to compile and run correctly your project in all the Visual Studio versions :
Properties of your project (right click on it)
C/C++
General
Include directory add the < your directory >\OpenCV2.3\include\opencv2, < your directory >\OpenCV2.3\include\opencv and < your directory >\OpenCV2.3\include
Linker
General
Add lib directory < your directory >\OpenCV2.3\lib
Input
Add all the libs like opencv_core230d.lib opencv_highgui230d.lib and so on...
Then don't forget to add the dll to your system path.
Configuration panel > System > Advanced > Environment variables > Path
you can add a user environment path which will override the other one,
just click New (if you have never added directory to your system path before) and write the path eg : < your directory >\OpenCV2.3\bin
Without more information, I hope it could help...
Julien,
Sometimes, the compiler cannot find the dll even if you have the correct path settings. At that point try copying the dll files from the openCV folder to ur current project (not solution) folder.
Rather than copy pasting I'll just link: http://theroundedengineer.blogspot.com/2011/07/opencv-23-for-vs-2008-from-source.html
Hopefully that helps. Granted I'm far from an expert on the differences between VS 2008 and VS 2010.
I got exactly the same problem. I couldn't read any image. I checked the data flag and image size. The flag indicated error and the size was always (0, 0). Although I do not know the actual cause, I somehow could avoid the problem and run my program fine.
At first, I compiled OpenCV myself. Even though all the dlls seemed to be created correctly and there was no build error, I noticed that the header folders are not correctly organized. Therefore, I switched to the superpack binary and tried static linking. There were a lot of undefined symbols at the beginning, so I basically just put everything into VS link options. The number of libraries I had to input to VS was quite absurd, but it is a good way to test if the superpack works.
These are what I use.
opencv_core230d.lib;opencv_calib3d230d.lib;opencv_contrib230d.lib;opencv_features2d230d.lib;opencv_highgui230d.lib;opencv_legacy230d.lib;opencv_ml230d.lib;opencv_imgproc230d.lib;opencv_video230d.lib;libjasperd.lib;libjpegd.lib;libpngd.lib;libtiffd.lib;zlibd.lib;
I also need to input Comctl32.lib to resolve linking error.
I tested my program with static libraries of superpack. Things work fine now.
The headers I used are
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
I do not try using dlls yet, but I can confirm that VS 2010 + OpenCV 2.3 64 bit from the superpack work. I hope you will have some luck with the superpack too.
(Hmm, I can't remember if I put opencv.hpp in the opencv2 folder myself, or if it was there right from the beginning. I did a lot of things to make it work and was a bit confused. But, I believe you can figure this out yourself if there is anything wrong about the header.)
Hope this helps,
Pinyo
You should try making a cycle structure:
#include <iostream>
#include <cv.h>
#include <highgui.h>
using namespace cv;
int main(){
Mat image;
namedWindow( "Gray image", 2 );
while(1){
image = imread( "d://Gaa6P.png", 1 );
imshow( "Gray image", image );
waitKey(0);
}
return 0;
}
Check your firewall. turn off firewall totally. Your antivirus may block the process too.
I had the same problem: cv::exception for memory and this was it's cause.