简体   繁体   中英

Compiling program with Open Source libFTDI

I use Asus router (based on ARMv7 proc) with Advanced Tomato installed on it as my ARMv7 developer platform. I install compiler (gcc - 5.4.0-1) plus dependencies and libFTDI (libftdi1 - 1.3-1) from OpenWRT Linux repo. OpenWRT does not provide libftdi-dev so I copied ftdi.h file from libFTDI download page to /opt/include directly. I try to compile program taken directly from libFTDI samples. The compiler command is:

gcc -v -Wl,-rpath=/opt/usr/local/lib -Wl,--dynamic-linker=/opt/lib/ld-linux.so.3 -L/opt/lib -O2 -pipe -march=armv7-a -mtune=cortex-a9-fno-caller-saves -mfloat-abi=soft -l ftdi1 d.c -o d

But compilation fails because:

/opt/bin/ld: cannot find -lftdi1

But there is /opt/usr/local/lib/libftdi1.so linked to libftdi1.so.2

My LD_LIBRARY_PATH looks like this:

/lib:/usr/lib:/usr/local/lib:/opt/lib:/opt/usr/lib:/opt/include:/opt/usr/local/lib:/opt/usr/include

So what the problem is?

I dont know why (probably bug) but for compiler taken from OpenWRT repo, MUST have wanted library in /opt/lib . So simply copy libftdi1.so.2.3.0 file and linking it to libftdi1.so resolved problem. That means that it does not use correctly LD_LIBRARY_PATH variable. Finally compilation command looks like this:

gcc -v -Wl,-rpath=/opt/usr/local/lib -Wl,--dynamic-linker=/opt/lib/ld-linux.so.3 -L/opt/lib -O2 -pipe -march=armv7-a -mtune=cortex-a9 -fno-caller-saves -mfloat-abi=soft -l ftdi1 arco.c -o arco

From my point of view - topic closed

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM