Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

using opencv with c++ .net application compilation issues

I didn't face any issues while linking opencv library with basic console application but when I moved to do the same in a .net framework template I got many LNK errors

image description

I didn't do anything strange except that I included the include and using namespace only.

I appreciate any assistance provided.. Thanks.

using opencv with c++ .net application compilation issues

I didn't face any issues while linking opencv library with basic console application but when I moved to do the same in a .net framework template I got many LNK errors

image description

I didn't do anything strange except that I included the include and using namespace only.

I appreciate any assistance provided.. Thanks.provided

PS: I managed to run it if I install the opencv package via NuGet but I don't wan't to use NuGet.

using opencv with c++ .net application compilation issues

I didn't face any issues while linking opencv library with basic console application but when I moved to do the same in a .net framework template I got many LNK errors

image description

I didn't do anything strange except that I included the include and using namespace only.

I appreciate any assistance provided

PS: I managed to run it if I install the opencv package via NuGet but I don't wan't to use NuGet.NuGet. (I tried to get frames from video but it is not working and I get an unhalded error while the same code is running with console without an issue)

This is a clean Form header. Whenever I place the include tags of opencv I will not be able to compile:

include "opencv2/objdetect/objdetect.hpp"
include "opencv2/highgui/highgui.hpp"
include "opencv2/imgproc/imgproc.hpp"
include opencv2/ml.hpp
include ctime



namespace VisionApp01
{
    using namespace cv;
    using namespace cv::ml;

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;

/// <summary>
/// Summary for MyForm
/// </summary>
public ref class MyForm : public System::Windows::Forms::Form
{
public:
    MyForm(void)
    {
        InitializeComponent();
        //
        //TODO: Add the constructor code here
        //
    }

protected:
    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    ~MyForm()
    {
        if (components)
        {
            delete components;
        }
    }
private: System::Windows::Forms::PictureBox^  beforeBox;
private: System::Windows::Forms::PictureBox^  afterBox;
protected:


protected:

private:
    /// <summary>
    /// Required designer variable.
    /// </summary>
    System::ComponentModel::Container ^components;


    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    void InitializeComponent(void)
    {
        this->beforeBox = (gcnew System::Windows::Forms::PictureBox());
        this->afterBox = (gcnew System::Windows::Forms::PictureBox());
        (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->beforeBox))->BeginInit();
        (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->afterBox))->BeginInit();
        this->SuspendLayout();
        // 
        // beforeBox
        // 
        this->beforeBox->Location = System::Drawing::Point(12, 12);
        this->beforeBox->Name = L"beforeBox";
        this->beforeBox->Size = System::Drawing::Size(300, 300);
        this->beforeBox->TabIndex = 0;
        this->beforeBox->TabStop = false;
        // 
        // afterBox
        // 
        this->afterBox->Location = System::Drawing::Point(353, 12);
        this->afterBox->Name = L"afterBox";
        this->afterBox->Size = System::Drawing::Size(300, 300);
        this->afterBox->TabIndex = 0;
        this->afterBox->TabStop = false;
        // 
        // MyForm
        // 
        this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
        this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
        this->ClientSize = System::Drawing::Size(665, 330);
        this->Controls->Add(this->afterBox);
        this->Controls->Add(this->beforeBox);
        this->Name = L"MyForm";
        this->Text = L"MyForm";
        this->Load += gcnew System::EventHandler(this, &MyForm::MyForm_Load);
        (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->beforeBox))->EndInit();
        (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->afterBox))->EndInit();
        this->ResumeLayout(false);

    }





private: System::Void MyForm_Load(System::Object^  sender, System::EventArgs^  e)
{


}


};

}

using opencv with c++ .net application compilation issues

I didn't face any issues while linking opencv library with basic console application but when I moved to do the same in a .net framework template I got many LNK errors

image description

I didn't do anything strange except that I included the include and using namespace only.

I appreciate any assistance provided

PS: I managed to run it if I install the opencv package via NuGet but I don't wan't to use NuGet. (I tried to get frames from video but it is not working and I get an unhalded error while the same code is running with console without an issue)

This is a clean Form header. Whenever I place the include tags of opencv I will not be able to compile:

include "opencv2/objdetect/objdetect.hpp"
include "opencv2/highgui/highgui.hpp"
include "opencv2/imgproc/imgproc.hpp"
include opencv2/ml.hpp
include ctime

 namespace VisionApp01
{
    using namespace cv;
    using namespace cv::ml;
    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms;
    using namespace System::Data;
    using namespace System::Drawing;
 
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;

/// <summary>
/// Summary for MyForm
/// </summary>
public ref class MyForm : public System::Windows::Forms::Form
{
public:
    MyForm(void)
    {
        InitializeComponent();
        //
        //TODO: Add the constructor code here
        //
    }

protected:
    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    ~MyForm()
    {
        if (components)
        {
            delete components;
        }
    }
private: System::Windows::Forms::PictureBox^  beforeBox;
private: System::Windows::Forms::PictureBox^  afterBox;
protected:

 protected:

private:
    /// <summary>
    /// Required designer variable.
    /// </summary>
    System::ComponentModel::Container ^components;


    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    void InitializeComponent(void)
    {
        this->beforeBox = (gcnew System::Windows::Forms::PictureBox());
        this->afterBox = (gcnew System::Windows::Forms::PictureBox());
        (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->beforeBox))->BeginInit();
        (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->afterBox))->BeginInit();
        this->SuspendLayout();
        // 
        // beforeBox
        // 
        this->beforeBox->Location = System::Drawing::Point(12, 12);
        this->beforeBox->Name = L"beforeBox";
        this->beforeBox->Size = System::Drawing::Size(300, 300);
        this->beforeBox->TabIndex = 0;
        this->beforeBox->TabStop = false;
        // 
        // afterBox
        // 
        this->afterBox->Location = System::Drawing::Point(353, 12);
        this->afterBox->Name = L"afterBox";
        this->afterBox->Size = System::Drawing::Size(300, 300);
        this->afterBox->TabIndex = 0;
        this->afterBox->TabStop = false;
        // 
        // MyForm
        // 
        this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
        this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
        this->ClientSize = System::Drawing::Size(665, 330);
        this->Controls->Add(this->afterBox);
        this->Controls->Add(this->beforeBox);
        this->Name = L"MyForm";
        this->Text = L"MyForm";
        this->Load += gcnew System::EventHandler(this, &MyForm::MyForm_Load);
        (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->beforeBox))->EndInit();
        (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->afterBox))->EndInit();
        this->ResumeLayout(false);

    }

 private: System::Void MyForm_Load(System::Object^  sender, System::EventArgs^  e)
{

 }
 };

}

}