0

I am trying to read an excel file with extension .xlsx in C using Coe-blocks. I have found the following library helps in doing so. libxls library. I have downloaded it. I have ran Test2.C in the downloaded folder. But I am getting these errors after .

||=== Build file: "no target" in "no project" (compiler: unknown) ===|
D:\Palguna\C__language\xlsx_reading\main.o:main.c|| undefined reference to `xls'|
D:\Palguna\C__language\xlsx_reading\main.o:main.c|| undefined reference to `xls_open_file'|
D:\Palguna\C__language\xlsx_reading\main.o:main.c|| undefined reference to `xls_getError'|
D:\Palguna\C__language\xlsx_reading\main.o:main.c|| undefined reference to `xls_getWorkSheet'|
D:\Palguna\C__language\xlsx_reading\main.o:main.c|| undefined reference to `xls_parseWorkSheet'|
D:\Palguna\C__language\xlsx_reading\main.o:main.c|| undefined reference to `xls_getError'|
D:\Palguna\C__language\xlsx_reading\main.o:main.c|| undefined reference to `xls_showROW'|
D:\Palguna\C__language\xlsx_reading\main.o:main.c|| undefined reference to `xls_showCell'|
D:\Palguna\C__language\xlsx_reading\main.o:main.c|| undefined reference to `xls_showBookInfo'|
||error: ld returned 1 exit status|
||=== Build failed: 10 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

How to resolve this. Please suggest. Thanks.

  • 1
    You don't *link* with the library itself. – Some programmer dude Nov 02 '22 at 07:31
  • Does anybody know the C variant of this https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix to be used as duplicate here? – Yunnosch Nov 02 '22 at 07:35
  • @Yunnosch No but linkers work exactly the same in C and C++. – Lundin Nov 02 '22 at 07:41
  • @some-programmer-dude, I don't understand _don't link with the library itself_. I have ran the code given by specifying the path to the `xls.h` header file in `test2.c` and compiled it. Could you enlighten me. –  Nov 02 '22 at 13:24
  • A header file is not a library. Building an application is done in multiple steps: 1) Edit source code; 2) Build the source code into object files; 3) Link object files together with libraries into an executable program file. Header files are included in step 2, linker errors like you're getting happens at step 3. Is there a file named something like `xls.lib` or `libxls.a` in your installation of the library? You need to link with one of them (which one depends on the toolchain you're building with). – Some programmer dude Nov 02 '22 at 13:37
  • I don't think it has a library with that name. I have searched that downloaded folder. [libxls library](https://github.com/libxls/libxls) –  Nov 02 '22 at 13:47
  • If you read [the installation instructions](https://github.com/libxls/libxls#installation) it's clearly stated that you need to build the library yourself from the source. What you have downloaded is only a source archive, not a ready-to-use binary installation. – Some programmer dude Nov 02 '22 at 13:52
  • @Someprogrammerdude I am using Windows, So I don't understand what was those _installation instructions_ were. How to do them in windows? Can we use the same instructions in command prompt?, Then how? –  Nov 02 '22 at 13:58
  • @Someprogrammerdude I think I can do that in _command prompt_. THere is a file named 'configure` in the downloaded folder. I changed the path to the directory and tried to ran `configure`, but the _command Prompt_ saying is not recognizing it, as it has no extension. –  Nov 02 '22 at 14:14
  • Unfortunately you seem to need a lot more knowledge than you have currently. And again unfortunately, StackOverflow is not the place to teach you all in a single answer. So you will need to prepare yourself for a longer learning curve, doing research, experimenting, all you need to understand. However, feel free to ask specific questions on single topics here on SO. -- Alternatively try to find a readily compiled library for Windows. Or switch to Linux. – the busybee Nov 02 '22 at 14:41
  • Thanks @thebusybee . I have installed WSL 2 for windows using [this link](https://learn.microsoft.com/en-us/windows/wsl/install). I have run the `/configure` command specified in [libxls library](https://github.com/libxls/libxls). This is [the result](https://drive.google.com/file/d/1_IyRPo_amxcC54bzpdOv2LllZD8FuDqg/view?usp=share_link). Have I done correctly or not? I do see _Makefile.am_, _Makefile.in_, _INSTALL_ files in the [libxls library](https://github.com/libxls/libxls) downloaded. –  Nov 04 '22 at 13:47

0 Answers0