0

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.

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

5 Comments

when you reference your_folder, are you referring to the folder that the library is in (presuming the .h file is indeed inside of the static library?) EDIT: Alright, well I tried find /usr/local/libxls/lib/ -type f -iname xls.h as well as /home/wdaniels/documents/libxlsWrapper/ (the home directory where I'm running this out of) and find wasn't coming up with anything. Which leads me to believe that there is indeed a problem with the visibility of the .h file
To the extreme, you can find / -type f -iname xls.h. If you could not find it, you did something wrong to install that.
It can find the file, but only in the original source that I compiled the library from. Ok, well, in theory I should still be able to at least link against that whole thing to make it work for now. so, the result of the find came up with /usr/local/libxls/include/libxls/xls.h So i proecceded to try the command: gcc -I /usr/local/libxls/include/libxls/ -o xlsWrapper libxlsReader.c -L. -lxlsreader -lpthread same result. Thanks for the help, btw, I know it's hard to diagnose problems like this on someone elses system.
Alright, so that did in fact fix it. I guess I didn't realize that even when you link a static library, unless you have the .h file directly pointed to (outside of the .a file) or have defined your own .h file with all of the necessary definitions, it won't find anything. Regardless, I got it to compile and run just fine, so thank you! I'd upvote, but not enough reputation yet.
Now that I have enough Reputation (later in the future) I gave you the upvote your help deserved, thanks again, even though it was a while ago.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.