OpenCV 2.4-致命错误LNK1104 [英] OpenCV 2.4 - fatal error LNK1104

查看:81
本文介绍了OpenCV 2.4-致命错误LNK1104的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我第一次使用Visual Studio Professional 2010进行GUI,是的,它涉及OpenCV.请看下面的代码

This is my first GUI attempt with Visual Studio Professional 2010, and yes, it involves OpenCV. Please have a look at the following code

GUI代码非常简单,仅包含一个按钮.

The GUI code is very simple, which only contains 1 button.

Form1.h

#pragma once
#include "ImageOpen.h"

namespace GUI {

    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 Form1
    /// </summary>
    public ref class Form1 : public System::Windows::Forms::Form
    {
    public:
        Form1(void)
        {
            InitializeComponent();
            //
            //TODO: Add the constructor code here
            //
        }

    protected:
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        ~Form1()
        {
            if (components)
            {
                delete components;
            }
        }
    private: System::Windows::Forms::Button^  button1;
    protected: 

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

#pragma region Windows Form Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        void InitializeComponent(void)
        {
            this->button1 = (gcnew System::Windows::Forms::Button());
            this->SuspendLayout();
            // 
            // button1
            // 
            this->button1->Location = System::Drawing::Point(27, 49);
            this->button1->Name = L"button1";
            this->button1->Size = System::Drawing::Size(75, 23);
            this->button1->TabIndex = 0;
            this->button1->Text = L"button1";
            this->button1->UseVisualStyleBackColor = true;
            this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
            // 
            // Form1
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->ClientSize = System::Drawing::Size(284, 262);
            this->Controls->Add(this->button1);
            this->Name = L"Form1";
            this->Text = L"Form1";
            this->ResumeLayout(false);


        }
#pragma endregion
    private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
                 ImageOpen i;
                 i.OpenImage();

             }
    };
}

Form1.cpp

//GUI.cpp:主项目文件.

// GUI.cpp : main project file.

#include "stdafx.h"
#include "Form1.h"

using namespace GUI;

[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
    // Enabling Windows XP visual effects before any controls are created
    Application::EnableVisualStyles();
    Application::SetCompatibleTextRenderingDefault(false); 

    // Create the main window and run it
    Application::Run(gcnew Form1());
    return 0;
}

ImageOpen.h

#pragma once
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>

using namespace std;
using namespace cv;

 class ImageOpen
{
public:
    ImageOpen(void);
    void OpenImage();
};

ImageOpen.cpp

#include "StdAfx.h"
#include "ImageOpen.h"


ImageOpen::ImageOpen(void)
{
}

void ImageOpen::OpenImage()
{
    Mat image = imread("C:/Users/Public/Pictures/Sample Pictures/Tulips.jpg");

    namedWindow("Image");
    imshow("Image",image);

    waitKey(0);
}

GUI如下所示很简单,因此我认为您甚至不必查看GUI代码

The GUI is simple as below, so I don't think you even have to look at the GUI code

不幸的是,运行此命令时,出现以下错误

Unfortunatly, when I run this, I get the following error

1>------ Build started: Project: GUI, Configuration: Debug Win32 ------
1>  stdafx.cpp
1>  AssemblyInfo.cpp
1>  GUI.cpp
1>  ImageOpen.cpp
1>  Generating Code...
1>LINK : fatal error LNK1104: cannot open file 'tbb_debug.lib'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

这也发生在VS 2010 Express中.为什么我会收到此错误?我在opencv中找不到tbb_debug.lib文件.我的opencv版本是2.4.请帮忙!

This happened in VS 2010 Express as well. Why I am getting this error? I can't find the tbb_debug.lib file in opencv. My opencv version is 2.4. Please help!

更新

此链接 OpenCV和VS2010:致命错误LNK1104:源错误LNK1104:无法打开文件'tbb_debug.lib 建议我们需要将公共语言运行时支持更改为无公共语言运行时支持.

This link OpenCV and VS2010: Fatal error LNK1104: atal error LNK1104: cannot open file 'tbb_debug.lib suggests that we need to change the common language runtime support to no common language run time support.

然后我收到此错误

1>------ Build started: Project: GUI, Configuration: Debug Win32 ------
1>  stdafx.cpp
1>  ImageOpen.cpp
1>  GUI.cpp
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\form1.h(6): error C2871: 'System' : a namespace with this name does not exist
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\form1.h(7): error C2653: 'System' : is not a class or namespace name
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\form1.h(7): error C2871: 'ComponentModel' : a namespace with this name does not exist
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\form1.h(8): error C2653: 'System' : is not a class or namespace name
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\form1.h(8): error C2871: 'Collections' : a namespace with this name does not exist
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\form1.h(9): error C2653: 'System' : is not a class or namespace name
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\form1.h(9): error C2871: 'Forms' : a namespace with this name does not exist
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\form1.h(10): error C2653: 'System' : is not a class or namespace name
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\form1.h(10): error C2871: 'Data' : a namespace with this name does not exist
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\form1.h(11): error C2653: 'System' : is not a class or namespace name
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\form1.h(11): error C2871: 'Drawing' : a namespace with this name does not exist
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\form1.h(16): error C2059: syntax error : 'public'
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\form1.h(16): error C2059: syntax error : 'public'
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\form1.h(16): error C2653: 'System' : is not a class or namespace name
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\form1.h(17): error C2143: syntax error : missing ';' before '{'
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\form1.h(17): error C2447: '{' : missing function header (old-style formal list?)
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\gui.cpp(8): error C2337: 'STAThreadAttribute' : attribute not found
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\gui.cpp(9): error C2065: 'array' : undeclared identifier
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\gui.cpp(9): error C2653: 'System' : is not a class or namespace name
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\gui.cpp(9): error C2275: 'cv::String' : illegal use of this type as an expression
1>          c:\opencv\build\include\opencv2\core\core.hpp(87) : see declaration of 'cv::String'
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\gui.cpp(9): error C2059: syntax error : '>'
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\gui.cpp(10): error C2143: syntax error : missing ';' before '{'
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\gui.cpp(10): error C2447: '{' : missing function header (old-style formal list?)
1>  AssemblyInfo.cpp
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\assemblyinfo.cpp(3): error C2871: 'System' : a namespace with this name does not exist
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\assemblyinfo.cpp(4): error C2653: 'System' : is not a class or namespace name
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\assemblyinfo.cpp(4): error C2871: 'Reflection' : a namespace with this name does not exist
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\assemblyinfo.cpp(5): error C2653: 'System' : is not a class or namespace name
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\assemblyinfo.cpp(5): error C2871: 'CompilerServices' : a namespace with this name does not exist
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\assemblyinfo.cpp(6): error C2653: 'System' : is not a class or namespace name
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\assemblyinfo.cpp(6): error C2871: 'InteropServices' : a namespace with this name does not exist
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\assemblyinfo.cpp(7): error C2653: 'System' : is not a class or namespace name
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\assemblyinfo.cpp(7): error C2871: 'Permissions' : a namespace with this name does not exist
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\assemblyinfo.cpp(14): error C2337: 'AssemblyTitleAttribute' : attribute not found
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\assemblyinfo.cpp(15): error C2337: 'AssemblyDescriptionAttribute' : attribute not found
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\assemblyinfo.cpp(16): error C2337: 'AssemblyConfigurationAttribute' : attribute not found
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\assemblyinfo.cpp(17): error C2337: 'AssemblyCompanyAttribute' : attribute not found
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\assemblyinfo.cpp(18): error C2337: 'AssemblyProductAttribute' : attribute not found
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\assemblyinfo.cpp(19): error C2337: 'AssemblyCopyrightAttribute' : attribute not found
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\assemblyinfo.cpp(20): error C2337: 'AssemblyTrademarkAttribute' : attribute not found
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\assemblyinfo.cpp(21): error C2337: 'AssemblyCultureAttribute' : attribute not found
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\assemblyinfo.cpp(34): error C2337: 'AssemblyVersionAttribute' : attribute not found
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\assemblyinfo.cpp(36): error C2337: 'ComVisible' : attribute not found
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\assemblyinfo.cpp(38): error C2337: 'CLSCompliantAttribute' : attribute not found
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\assemblyinfo.cpp(40): error C2337: 'SecurityPermission' : attribute not found
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\assemblyinfo.cpp(40): error C2653: 'SecurityAction' : is not a class or namespace name
1>c:\users\yohan\documents\visual studio 2010\projects\gui\gui\assemblyinfo.cpp(40): error C2065: 'RequestMinimum' : undeclared identifier
1>          missing quotes ("") around 'RequestMinimum'?
1>  Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

推荐答案

如链接中所建议:您可以在配置"属性->常规"->公共语言运行时"中将公共语言运行时支持(/clr)"更改为无公共语言运行时支持".

You can change Common Language Runtime Support (/clr) to No Common Language Runtime Support in Configuration properties-> General->Common Language Runtime.

您还没有在Form1.h

这篇关于OpenCV 2.4-致命错误LNK1104的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆