Avatar of mjs2011
mjs2011
Flag for Saudi Arabia asked on

I Need assistance to resolve error message when compiled Project in Visual Studio 2019

I have a project on Visual Studio 2019 and using C/C++ open mp (Parallel) and openCV for image processing , When I tried to compile the project on Visual Studio 2019, I got two error messages
4.jpg
1.jpg
2.jpg
3.jpg
* ParallelsMicrosoft Visual Studio* Opencv

Avatar of undefined
Last Comment
MURUGESAN N

8/22/2022 - Mon
MURUGESAN N

@mjs2011
 
I am not having Windows visual studio.
Your project is missing the library opencv_world420d.dll

Example of using cygwin error:
$ echo murugesandins | awk '{ print $1}'
C:/cygwin/bin/gawk.exe: error while loading shared libraries: cyggmp-10.dll: cannot open shared object file: No such file or directory

Open in new window

cyggmp-10.dll installation has been missed here.
Hence After installing libgmp10 will resolve that issue.
Reason:
gawk.exe has been compiled using many *.dll files including cyggmp-10.dll

Sample dependencies for iexplore.exe
C:\Users\murugesandins>ldd C:\PROGRA~2\INTERN~1\iexplore.exe  | sed "s/\/cygdrive\/c/C:/;s/\//\\\\/g;s/(.*//;"
        ntdll.dll => C:\Windows\SYSTEM32\ntdll.dll
        ntdll.dll => C:\Windows\SysWOW64\ntdll.dll
        wow64.dll => C:\Windows\SYSTEM32\wow64.dll
        wow64win.dll => C:\Windows\SYSTEM32\wow64win.dll
        wow64cpu.dll => C:\Windows\SYSTEM32\wow64cpu.dll

C:\Users\murugesandins>

Open in new window

Like the same:
1. search where you are having the file opencv_world420d.dll in your system
Initially search that file using WinKeyF (windows find) or
we can search the same after opening
C:\Windows\System32\cmd.exe as Administrator
C:> DIR /S /B opencv_world420d.dll 2>NUL
D:> DIR /S /B opencv_world420d.dll 2>NUL
E:> DIR /S /B opencv_world420d.dll 2>NUL
...

Open in new window

2. If not found you have to download the source having opencv_world420d.dll
since the functions you are invoking are present at external dynamic link library (.dll) => (.dll being .so or .sl at other OS)
Once found or downloaded, add that dll file at project source libraries.
Since I do not have visual studio I cannot inform the way to add .dll at visual studio.
We used to make changes at Makefile at all OS (excluding visual studio including cygwin at windows)
mjs2011

ASKER
I did the below steps to guide visual studio where is a location for this file as below site . I already attached print screens for configuration in my question

Add opencv’s bin directory to path. If you’ve extracted the downloaded .exe file into c:\, the path to the bin directory should be c:\opencv\build\x64\vc15\bin

https://medium.com/@subwaymatch/adding-opencv-4-2-0-to-visual-studio-2019-project-in-windows-using-pre-built-binaries-93a851ed6141
MURUGESAN N

@mjs2011

I am from Linux oriented and not windows.
Used vlc.exe many years ago.
I have tried the following using cygwin at windows:

a)
$ cat opencv_world420d.cpp
#include <iostream>
using namespace std;
void ExternalFunFromLib()
{
	cout << "fun from opencv_world420d.dll\n";
}
$ /usr/bin/g++ -c -shared -Wall ./opencv_world420d.cpp -o ./opencv_world420d.o -std=c++11
$ /usr/bin/g++ -shared -o opencv_world420d.dll opencv_world420d.o
$ ldd "C:\\PROGRA~2\INTERN~1\IEXPLORE.EXE" | head -1 | awk '{ print $3}' | sed "s/\/cygdrive\/c/C:/;s/\//\\\\/g;"
C:\Windows\SYSTEM32\ntdll.dll
$ file $(ldd "C:\\PROGRA~2\INTERN~1\IEXPLORE.EXE" | head -1 | awk '{ print $3}' | sed "s/\/cygdrive\/c/C:/;s/\//\\\\/g;")
C:\Windows\SYSTEM32\ntdll.dll: PE32+ executable (DLL) (console) x86-64, for MS Windows
$ file ./opencv_world420d.dll
./opencv_world420d.dll: PE32+ executable (DLL) (console) x86-64, for MS Windows

Open in new window

Created the object file opencv_world420d.o
Using that object file created opencv_world420d.dll file
b)
$ cat ProjOpenCM.cpp
#include <iostream>
using namespace std;
extern void ExternalFunFromLib();
int main()
{
	cout << "hai\n";
	ExternalFunFromLib();
	return 0;
}
$ /usr/bin/g++ -Wall ./ProjOpenCM.cpp -o ./ProjOpenCM.exe -std=c++11 -L. -lopencv_world420d
$ file "C:\\PROGRA~2\INTERN~1\IEXPLORE.EXE"
C:\PROGRA~2\INTERN~1\IEXPLORE.EXE: PE32 executable (GUI) Intel 80386, for MS Windows
$ file ./ProjOpenCM.exe
./ProjOpenCM.exe: PE32+ executable (console) x86-64, for MS Windows

Open in new window

Compiled ProjOpenCM.cpp using the option -L. => take the library .dll from current directory .
Also creating ./ProjOpenCM.exe at current directory.
Current directory having the dll file also => -lopencv_world420d => opencv_world420d.dll

Hence ProjOpenCM.exe can use opencv_world420d.dll file when we start executing that.
Output at C:\Windows\System32\cmd.exe:
C:\Users\murugesandins\experts_exchange> DIR
 Volume in drive C is MURUGAN
 Volume Serial Number is 1603-C636

 Directory of C:\Users\murugesandins\experts_exchange

Sun 29-Mar-2020  12:41 PM    <DIR>          .
Sun 29-Mar-2020  12:41 PM    <DIR>          ..
Sun 29-Mar-2020  12:29 PM               119 opencv_world420d.cpp
Sun 29-Mar-2020  12:29 PM               141 ProjOpenCM.cpp
               2 File(s)            260 bytes
               2 Dir(s)  411,769,749,504 bytes free

C:\Users\murugesandins\experts_exchange> g++ -c -shared -Wall ./opencv_world420d
.cpp -o ./opencv_world420d.o -std=c++11

C:\Users\murugesandins\experts_exchange> g++ -shared -o opencv_world420d.dll ope
ncv_world420d.o

C:\Users\murugesandins\experts_exchange> g++ -Wall ./ProjOpenCM.cpp -o ./ProjOpe
nCM.exe -std=c++11 -L. -lopencv_world420d

C:\Users\murugesandins\experts_exchange> DIR
 Volume in drive C is MURUGAN
 Volume Serial Number is 1603-C636

 Directory of C:\Users\murugesandins\experts_exchange

Sun 29-Mar-2020  12:42 PM    <DIR>          .
Sun 29-Mar-2020  12:42 PM    <DIR>          ..
Sun 29-Mar-2020  12:29 PM               119 opencv_world420d.cpp
Sun 29-Mar-2020  12:42 PM           137,330 opencv_world420d.dll
Sun 29-Mar-2020  12:42 PM             2,329 opencv_world420d.o
Sun 29-Mar-2020  12:29 PM               141 ProjOpenCM.cpp
Sun 29-Mar-2020  12:42 PM           161,596 ProjOpenCM.exe
               5 File(s)        301,515 bytes
               2 Dir(s)  411,767,050,240 bytes free

C:\Users\murugesandins\experts_exchange>ProjOpenCM.exe
hai
fun from opencv_world420d.dll

C:\Users\murugesandins\experts_exchange>MOVE

C:\Users\murugesandins\experts_exchange> MOVE opencv_world420d.dll ..
        1 file(s) moved.

C:\Users\murugesandins\experts_exchange> ProjOpenCM.exe

C:\Users\murugesandins\experts_exchange>

Open in new window

Since I have moved opencv_world420d.dll and started executing ProjOpenCM.exe.
Reported similar error. (Attaching that error).
1)
Hence keep related dll at required directory.
2)
Hence keep related dll at microsoft visual studio ( I am not sure from menu since I used many years ago)

Comment I coped from:
https://stackoverflow.com/questions/4445418/how-to-add-additional-libraries-to-visual-studio-project
For Visual Studio you'll want to right click on your project in the solution explorer and then click on Properties.
Next open Configuration Properties and then Linker.
Now you want to add the folder you have the Allegro libraries in to Additional Library Directories,
Linker -> Input you'll add the actual library files under Additional Dependencies.
For the Header Files you'll also want to include their directories under C/C++ -> Additional Include Directories.
If there is a dll have a copy of it in your main project folder, and done.
I would recommend putting the Allegro files in the your project folder and then using local references in for the library and header directories.
Doing this will allow you to run the application on other computers without having to install Allergo on the other computer.
This was written for Visual Studio 2008. For 2010 it should be roughly the same.

Open in new window

opencv_world420d_error.jpg
Your help has saved me hundreds of hours of internet surfing.
fblack61
ASKER CERTIFIED SOLUTION
mjs2011

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
MURUGESAN N

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.