2

When I create a project visual studio 2015 I can work this libxl library hovewer I could not be able to work that library on visual studio qt gui application project.

I try everything whatever I know.

#include "stdafx.h"
#include "QtGuiApplication5.h"
#include <QtWidgets/QApplication>
#include <qapplication.h>
#include <qpushbutton.h>
#include <iostream>
#include <conio.h>
#include "libxl.h"
using namespacenclude <Qt libxl;
using namespace std;

int main(int argc, char *argv[])
{
    Book* book = xlCreateBook();

    if (book)
    {
        if (book->load(L"..\\Lab_Bus Datebase.xlsx"))
        {
            Sheet* sheet = book->getSheet(0);
            if (sheet)
            {
                const wchar_t* s = sheet->readStr(2, 1);
                if (s) std::wcout << s << std::endl << std::endl;
            }
        } 
        else
        {
            std::cout << "At first run generate !" << std::endl;
        }
        book->release();
    }
    std::cout << "\nPress any key to exit...";
    _getch();
    QApplication a(argc, argv);
    QtGuiApplication5 w;
    w.show();

    return a.exec();
}

Link2019 error: Severity Code Description Project File Line Suppression State Error LNK2019 unresolved external symbol __imp_xlCreateBookW referenced in function main QtGuiApplication5

link1120 error: Severity Code Description Project File Line Suppression State Error LNK1120 1 unresolved externals QtGuiApplication5 C

dascandy
  • 7,184
  • 1
  • 29
  • 50
Osman
  • 21
  • 2
  • an unresolved external symbol means there no definition found for used function. Maybe you are missing some lib to link. use `#pragma comment(lib, "libname.lib")` – Mayur May 07 '19 at 06:55
  • I took same errors. – Osman May 07 '19 at 07:22

1 Answers1

1

You need to configure visual studio project properties to use required lib. Refer this link for the same.

You are using .xlsx file so instead of xlCreateBook use xlCreateXMLBook. Apart from this you need to use using namespace libxl;as well

Below are Factory functions:

  • Book* xlCreateBook()
    Create a binary book instance for xls format. This function should be called first for receiving a book pointer. This function and other classes are in libxl namespace.
  • Book* xlCreateXMLBook()
    Create a xml book instance for xlsx format. This function should be called first for receiving a book pointer. This function and other classes are in libxl namespace.

See below image above code works fine at my machine. enter image description here

Mayur
  • 2,583
  • 16
  • 28
  • I did whatever need which write on reference page, It is not reletaed with xlsx, even if I delete whole code without first line I received same error like that int main(int argc, char *argv[]) { Book* book = xlCreateXMLBook(); return a.exec(); } – Osman May 07 '19 at 08:16
  • Are you sure you are using expected lib on your platform? eg. try to use x86 lib with x86 visual studio build environment – Mayur May 07 '19 at 08:22
  • well, I am trying same example on my system, let's see what will happen – Mayur May 07 '19 at 08:41
  • everything works fine at my end, I am getting data from sheet – Mayur May 07 '19 at 08:46
  • Probably you have misconfigured the project properties I guess. – Mayur May 07 '19 at 08:49
  • Thank you very much for your helping, my problem related with win32. – Osman May 07 '19 at 09:18