Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - General
User Name
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.


  Search this Thread
Old 12-17-2010, 11:05 PM   #1
Registered: Mar 2005
Distribution: Gentoo, Kubuntu
Posts: 530

Rep: Reputation: 28
Yet another undefined reference

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

int main(int argc, char *argv[])
{ ...
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:
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?
Old 12-17-2010, 11:47 PM   #2
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
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:
gcc -g -Wall -pedantic -o testpp test.c -lparapin
1 members found this post helpful.
Old 12-18-2010, 12:08 AM   #3
Registered: Mar 2005
Distribution: Gentoo, Kubuntu
Posts: 530

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.


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

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

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

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