Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8051213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:15:14+00:00 2026-06-05T07:15:14+00:00

How do I install OpenCV 2.4 and compile my code with MinGW?

  • 0

How do I install OpenCV 2.4 and compile my code with MinGW?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:15:15+00:00Added an answer on June 5, 2026 at 7:15 am

    1. Installing OpenCV 2.4.3

    First, get OpenCV 2.4.3 from sourceforge.net. Its a self-file-extracting so just double click the file to start installation. Install it in a directory, say C:\.

    OpenCV self-extracting

    Wait until all files get extracted. It will create a new
    directory C:\opencv which contains OpenCV header files, libraries, code samples, etc.

    Now you need to add C:\opencv\build\x86\mingw\bin directory to your system PATH. This directory contains OpenCV DLLs which is required for running your code.

    Open Control Panel → System → Advanced system settings → Advanced Tab → Environment variables…

    You will see a window like shown below:

    Add OpenCV DLL directory to system path

    On the System Variables section,
    select Path (1), click Edit… (2), add C:\opencv\build\x86\mingw\bin (3) then click Ok.

    This will completes the OpenCV 2.4.3 installation on your computer.


    2. Installing MinGW compiler suite

    I highly recommend you to use gcc (GNU Compiler Collection) for compiling your code. gcc is the compiler suite widely available in Linux systems and MinGW is the native port for Windows.

    Download the MinGW installer from Sourceforge.net and double click to start installation. Just follow the wizard and select the directory to be installed, say C:\MinGW.

    Select directory in MinGW installation

    Select “C Compiler” and “C++ Compiler” to be installed.

    Select components to be installed

    The installer will download some packages from the internet so you have to wait for a while. After the installation finished, add C:\MinGW\bin to your system path using the steps described before.

    Add MinGW bin directory to system path

    To test if your MinGW installation is success, open a command-line box and type: gcc. If everything is ok, it will display this message:

    gcc: fatal error: no input files
    compilation terminated
    

    This completes the MinGW installation, now is the time to write your “Hello, World!” program.


    3. Write a sample code

    Open your text editor and type the code below and save the file to loadimg.cpp.

    #include "opencv2/highgui/highgui.hpp"
    #include <iostream>
    
    using namespace cv;
    using namespace std;
    
    int main(int argc, char** argv)
    {
      Mat im = imread(argc == 2 ? argv[1] : "lena.jpg", 1);
      if (im.empty())
      {
        cout << "Cannot open image!" << endl;
        return -1;
      }
    
      imshow("image", im);
      waitKey(0);
    
      return 0;
    }
    

    Put lena.jpg or any image you like in the same directory with the file above. Open a command-line box and compile the code above by typing:

    g++ -I"C:\opencv\build\include" -L"C:\opencv\build\x86\mingw\lib" loadimg.cpp -lopencv_core243 -lopencv_highgui243 -o loadimg
    

    If it compiles successfully, it will create an executable named loadimg.exe.

    Type:

    loadimg
    

    To execute the program. Result:

    The result of your first OpenCV program


    4. Where to go from here?

    Now that your OpenCV environment is ready, what’s next?

    1. Go to the samples dir → C:\opencv\samples\cpp.
    2. Read and compile some code.
    3. Write your own code.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to compile/build OPenCV 2.3 with the help of CMake/Mingw. I got
I'm trying to install openCV on university's iMac, but the problem is our university's
I am trying since two days to install OpenCV 2.3.0 or 2.3.1 on my
if we do sudo port install opencv it works fine but it installs in
I install antlr in my eclipse. And set antlr-code generator-output folder-project relative folder as
What packages do I need to install OpenCV on Ubuntu lucid 10.04 ? Do
I am trying to install OpenCV on my Mac (OS X v10.6.3) for use
I was trying to install a module for opencv and added an opencv.pth file
I want to compile OpenCV with same zlib as I use for compilation of
I am trying to install OpenCV over windows vista 64x but it's shows a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.