LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Library linking problem (https://www.linuxquestions.org/questions/linux-newbie-8/library-linking-problem-4175512833/)

GGoysens 07-31-2014 06:33 AM

Library linking problem
 
Hi,

I am new to linux and actually also for some extend to programming. I'm having a problem linking a C library to my C code.

The library .a files are in the folder /home/glenn/SOEM1.2.8/lib/linux (libsoem.a)
The header files are in the folder /home/glenn/SOEM1.2.8/soem

After some google searching I thought I could compile my code like this:

gcc -o soem_functions -I/home/glenn/SOEM1.2.8/soem -L/home/glenn/SOEM1.2.8/lib/linux -lsoem soem_function.c

But I am having "undefined reference to" errors for the functions in this library.
I don't see what I'm doing wrong here, can someone help me out ?

Thanks.

pan64 07-31-2014 07:18 AM

you should change the order of the files: first comes the .c, and last the lib -lsoem

GGoysens 07-31-2014 08:57 AM

That did the trick, rookie mistake, thanks.


All times are GMT -5. The time now is 10:10 PM.