1

Part of my school project I need to work with LabWindows/CVI.

I need to read a xlsx file and analize it.

I download this libxl library.

I amported the h files and the lib files. this is my code ( I coppied it from here):

#include <cvirte.h>     
#include <userint.h>
#include <formatio.h>
#include "Final work.h"
#include "libxl.h"


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

static int panelHandle;

int readFile()
{
    BookHandle book = xlCreateBook(); // xlCreateXMLBook()
    if (xlBookLoad(book, "G:/Electro data/0.5_time_all.xlsx")){
        return 0;   
    }
    if(book) 
    {
        SheetHandle sheet = xlBookAddSheet(book, L"Sheet1", 0);
        if(sheet) 
        {
            xlSheetWriteStr(sheet, 2, 1, L"Hello, World !", NULL);
            xlSheetWriteNum(sheet, 3, 1, 1000, NULL);
        }
        xlBookSave(book, L"example.xls");
        xlBookRelease(book);
    }
    
    return 0;
}

and I am getting this errors: Build Status (Final work.prj - Debug) Final work.c - 3 warnings

error: Undefined symbol '_xlBookAddSheetA' referenced in "c:\Users\USER\Documents\National Instruments\CVI\cvibuild.Final work\Debug\Final work.obj".

error: Undefined symbol '_xlBookLoadA' referenced in "c:\Users\USER\Documents\National Instruments\CVI\cvibuild.Final work\Debug\Final work.obj".

error: Undefined symbol '_xlBookReleaseA' referenced in "c:\Users\USER\Documents\National Instruments\CVI\cvibuild.Final work\Debug\Final work.obj".

error: Undefined symbol '_xlBookSaveA' referenced in "c:\Users\USER\Documents\National Instruments\CVI\cvibuild.Final work\Debug\Final work.obj".

error: Undefined symbol '_xlCreateBookCA' referenced in "c:\Users\USER\Documents\National Instruments\CVI\cvibuild.Final work\Debug\Final work.obj".

error: Undefined symbol '_xlSheetWriteNumA' referenced in "c:\Users\USER\Documents\National Instruments\CVI\cvibuild.Final work\Debug\Final work.obj".

error: Undefined symbol '_xlSheetWriteStrA' referenced in "c:\Users\USER\Documents\National Instruments\CVI\cvibuild.Final work\Debug\Final work.obj".

Build failed.

here is an image to illustrate:

enter image description here

What am I doing wrong?

Community
  • 1
  • 1
Kenny Smith
  • 729
  • 3
  • 9
  • 23
  • 1
    IDK, but they are linker errors. However you should fix the three compiler warnings concerning passing incompatible pointer types to functions: `unsigned short []` to `const char*`. Presumably due to the `L` in `L"Sheet1"` which judging from the warning message can be just `"Sheet1"`. – Weather Vane Feb 29 '20 at 15:35
  • Unrelated to your problem, but most probably wrong: If `xlBookLoad()` returns `true`, it was successful. But you quit the function. And you didn't check that `book` contains a valid handle before that `if`. – the busybee Feb 29 '20 at 15:54
  • Which IDE is this? – the busybee Feb 29 '20 at 15:54
  • Thanks for the comments The IDE is LabWindows/CVI – Kenny Smith Mar 01 '20 at 06:23

1 Answers1

1

You need to link with the provided library. From the screenshot you seem to have added the library to your project, however the linker does not get it.

the busybee
  • 10,755
  • 3
  • 13
  • 30