libftdi Archives

Subject: Re: How to cross-compile libftdi1 for ARM Linux target?

From: Anton Smirnov <dev@xxxxxxxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Wed, 21 Aug 2013 17:31:34 +0600
I cleared out that cmake tries to generate command-line for clang which is default compiler on mac and which recogizes these command-line parameters, but i've set
gcc as c/cpp compiler.

So i had to solve it using hack - commented few lines in Darwin.cmake:

# 4ntoine (fix for libftdi compilation using cmake)
#set(CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ")
#set(CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ")
#set(CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}")
#set(CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}")

# ...

# 4ntoine (fix for libftdi build using cmake)
#if(NOT XCODE)
# Enable shared library versioning.  This flag is not actually referenced
# but the fact that the setting exists will cause the generators to support
# soname computation.
#  set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-install_name")
#endif()

So now i have another problem:

cd /Users/asmirnov/Documents/dev/src/libftdi-1.0/build/src && /usr/local/Cellar/cmake/2.8.11.1/bin/cmake -E cmake_link_script CMakeFiles/ftdi1.dir/link.txt --verbose=1
/softdev/arm-toolchain/bin/arm-linux-androideabi-gcc  -O2 -g -DNDEBUG -dynamiclib -Wl,-headerpad_max_install_names  -L/softdev/arm-libs/lib -o libftdi1.dylib   CMakeFiles/ftdi1.dir/ftdi.c.o CMakeFiles/ftdi1.dir/ftdi_stream.c.o /softdev/arm-libs/lib/libusb-1.0.so 
/softdev/arm-toolchain/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: /softdev/arm-toolchain/bin/../sysroot/usr/lib/crtbegin_dynamic.o: in function _start:crtbrand.c(.text+0x78): error: undefined reference to 'main'
collect2: ld returned 1 exit status
make[2]: *** [src/libftdi1.dylib] Error 1
make[1]: *** [src/CMakeFiles/ftdi1.dir/all] Error 2
make: *** [all] Error 2

Any thoughs?

It seems that the problem is that main() function is absent in object files for ftdi.c.o, ftdi_stream.c.o.

PS. Is moving to cmake was really necessary to compile 5 files (i've spend 2 days trying to do it)?

2013/8/21 Anton Smirnov <dev@xxxxxxxxxxxxxxxxx>
Libusb for ARM and native have the same syntax so i've decided not to fix library paths (leave using system) as final executable is build using autotools and i'm
able to configure cross-compilation for it.

So when executing "make" i'm getting error (make VERBOSE=1):

cd /Users/asmirnov/Documents/dev/src/libftdi-1.0/src && /usr/local/Cellar/cmake/2.8.11.1/bin/cmake -E cmake_link_script CMakeFiles/ftdi1.dir/link.txt --verbose=1
/softdev/arm-toolchain/bin/arm-linux-androideabi-gcc  -O2 -g -DNDEBUG -dynamiclib -Wl,-headerpad_max_install_names  -L/softdev/arm-libs/lib -compatibility_version 2.0.0 -current_version 2.0.0 -o libftdi1.2.0.0.dylib -install_name /Users/asmirnov/Documents/dev/src/libftdi-1.0/src/libftdi1.2.dylib CMakeFiles/ftdi1.dir/ftdi.c.o CMakeFiles/ftdi1.dir/ftdi_stream.c.o /usr/local/lib/libusb-1.0.dylib 
arm-linux-androideabi-gcc: error: 2.0.0: No such file or directory
arm-linux-androideabi-gcc: error: 2.0.0: No such file or directory
arm-linux-androideabi-gcc: error: /Users/asmirnov/Documents/dev/src/libftdi-1.0/src/libftdi1.2.dylib: No such file or directory
arm-linux-androideabi-gcc: error: unrecognized option '-compatibility_version'
arm-linux-androideabi-gcc: error: unrecognized option '-current_version'
make[2]: *** [src/libftdi1.2.0.0.dylib] Error 1
make[1]: *** [src/CMakeFiles/ftdi1.dir/all] Error 2
make: *** [all] Error 2

So it seems that cmake created command line for gcc incorrectly - gcc does not understand "-compatibility_version 2.0.0 -current_version 2.0.0".
What's wrong with this?


2013/8/21 Anton Smirnov <dev@xxxxxxxxxxxxxxxxx>
I've used autotools to cross-compile libftdi-0.1 for ARM Linux:

export CPPFLAGS="-I/softdev/arm-libs/include/libusb"
export LDFLAGS="-L/softdev/arm-libs/lib"
./configure --build=x86-unknown-linux-gnu --host=arm-linux-androideabi --target=arm-linux-androideabi --prefix=/softdev/arm-libs

Now i'm going to do the same for libftdi1 and i was surprised that libftdi is now build with cmake.
After getting familiar with cmake and googling for a few hours i constructed build command for it which seems to be good for my purpose:

cmake -DCMAKE_INSTALL_PREFIX="/softdev/arm-libs" -DCMAKE_C_COMPILER="${CC}" -DCMAKE_CXX_COMPILER="${CXX}" -DCMAKE_CXX_FLAGS="${CPPFLAGS}" -DCMAKE_SYSTEM_NAME="Linux" -DLIBUSB_INCLUDE_DIR="/softdev/arm-libs/include/libusb" -DCMAKE_HOST_SYSTEM_NAME="Linux" -DCMAKE_FIND_ROOT_PATH="/softdev/arm-libs"  -G "Unix Makefiles" ..

So i'm getting error during "make":
arm-linux-androideabi-gcc: error: 2.0.0: No such file or directory
arm-linux-androideabi-gcc: error: 2.0.0: No such file or directory

cmake find compilers (c and c++) correctly, but does not use ARM libs for linker (still uses system paths).

What's wrong? Can it be cross-compiled in more simple way?
Libusb-1.0 is cross-compiled and is located in specified paths for sure.

Regards, Anton.
 




libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx


Current Thread