简体   繁体   English

C++ zbar 库 - 未解析的外部符号

[英]C++ zbar library - unresolved external symbol

I ran the following code for getting code feature for barcode using zbar library and set the properties for the project.我运行以下代码以使用 zbar 库获取条形码的代码功能并设置项目的属性。 I am getting errors such as unresolved external symbol error (LNK2019).我收到错误,例如未解决的外部符号错误 (LNK2019)。 How to resolve this error?如何解决此错误? The code for my program and the errors are attached below我的程序代码和错误附在下面

    #include <opencv2/opencv.hpp>
    #include <C:/Program Files/ZBar/include/zbar.h>
    using namespace cv;
    using namespace std;
    using namespace zbar;
    typedef struct
    {
      string type;
      string data;
      vector <Point> location;
    } decodedObject;

    // Find and decode barcodes and QR codes
    void decode(Mat& im, vector<decodedObject>& decodedObjects)
    {

      // Create zbar scanner
      ImageScanner scanner;

      // Configure scanner
      scanner.set_config(ZBAR_NONE, ZBAR_CFG_ENABLE, 1);

      // Convert image to grayscale
      Mat imGray;
      cvtColor(im, imGray, COLOR_BGR2GRAY);

      // Wrap image data in a zbar image
     Image image(im.cols, im.rows, "Y800", (uchar*)imGray.data, im.cols * im.rows);

     // Scan the image for barcodes and QRCodes
     int n = scanner.scan(image);

     // Print results
     for (Image::SymbolIterator symbol = image.symbol_begin(); symbol != image.symbol_end(); ++symbol)
     {
        decodedObject obj;

        obj.type = symbol->get_type_name();
        obj.data = symbol->get_data();

        // Print type and data
        cout << "Type : " << obj.type << endl;`
        cout << "Data : " << obj.data << endl << endl;

        // Obtain location
        for (int i = 0; i < symbol->get_location_size(); i++)
        {
            obj.location.push_back(Point(symbol->get_location_x(i), symbol->get_location_y(i)));
        }

        decodedObjects.push_back(obj);
    }
}

// Display barcode and QR code location  
void display(Mat& im, vector<decodedObject>& decodedObjects)
{
    // Loop over all decoded objects
    for (int i = 0; i < decodedObjects.size(); i++)
    {
        vector<Point> points = decodedObjects[i].location;
        vector<Point> hull;

        // If the points do not form a quad, find convex hull
        if (points.size() > 4)
            convexHull(points, hull);
        else
            hull = points;

        // Number of points in the convex hull
        int n = hull.size();

        for (int j = 0; j < n; j++)
        {
            line(im, hull[j], hull[(j + 1) % n], Scalar(255, 0, 0), 3);
        }

    }

    // Display results 
    imshow("Results", im);
    waitKey(0);

}

int main(int argc, char* argv[])
{

    // Read image
    Mat im = imread("zbar-test.jpg");

    // Variable for decoded objects 
    vector<decodedObject> decodedObjects;

    // Find and decode barcodes and QR codes
    decode(im, decodedObjects);

    // Display location 
    display(im, decodedObjects);

    return EXIT_SUCCESS;
}

The errors are as follows,错误如下,

错误

Your code runs OK!您的代码运行正常! You just need to refer the Zbar library on: Project Properties -> Linker -> Input -> C:\\opencv\\Zbar\\lib\\libzbar64-0.lib (for example)您只需要在以下位置引用 Zbar 库:项目属性 -> 链接器 -> 输入 -> C:\\opencv\\Zbar\\lib\\libzbar64-0.lib(例如)

With kind regards, PFG亲切的问候, PFG

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 C ++库中未解析的外部符号 - Unresolved external symbol in library in C++ MySQL Connector C ++无法解析的外部符号 - MySQL Connector C++ Unresolved External Symbol 来自一个项目中的静态库的未解析的外部符号,而不是另一个。 (C ++) - Unresolved external symbol from a static library in one project, not the other. (C++) Visual C ++无法解析的外部符号_Direct3DCreate9 @ 4 - Visual c++ unresolved external symbol _Direct3DCreate9@4 DLL注入编译“无法解析的外部符号” Visual Studio C ++ - DLL Injection Compilation “unresolved external symbol” Visual Studio C++ 如何解决visual c ++中“未解决的外部符号”链接错误? - How to solve the “unresolved external symbol” link error in visual c++? 将 Cython 扩展与 Windows 上的 C 库链接时出现“未解析的外部符号”-错误 - "unresolved external symbol"-error when linking a Cython extension against a C library on Windows Rust代码无法与在Windows上编译的C库链接,因为存在未解析的外部符号 - Rust code cannot link with a C library compiled on Windows because there is an unresolved external symbol Clrdump(C ++)错误LNK2019:函数_main中引用的未解析的外部符号__imp__RegisterFilter @ 8 - Clrdump (C++) error LNK2019: unresolved external symbol __imp__RegisterFilter@8 referenced in function _main C ++ cURL链接错误“未解析的外部符号_curl_easy_” - C++ cURL linking error “unresolved external symbol _curl_easy_”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM