LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-17-2010, 10:05 PM   #1
CollieJim
Member
 
Registered: Mar 2005
Distribution: Gentoo, Kubuntu
Posts: 582

Rep: Reputation: 28
Yet another undefined reference


I'm trying to compile and link a program to test parapin.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "parapin.h"

int main(int argc, char *argv[])
{ ...
Code:
lib$ cd /usr/lib
lib$ ls -al libparapin*
-rwxr-xr-x 1 root root 2602 Dec 18 09:57 libparapin.a
When I compile, I get:
Code:
noppp$ gcc -O -lparapin -o testpp test.c
/tmp/cc3tvN9s.o: In function `main':
test.c:(.text+0x19): undefined reference to `pin_init_user'
test.c:(.text+0x3d): undefined reference to `pin_input_mode'
test.c:(.text+0x49): undefined reference to `pin_output_mode'
test.c:(.text+0x69): undefined reference to `set_pin'
test.c:(.text+0x75): undefined reference to `clear_pin'
test.c:(.text+0x81): undefined reference to `pin_is_set'
collect2: ld returned 1 exit status
It looks like the library is found (no error anyway) but the functions in it are not seen. Text at the beginning of libparapin.a includes function names as used in the test program, and parapin.h declares them.

What am I missing?
TIA
 
Old 12-17-2010, 10:47 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

I think it probably would have been better to post this in the "Programming" section...

... but

1) it sounds like you're basically doing everything correctly.

2) You can use "nm" to verify which symbols are in the library
Quote:
EXAMPLES:
nm libparapin.a | less
nm libparapin.a | grep pin_init_user
3) A longshot ... but maybe it would help if you put the "-lparapin" at the END of your link command:
Quote:
gcc -g -Wall -pedantic -o testpp test.c -lparapin
 
1 members found this post helpful.
Old 12-17-2010, 11:08 PM   #3
CollieJim
Member
 
Registered: Mar 2005
Distribution: Gentoo, Kubuntu
Posts: 582

Original Poster
Rep: Reputation: 28
Thanks. I need to have my eyes examined, I think. I looked, but missed the programming section.

Putting -lparapin at the end worked.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
undefined reference to.... crapodino Programming 1 01-13-2008 07:05 PM
Undefined reference to: ashlesha Programming 5 11-08-2006 01:07 PM
undefined reference? Sharky01252 Programming 3 11-07-2006 11:36 AM
Undefined Reference ChemicalBurn Programming 2 02-14-2005 03:01 AM
undefined reference mp4-10 Programming 3 01-25-2005 12:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:48 AM.

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
Open Source Consulting | Domain Registration