简体   繁体   中英

Problem with the libxlsxwriter libary (MSYS2)

I installed the libxlsxwriter library in MSYS2 MinGW 64-bit with the pacman -S mingw-w64-x86_64-libxlsxwriter command. Now I can't compile the standard test file from https://libxlsxwriter.github.io/getting_started.html on Visual Studio Code.

The Code:

#include "xlsxwriter.h"
 
int main() {
 
    lxw_workbook  *workbook  = workbook_new("myexcel.xlsx");
    lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
    int row = 0;
    int col = 0;
 
    worksheet_write_string(worksheet, row, col, "Hello me!", NULL);
 
    return workbook_close(workbook);
}

I got the errors

  • C:/(path to.c file/myexcel.c: undefined reference to `workbook_new'
  • C:/(path to.c file/myexcel.c: undefined reference to `workbook_add_worksheet'
  • C:/(path to.c file/myexcel.c: undefined reference to `worksheet_write_string'
  • C:/(path to.c file/myexcel.c: undefined reference to `workbook_close'
  • collect2.exe: error: ld returned 1 exit status

Nothing is underlined so the library should be installed. I'm working with minGW64 GCC Compiler which works fine. I'm new in working with libraries and hope you can help me.

I used F5 which equals gcc myexcel.c but I had to use gcc myexcel.c -o myexcel -lxlsxwriter and now it is working. Just said i'm new in working with libraries.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM