Author Topic: OpenCV error in code::blocks  (Read 354 times)

Offline jhongramaticus

  • Single posting newcomer
  • *
  • Posts: 2
OpenCV error in code::blocks
« on: Yesterday at 09:49:54 am »
I'm trying to use OpenCV (version 4.12.0) in Code::Blocks (version 25.03). When installing OpenCV, I used CMake to generate the libraries in Code::Blocks and Mingw. Once I obtained openCV.cbp, I compiled it in Code::Blocks to generate the libraries. After that, I opened code::blocks<<file<<new<<project<<openCV project<< next<<next<<next<< and I got the following error:
 
Code
the lib path you entered seems invalid, can't find files C:\opencv\build\x86\mingw\lib\libopencv_core121.dll.a or C:\opencv\build\x86\mingw\lib\libopencv_core121d.dll.a 

I created the x86<<mingw folder so that cmake would generate the files in that location. Despite searching for help on Stack Overflow and other sites, I found no answers. I renamed the library libopencv_core4120.dll to libopencv_core121d.dll.a and it worked fine until yesterday. Now I've deleted code::blocks and OpenCV, regenerated the libraries, and when I try to use any program that has an OpenCV library, I get the message:

Code
"Code execution cannot continue because libopencv:core4110.dll was not found. This problem can be solved by reinstalling the program." I got the same message for libopencv_imgcodecs4120.dll and also libopencv_imgproc4120.dll.


Before attempting to create code using OpenCV's Code::Blocks project, I added it only to Settings <<Compiler <<Linker Settings and the directory to Settings <<Compiler <<Search Directories. I've since removed everything, but I'm still getting the same errors, both when creating a project using OpenCV's code::blocks<<file<<new<<project<<openCV project<< next<<next<<next<< and when creating a regular file just mentioning the OpenCV libraries. Sometimes, even a simple "Hello World" code won't compile because of these OpenCV problems.
« Last Edit: Yesterday at 04:22:41 pm by jhongramaticus »

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1855
Re: OpenCV error in code::blocks
« Reply #1 on: Yesterday at 10:11:30 am »
There is a double backslash in the search path:

Code
mingw\\lib\libopen

Offline jhongramaticus

  • Single posting newcomer
  • *
  • Posts: 2
Re: OpenCV error in code::blocks
« Reply #2 on: Yesterday at 04:24:10 pm »
Fixed, thank you

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1855
Re: OpenCV error in code::blocks
« Reply #3 on: Yesterday at 06:38:43 pm »
Did you fix it in the project or only in the post?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7830
    • My Best Post
Re: OpenCV error in code::blocks
« Reply #4 on: Yesterday at 10:40:47 pm »
Something to try is
Project -> Build Settings
Select the project in left hand window
Linker Settings
Then remove the version variable of "CV_VERSION" also remove the "$" sign and braces before and after.

I then got an error I did not understand.

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7830
    • My Best Post
Re: OpenCV error in code::blocks
« Reply #5 on: Yesterday at 11:32:20 pm »
Rereading your message implies that the error is during the wizard.

Right click on the wizard and you can edit it.

You need to state what are the names and path to the DLLs and DDL import libs:

I edited the wizard for me by removing [_T("\\libopencv_core") +].

Code
        local test_release_lib_file = lib_nomacro + _T("\\libopencv_core") + VersionString + _T(".dll.a");
        local test_debug_lib_file = lib_nomacro + _T("\\libopencv_core") + VersionString + _T("d.dll.a");

But that was because the import library did not have the version in it.

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org