LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-31-2014, 07:33 AM   #1
GGoysens
LQ Newbie
 
Registered: Jul 2014
Posts: 2

Rep: Reputation: Disabled
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.
 
Old 07-31-2014, 08:18 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 8,516

Rep: Reputation: 2436Reputation: 2436Reputation: 2436Reputation: 2436Reputation: 2436Reputation: 2436Reputation: 2436Reputation: 2436Reputation: 2436Reputation: 2436Reputation: 2436
you should change the order of the files: first comes the .c, and last the lib -lsoem
 
1 members found this post helpful.
Old 07-31-2014, 09:57 AM   #3
GGoysens
LQ Newbie
 
Registered: Jul 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
That did the trick, rookie mistake, thanks.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
library linking problem in gcc surya1006 Linux - Newbie 2 09-05-2008 04:43 PM
Problem in linking GDOME library. Varsha_vdd Linux - Newbie 2 06-05-2008 09:48 AM
Library Linking problem IronBeagle Linux - Software 3 02-14-2006 01:10 PM
Still library linking problem The_Nerd Programming 19 05-20-2004 05:08 PM
Library linking problem The_Nerd Programming 10 04-27-2004 12:07 AM


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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration