在测试树莓派控制LED教程(http://www.codelast.com/?p=5155)
GPIO测试编译时出现了这个问题
/usr/lib/gcc/arm-linux-gnueabi/4.6/../../../libwiringPi.so:undefined reference to `i2c_smbus_write_byte'
/usr/lib/gcc/arm-linux-gnueabi/4.6/../../../libwiringPi.so:undefined reference to `i2c_smbus_read_byte'
/usr/lib/gcc/arm-linux-gnueabi/4.6/../../../libwiringPi.so:undefined reference to `i2c_smbus_write_byte_data'
/usr/lib/gcc/arm-linux-gnueabi/4.6/../../../libwiringPi.so:undefined reference to `i2c_smbus_write_word_data'
/usr/lib/gcc/arm-linux-gnueabi/4.6/../../../libwiringPi.so:undefined reference to `i2c_smbus_read_word_data'
/usr/lib/gcc/arm-linux-gnueabi/4.6/../../../libwiringPi.so:undefined reference to `i2c_smbus_read_byte_data'
collect2: ld returned 1 exit status
官方论坛上说是少装了库的原因
安装这几个库: i2c-tools,libi2c-dev ,python-smbus
安装参考 sudo apt-get install libi2c-dev
然后重新
make clean
sudo make uninstall
make
sudo make install
重新编译下你的.c文件
gcc led.c -o led -lwiringPi
sudo ./led 4
虽然输入的是4
实际上是GPIO23不停输出高低电平
因为当初写库的时候重新定义了GPIO
(具体可参考https://projects.drogon.net/raspberry-pi/wiringpi/pins/)
晒一张测试照片
(更多引脚信息可参考http://www.raspberrypi-spy.co.uk/2012/06/simple-guide-to-the-rpi-gpio-header-and-pins/)
实际上是
经测试果然编译通过
(附:WiringPi→Download and Install https://projects.drogon.net/raspberry-pi/wiringpi/download-and-install/)
原文地址
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=31&t=19680
I am trying out the Ada I2c interface http://sourceforge.net/projects/raspi-i2c-ada/ and have downloaded and built the library. However, when I try and build the example test program I get the following ld errors: -
-
CODE:
SELECT ALL
-
gprbuild test.gpr
gcc-4.6 t.o -o t
/home/pi/raspi-i2c-ada-code/lib-static//libi2c-ada.a(i2c_interface.o): In function `write_quick':
i2c_interface.c:(.text+0x24): undefined reference to `i2c_smbus_write_quick'
/home/pi/raspi-i2c-ada-code/lib-static//libi2c-ada.a(i2c_interface.o): In function `read_byte':
i2c_interface.c:(.text+0x4c): undefined reference to `i2c_smbus_read_byte'
/home/pi/raspi-i2c-ada-code/lib-static//libi2c-ada.a(i2c_interface.o): In function `write_byte':
i2c_interface.c:(.text+0x84): undefined reference to `i2c_smbus_write_byte'
/home/pi/raspi-i2c-ada-code/lib-static//libi2c-ada.a(i2c_interface.o): In function `read_byte_data':
i2c_interface.c:(.text+0xbc): undefined reference to `i2c_smbus_read_byte_data'
/home/pi/raspi-i2c-ada-code/lib-static//libi2c-ada.a(i2c_interface.o): In function `write_byte_data':
i2c_interface.c:(.text+0x104): undefined reference to `i2c_smbus_write_byte_data'
/home/pi/raspi-i2c-ada-code/lib-static//libi2c-ada.a(i2c_interface.o): In function `read_word_data':
i2c_interface.c:(.text+0x13c): undefined reference to `i2c_smbus_read_word_data'
/home/pi/raspi-i2c-ada-code/lib-static//libi2c-ada.a(i2c_interface.o): In function `write_word_data':
i2c_interface.c:(.text+0x184): undefined reference to `i2c_smbus_write_word_data'
/home/pi/raspi-i2c-ada-code/lib-static//libi2c-ada.a(i2c_interface.o): In function `process_call':
i2c_interface.c:(.text+0x1cc): undefined reference to `i2c_smbus_process_call'
/home/pi/raspi-i2c-ada-code/lib-static//libi2c-ada.a(i2c_interface.o): In function `read_block_data':
i2c_interface.c:(.text+0x20c): undefined reference to `i2c_smbus_read_block_data'
/home/pi/raspi-i2c-ada-code/lib-static//libi2c-ada.a(i2c_interface.o): In function `write_block_data':
i2c_interface.c:(.text+0x25c): undefined reference to `i2c_smbus_write_block_data'
/home/pi/raspi-i2c-ada-code/lib-static//libi2c-ada.a(i2c_interface.o): In function `read_i2c_block_data':
i2c_interface.c:(.text+0x2ac): undefined reference to `i2c_smbus_read_i2c_block_data'
/home/pi/raspi-i2c-ada-code/lib-static//libi2c-ada.a(i2c_interface.o): In function `write_i2c_block_data':
i2c_interface.c:(.text+0x2fc): undefined reference to `i2c_smbus_write_i2c_block_data'
/home/pi/raspi-i2c-ada-code/lib-static//libi2c-ada.a(i2c_interface.o): In function `block_process_call':
i2c_interface.c:(.text+0x34c): undefined reference to `i2c_smbus_block_process_call'
collect2: ld returned 1 exit status
gprbuild: link of t.adb failed
I have done some digging around and found that these undefined functions are defined in i2c-dev.h but the question is, where is and how should I link to their implementation/library

- Posts: 9
- Joined: Tue Jun 05, 2012 8:35 pm
sudo apt-get install libi2c-dev
may be all that you need.
- Posts: 1341
- Joined: Thu Jul 05, 2012 5:09 pm
- Location: UK
ada-fruit schmada fruit
libi2c-dev schmlibi2c-dev
I just did this: http://www.njbsmith.net/miscellaneous/Ivansense_6050_test.c
hack it if you can
- Posts: 1469
- Joined: Sun Mar 04, 2012 12:49 am
-
CODE:
SELECT ALL
-
pi@raspberrypi ~ $ i2cset -y 0 0x20 0x00 0x00
pi@raspberrypi ~ $ i2cset -y 0 0x20 0x01 0x00
pi@raspberrypi ~ $ i2cset -y 0 0x20 0x12 0x01
pi@raspberrypi ~ $ i2cset -y 0 0x20 0x12 0x02
pi@raspberrypi ~ $ i2cset -y 0 0x20 0x12 0x03
pi@raspberrypi ~ $ i2cset -y 0 0x20 0x12 0x00
The only issue is linking because I don't appear to be able to find a library containing the missing symbols

- Posts: 9
- Joined: Tue Jun 05, 2012 8:35 pm
Hmm I see you installed python-smbus which is for python, but you are building a gcc (C) porogramme, you have not by chance made reference in your code to python routines instead of C library functions?
Thus confusing the compiler.
or http://www.pcserviceselectronics.co.uk/pi/
- Posts: 764
- Joined: Sat Jul 14, 2012 6:40 pm
- Location: Reading, UK
My solution was to create a C file which provides a callable interface to each declared function, so that it can be called from Ada using pragma Import.
The project's Makefile is supposed to compile this file and include it in the project library, but something went wrong on @richtoy's machine. AFAICR he retried it and it worked.