# Revision history [back]

### Getting the OpenCV library to work with C++

Hello everyone,

just a short heads-up: I have never used OpenCV and barely programmed outside of university classes (that means I know all the basic concepts like loops, data types, object orientation etc but I am having a hard time dealing with all the stuff that surrounds the coding like getting libraries to work, setting up frameworks, ...)

I have been trying to get OpenCV to work for hours now, but I just cannot do it. The first thing I did is downloading and extracting the current OCV - 3.4.1. I wanted to get it to work in Code Blocks and after some research I learned that there are 'source' files from which I can build 'binaries' (correct me if I got that wrong) to use in my IDE. And that I need cmake to generate those binaries. So I downloaded it and tinkered around with it for hours - it just wouldn't work. I always got an error message telling me that some DLL (libintl-8?) was missing - even though it was exactly where it needed to be, inside the MinGW folder. Creating an OpenCV-project with Code Block did not work at all for me, I got stuck with some error messages I can't quite remember after linking the OpenCV-folder.

After that I read that I would not need to create the binaries myself if I used Visual C++, so I decided to download it and give it a try. I set my project's propertysheet (I hope that's the english name for it, I'm using it in a different language) "Linker" -> "Additional Library directories" to C:\opencv\build and the "C/C++" -> "Additional Include directories" to C:\opencv\build\include. Lastly, under "Linker" -> "Input" -> "Additional dependencies" I entered "opencv_world341.lib", because the full list (as described here: https://docs.opencv.org/2.4/doc/tutorials/introduction/windows_visual_studio_Opencv/windows_visual_studio_Opencv.html) wouldn't work but it seems that this 'world' thing seems to contain all I need.

After typing #include, the IDE automatically suggests the opencv and opencv2 directories, so that seemed to work. However, after trying out the test-code from the link I posted above:

#include "stdafx.h"
#include "opencv2\core\core.hpp"
#include "opencv2\highgui\highgui.hpp"
#include <iostream>
#include ""

using namespace cv;
using namespace std;

int main(int argc, char** argv)
{
if (argc != 2)
{
cout << " Usage: display_image ImageToLoadAndDisplay" << endl;
return -1;
}

Mat image;

if (!image.data) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl;
return -1;
}

namedWindow("Display window", WINDOW_AUTOSIZE); // Create a window for display.
imshow("Display window", image); // Show our image inside it.

waitKey(0); // Wait for a keystroke in the window
return 0;
}


and run it, I get the following error:

1>------ Erstellen gestartet: Projekt: OpenCV_Test_Console, Konfiguration: Debug Win32 ------ 1>opencv_world341.lib(opencv_world341.dll) : fatal error LNK1112: Modul-Computertyp "x64" steht in Konflikt mit dem Zielcomputertyp "x86". 1>Die Erstellung des Projekts "OpenCV_Test_Console.vcxproj" ist abgeschlossen -- FEHLER. ========== Erstellen: 0 erfolgreich, 1 fehlerhaft, 0 aktuell, 0 übersprungen ==========

So there seems to be a conflict between the OpenCV's 64-bit-architecture and VC++ using a 32-bit-one? I just don't get it. There is no x86 folder in my opencv-directory.

I'm starting to feel desperate here because I already wasted so many hours and did not even start working on what I want to do with OpenCV. I consulted countless guides, FAQs, How-Tos and YouTube videos, but there is always something that wouldn't work for me, is completely different or just outdated.

Could someone please tell what I did wrong in my VC++ settings and how I get the lib to work? Thanks a lot in advance.

### Getting the OpenCV library to work with C++

Hello everyone,

just a short heads-up: I have never used OpenCV and barely programmed outside of university classes (that means I know all the basic concepts like loops, data types, object orientation etc but I am having a hard time dealing with all the stuff that surrounds the coding like getting libraries to work, setting up frameworks, ...)

I have been trying to get OpenCV to work for hours now, but I just cannot do it. The first thing I did is downloading and extracting the current OCV - 3.4.1. I wanted to get it to work in Code Blocks and after some research I learned that there are 'source' files from which I can build 'binaries' (correct me if I got that wrong) to use in my IDE. And that I need cmake to generate those binaries. So I downloaded it and tinkered around with it for hours - it just wouldn't work. I always got an error message telling me that some DLL (libintl-8?) was missing - even though it was exactly where it needed to be, inside the MinGW folder. Creating an OpenCV-project with Code Block did not work at all for me, I got stuck with some error messages I can't quite remember after linking the OpenCV-folder.

After that I read that I would not need to create the binaries myself if I used Visual C++, so I decided to download it and give it a try. I set my project's propertysheet (I hope that's the english name for it, I'm using it in a different language) "Linker" -> "Additional Library directories" to C:\opencv\build and the "C/C++" -> "Additional Include directories" to C:\opencv\build\include. Lastly, under "Linker" -> "Input" -> "Additional dependencies" I entered "opencv_world341.lib", because the full list (as described here: https://docs.opencv.org/2.4/doc/tutorials/introduction/windows_visual_studio_Opencv/windows_visual_studio_Opencv.html) wouldn't work but it seems that this 'world' thing seems to contain all I need.

After typing #include, the IDE automatically suggests the opencv and opencv2 directories, so that seemed to work. However, after trying out the test-code from the link I posted above:

#include "stdafx.h"
#include "opencv2\core\core.hpp"
#include "opencv2\highgui\highgui.hpp"
#include <iostream>
#include ""

using namespace cv;
using namespace std;

int main(int argc, char** argv)
{
if (argc != 2)
{
cout << " Usage: display_image ImageToLoadAndDisplay" << endl;
return -1;
}

Mat image;

if (!image.data) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl;
return -1;
}

namedWindow("Display window", WINDOW_AUTOSIZE); // Create a window for display.
imshow("Display window", image); // Show our image inside it.

waitKey(0); // Wait for a keystroke in the window
return 0;
}


and run it, I get the following error:

1>------ Erstellen gestartet: Projekt: OpenCV_Test_Console, Konfiguration: Debug Win32 ------ 1>opencv_world341.lib(opencv_world341.dll) : fatal error LNK1112: Modul-Computertyp "x64" steht in Konflikt mit dem Zielcomputertyp "x86". 1>Die Erstellung des Projekts "OpenCV_Test_Console.vcxproj" ist abgeschlossen -- FEHLER. ========== Erstellen: 0 erfolgreich, 1 fehlerhaft, 0 aktuell, 0 übersprungen ==========

So there seems to be a conflict between the OpenCV's 64-bit-architecture and VC++ using a 32-bit-one? I just don't get it. There is no x86 folder in my opencv-directory.

I'm starting to feel desperate here because I already wasted so many hours and did not even start working on what I want to do with OpenCV. I consulted countless guides, FAQs, How-Tos and YouTube videos, but there is always something that wouldn't work for me, is completely different or just outdated.

Could someone please tell what I did wrong in my VC++ settings and how I get the lib to work? Thanks a lot in advance.

### Getting the OpenCV library to work with C++

Hello everyone,

just a short heads-up: I have never used OpenCV and barely programmed outside of university classes (that means I know all the basic concepts like loops, data types, object orientation etc but I am having a hard time dealing with all the stuff that surrounds the coding like getting libraries to work, setting up frameworks, ...)

I have been trying to get OpenCV to work for hours now, but I just cannot do it. The first thing I did is downloading and extracting the current OCV - 3.4.1. I wanted to get it to work in Code Blocks and after some research I learned that there are 'source' files from which I can build 'binaries' (correct me if I got that wrong) to use in my IDE. And that I need cmake to generate those binaries. So I downloaded it and tinkered around with it for hours - it just wouldn't work. I always got an error message telling me that some DLL (libintl-8?) was missing - even though it was exactly where it needed to be, inside the MinGW folder. Creating an OpenCV-project with Code Block did not work at all for me, I got stuck with some error messages I can't quite remember after linking the OpenCV-folder.

After that I read that I would not need to create the binaries myself if I used Visual C++, so I decided to download it and give it a try. I set my project's propertysheet (I hope that's the english name for it, I'm using it in a different language) "Linker" -> "Additional Library directories" to C:\opencv\build and the "C/C++" -> "Additional Include directories" to C:\opencv\build\include. Lastly, under "Linker" -> "Input" -> "Additional dependencies" I entered "opencv_world341.lib", because the full list (as described here: https://docs.opencv.org/2.4/doc/tutorials/introduction/windows_visual_studio_Opencv/windows_visual_studio_Opencv.html) wouldn't work but it seems that this 'world' thing seems to contain all I need.

After typing #include, the IDE automatically suggests the opencv and opencv2 directories, so that seemed to work. However, after trying out the test-code from the link I posted above:

#include "stdafx.h"
#include "opencv2\core\core.hpp"
#include "opencv2\highgui\highgui.hpp"
#include <iostream>

using namespace cv;
using namespace std;

int main(int argc, char** argv)
{
if (argc != 2)
{
cout << " Usage: display_image ImageToLoadAndDisplay" << endl;
return -1;
}

Mat image;

if (!image.data) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl;
return -1;
}

namedWindow("Display window", WINDOW_AUTOSIZE); // Create a window for display.
imshow("Display window", image); // Show our image inside it.

waitKey(0); // Wait for a keystroke in the window
return 0;
}


and run it, I get the following error:

1>------ Erstellen gestartet: Projekt: OpenCV_Test_Console, Konfiguration: Debug Win32 ------ 1>opencv_world341.lib(opencv_world341.dll) : fatal error LNK1112: Modul-Computertyp "x64" steht in Konflikt mit dem Zielcomputertyp "x86". 1>Die Erstellung des Projekts "OpenCV_Test_Console.vcxproj" ist abgeschlossen -- FEHLER. ========== Erstellen: 0 erfolgreich, 1 fehlerhaft, 0 aktuell, 0 übersprungen ==========

So there seems to be a conflict between the OpenCV's 64-bit-architecture and VC++ using a 32-bit-one? I just don't get it. There is no x86 folder in my opencv-directory.

Update: after setting VS to x64, I get another error msg:

1>------ Erstellen gestartet: Projekt: OpenCV_Test_Console, Konfiguration: Debug x64 ------ 1>stdafx.cpp 1>OpenCV_Test_Console.cpp 1>OpenCV_Test_Console.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""void __cdecl cv::imshow(class cv::String const &,class cv::debug_build_guard::_InputArray const &)" (?imshow@cv@@YAXAEBVString@1@AEBV_InputArray@debug_build_guard@1@@Z)" in Funktion "main". 1>C:.......+\Projekte\OpenCV_Test_Console\x64\Debug\OpenCV_Test_Console.exe : fatal error LNK1120: 1 nicht aufgelöste Externe 1>Die Erstellung des Projekts "OpenCV_Test_Console.vcxproj" ist abgeschlossen -- FEHLER. ========== Erstellen: 0 erfolgreich, 1 fehlerhaft, 0 aktuell, 0 übersprungen ==========

I'm starting to feel desperate here because I already wasted so many hours and did not even start working on what I want to do with OpenCV. I consulted countless guides, FAQs, How-Tos and YouTube videos, but there is always something that wouldn't work for me, is completely different or just outdated.

Could someone please tell what I did wrong in my VC++ settings and how I get the lib to work? Thanks a lot in advance.