LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-30-2006, 12:19 PM   #1
Mike Davies
Member
 
Registered: Jul 2004
Distribution: Custom Linux, Buildroot, Busybox, Fedora, Raspberry Pi
Posts: 144

Rep: Reputation: 15
"undefined references"


I've recently upgraded my kernel (from 2.4.31 to 2.6.19) and also my toolchain, and now I'm getting undefined references.

e.g.

:/home/mike/work/sensor/sensor.c:80: undefined reference to `i2c_smbus_write_block_data'
:/home/mike/work/sensor/sensor.c:95: undefined reference to `i2c_smbus_write_byte'
:/home/mike/work/sensor/sensor.c:107: undefined reference to `i2c_smbus_read_word_data'
collect2: ld returned 1 exit status
make: *** [sensor] Error 1

These routines are part of the i2c dev interface and appear to have been moved into the kernel from 2.6.13 onwards.

How do I get the linker to resolve these undefined references ? Is there some sort of special calling mechanism now that they are part of the kernel ?

Last edited by Mike Davies; 12-30-2006 at 12:20 PM.
 
Old 12-30-2006, 01:40 PM   #2
studioj
Member
 
Registered: Oct 2006
Posts: 460

Rep: Reputation: 31
i think we need the compiler output including the link command that failed.

the i2c-bus works right it's just a compile problem.
we might need to know what you are compiling.

when you say you upgraded you toolcain you mean you have a new glibc too ?
 
Old 01-01-2007, 03:07 AM   #3
Mike Davies
Member
 
Registered: Jul 2004
Distribution: Custom Linux, Buildroot, Busybox, Fedora, Raspberry Pi
Posts: 144

Original Poster
Rep: Reputation: 15
Thanks for the reply.

The command looks like ...

/home/mike/buildroot/build_i386/staging_dir/bin/i386-linux-uclibc-gcc -Wall -o sensor sensor.o sensor_utils.o -L/home/mike/buildroot/build_i386/staging_dir/lib -L/home/mike/buildroot/build_i386/staging_dir/i386-linux-uclibc/lib -L/home/mike/buildroot/build_i386/staging_dir/usr/lib -lm -lc --just-symbols=~/linux-2.6.19.1/System.map
sensor.o: In function `main':
/home/mike/work/sensor/sensor.c:77: undefined reference to `i2c_smbus_read_byte_data'
/home/mike/work/sensor/sensor.c:84: undefined reference to `i2c_smbus_write_block_data'
/home/mike/work/sensor/sensor.c:99: undefined reference to `i2c_smbus_write_byte'
/home/mike/work/sensor/sensor.c:111: undefined reference to `i2c_smbus_read_word_data'
collect2: ld returned 1 exit status
make: *** [sensor] Error 1
[mike@glynys sensor]$

As you can see I'm using uClibc because it's a small embedded system I'm trying to set up. I've also tried using the --just_symbols and -t options to the linker with no effect.

The routines I need are in the kernel. How do I link to them ?
 
Old 01-01-2007, 03:19 PM   #4
studioj
Member
 
Registered: Oct 2006
Posts: 460

Rep: Reputation: 31
hi,
im not sure about this but
include <linux/i2c-dev.h>

would be a part of glibc BUT the glibc has to be compiled against the kernel headers from the newer kernel.

i think in an embeded system it is common to use a minimal subset of glibc symbols.
there is a method they use where when they encounter an undefined reference they can add the symbol to a symbol list and recompie glibc to include it but this is beyond my ability to comment on further. sorry
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
"undefined reference"linker error for static field w/ C++ astorm Programming 5 08-27-2008 03:00 AM
I need help on this PHP error -- "Call to undefined function: mysql_connect()" yzh999 Linux - Software 1 08-12-2006 03:14 AM
"undefined mode number" When Connecting TV via Composite Cable moo-cow Linux - Hardware 1 04-12-2006 02:25 AM
avgscan "relocation error" "undefined symbol: __dynamic_cast_2" Monster_user Linux - Software 0 02-22-2006 11:57 AM
Undefined Screen " XFree86" reference by serverLayout "XFree86 Configured" comox *BSD 7 01-17-2005 05:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:02 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