Alright, I realize that this might seem like a duplicate, but I've tried most variations and attempts via' searched posts, and I'm still coming up with nothing. Here's the issue: I am working with an open-source C library called libxls that is used for reading .xls files (aptly named project.. :) ). The code I'm using is straight off their website, essentially just a beginning toy example to make sure I can access the libraries:Link to their website with the source

#include <stdio.h>
#include "libxls/xls.h"

int main(){
    xlsWorkBook* pWB;
    pWB = xls_open("Book1.xls", "iso-8859-15//TRANSLIT");
    return 0;
}

That's it. Now, the syntax of that is fine. I know for a fact through the nm command that xls_open is indeed available as a function in the .a library, so that's not a problem. in my directory I have the following files (pardon the redundant naming, I was just trying to force it to work real quick):

Book1.xls
libxlsreader.a
libxlsReader.c
libxlsreader.so

Although I don't THINK I need the .so file here since I've tried dynamically linking to where that lives, figured it wasn't a bad plan to try. Alright, so, on the include line, I keep getting the common:

libxlsreader.c:3:37: fatal erro: libxls/xls.h: No such file or directory

Ok fine, so I probably linked in the library wrong, take a look at my compile line arguments:

gcc -o libxlsWrapper libxlsReader.c -L /usr/local/lib/ -lxlsreader -lpthread

huh, well.. that certainly LOOKS right, /usr/local/lib/ is where the library created itself with all of it's .so files, and the .a one in my PWD. Now, I'm a java developer by trade, so I might be missing something blaringly obvious, but for the life of me I can't determine what it is. it certainly seems ok to me.

I'm using GCC (ubuntu/Linaro 4.7.3-lubunutul) 4.7.3 on Linux Mint 15 KDE 32-bit.

If you'd like to reproduce the library for your own testing or problem solving, it can be obtained from

I don't recommend recreating it on windows, I tried for a couple hours yesterday and gave up, so just do the regular ./configure -> make -> make install and that should produce the appropriate libraries for you.

Thanks!

-Will

edit #1: here are some of the other linking attempts I've tried, all with the identical result.

gcc -o libxlsWrapper libxlsReader.c -L. -lxlsreader -I.
gcc -o libxlsWrapper libxlsReader.c -L. -lxlsreader -lpthread
gcc -o libxlsWrapper libxlsReader.c -L. -lxlsreader.so

I also tried a bunch with g++ instead of gcc (throwing darts, I know), same result.

有帮助吗?

解决方案

Please do a find your_folder -type f -iname xls.h and then use a gcc -I /the_path to include the path for xls.h. Because the problem you have is that gcc could not locate the header file xls.h.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top