[Armadillo:05121] Re: ライブラリのコンパイル方法

mizo email@hidden
2010年 4月 27日 (火) 17:01:04 JST


溝渕です。

佐原拓也 wrote:
> 佐原と言います。Linux初心者です。
>  
> Armadillo-500FXにて、FTDI USBドライバ(ライブラリ)を動作させようと
> 奮闘中です。
> 接続環境
> Armadillo-500FX <--- USB cable ---> FTDI FT2232H(USB) <---> CPU 
>  
> Out of Tree コンパイルにて、FTDI USBプログラムを動作させよう試みてます。

ビルドしなくても、debianのパッケージにあるlibftdi0で動いたりしませんか?

[debian package: libftdi0]
http://packages.debian.org/etch/arm/libftdi0/download

[HOWTO: クロス開発用ライブラリをインストールする方法]
http://armadillo.atmark-techno.com/howto/install-cross-libraries

> ディレクトリにCソースコード(souce.c)とヘッダファイル(ftd2xx.h)をいれ、
> makeすると以下のエラーが出ます。
> arm-linux-gcc   -L../atmark-dist-20100310/lib -o test test.o -lc -lgcc
> test.o: In function `ae2_write_ana':
> test.c:(.text+0x40): undefined reference to `FT_Write'
> test.c:(.text+0x6c): undefined reference to `FT_Write'
>  :
>  中略 上記同様のエラー内容がずらっとでます。
>  :
> collect2: ld returned 1 exit status
> make: *** [test] エラー 1
>  
> と出ます。
>  
> 1)ライブラリがリンクされていないからだと思うのですが、クロスコンパイル 
> する場合、
>  ライブラリをどのようにリンクするか教えて頂きたいです。

ライブラリの検索対象のディレクトリにあるライブラリをリンクします。
/usr/arm-linux-gnu/lib/などです。

ftd2xxのライブラリはどこに置きましたか?

>  具体的には本文の最後にあります、Debian Linuxでライブラリをインストール 
> したことを
>  クロスコンパイルでもする必要があると思いますが方法がよくわかりません。
>  
> 2)合わせて、Makefile のgccオプションを追加する必要があると思いますが、
>   オプションの書き方がよくわかりません。

arm-linux-gnu-gccのオプションに、
-lftd2xx
を付けるとどうなりますか?

> 組込でなく、Debian Linuxではプログラムが動作していることは確認しました。
> 以下、FTDI USBのMakefile、Rules.make、Readme.dat です。
>  
> 〇Makefile
>  
> TOPDIR  := $(shell cd ..; pwd)
> include $(TOPDIR)/Rules.make
> APP = test
> all: $(APP)
> $(APP): main.c
>  $(CC) -o $(APP) $(CFLAGS) main.c 
>  clean:
>  rm -f *.o ; rm $(APP)
>  
> 〇Rules.make
>  
> CC=gcc
> CFLAGS=-L. -lftd2xx -Wl,-rpath /usr/local/lib
> 〇FTDI USBドライバー(ライブラリ)のインストール(Readme.dat)
>  
> Instructions for installing the d2xx shared lib
> As Linux distributions vary these instructions are a guide to 
> installation and use.
> This setup works with Mandrake 9.2 but may require some investigation on 
> other distributions.
> This library has been tested using kernel 2.4.25.
> D2XX documentation is available for the Windows dll - some variations 
> may occur between linux and
> windows implementation. We have endevoured to make the APIs appear the 
> same on both platforms however some
> issues may slip and we would appreciate that you contact support if you 
> observe this.
> D2XX for linux was primarily developed to aid porting windows 
> applications written with D2XX to linux.
> Unfortunately the source code for D2XX is not freely available - however 
> if you prefer to have the
> source and are starting a project from scratch you can try libftdi from 
> Thomas Jarosch.
> Details of this library are on the ftdi web site.
>  
> libftd2xx uses an unmodified version of libusb 
> (http://libusb.wiki.sourceforge.net/). 
> Source code for libusb is included in the driver distribution in the 
> libusb-0.1.12 directory.
>  
> Installation:
> 1. unzip and untar the file given to a suitable directory
> gunzip libftd2xx0.4.12.tar.gz
> tar -xvf libftd2xx0.4.12.tar
> 2. As root user copy the following files to /usr/local/lib
> cp libftd2xx.so.0.4.12 /usr/local/lib
> 3. Change directory to /usr/local/lib
> cd /usr/local/lib
> 4. make symbolic links to these files using the following commands:
> ln -s libftd2xx.so.0.4.12 libftd2xx.so
> 5. Change directory to /usr/lib
> cd /usr/lib
> 6. make symbolic links to these files using the following commands:
> ln -s /usr/local/lib/libftd2xx.so.0.4.12 libftd2xx.so
> 7. Add the following line to /etc/fstab:
> none /proc/bus/usb usbdevfs defaults,devmode=0666 0 0
> There have been reports that you may need to use the following command 
> for some distros
> none /proc/bus/usb usbdevfs defaults,mode=0666 0 0 (use usbfs in 2.6 
> kernels)
> 8. Remount all in the fstab file
> mount -a
> If you have problems with this check with usbview (search on the 
> internet for application
> or it can be sent to you by ftdi) to check the usb file system is 
> mounted properly.
> Other problems will be related to the ftdi_sio driver loading -
> 1.you must unload this driver (and usbserial) if it is attached to your 
> device ("rmmod ftdi_sio" and "rmmod usbserial"as root user).
> 2.Your PID/VID has not been included in the distribution.A PID of 0x6006 
> and VID of
> 0x0403 should work as a temporary workaround.
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> armadillo mailing list
> email@hidden
> http://lists.atmark-techno.com/cgi-bin/mailman/listinfo/armadillo




armadillo メーリングリストの案内