Can not compile program on ARMv7 native platform

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Can not compile program on ARMv7 native platform

mackowiakp
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. 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

Below program source and output from compilation process. As You can
see, ftdi.h file absence is rapport.
I try to find ftdi.h file in whole system, but there is no such file at
all. How can I obtain this file for ARMv7 architecture?


Programm to be compiled

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define sleep(x) Sleep(x)
#include <ftdi.h>

int main(int argc, char **argv)
{
    struct ftdi_context *ftdi;
    int f,i;
    unsigned char buf[1];
    int retval = 0;

    if ((ftdi = ftdi_new()) == 0)
    {
        fprintf(stderr, "ftdi_new failed\n");
        return EXIT_FAILURE;
    }

    f = ftdi_usb_open(ftdi, 0x0403, 0x6001);

    if (f < 0 && f != -5)
    {
        fprintf(stderr, "unable to open ftdi device: %d (%s)\n", f,
ftdi_get_error_string(ftdi));
        retval = 1;
        goto done;
    }

    printf("ftdi open succeeded: %d\n",f);

    printf("enabling bitbang mode\n");
    ftdi_set_bitmode(ftdi, 0xFF, BITMODE_BITBANG);

    sleep(3);

    buf[0] = 0x0;
    printf("turning everything on\n");
    f = ftdi_write_data(ftdi, buf, 1);
    if (f < 0)
    {
        fprintf(stderr,"write failed for 0x%x, error %d
(%s)\n",buf[0],f, ftdi_get_error_string(ftdi));
    }

    sleep(3);

    buf[0] = 0xFF;
    printf("turning everything off\n");
    f = ftdi_write_data(ftdi, buf, 1);
    if (f < 0)
    {
        fprintf(stderr,"write failed for 0x%x, error %d
(%s)\n",buf[0],f, ftdi_get_error_string(ftdi));
    }

    sleep(3);

    for (i = 0; i < 32; i++)
    {
        buf[0] =  0 | (0xFF ^ 1 << (i % 8));
        if ( i > 0 && (i % 8) == 0)
        {
            printf("\n");
        }
        printf("%02hhx ",buf[0]);
        fflush(stdout);
        f = ftdi_write_data(ftdi, buf, 1);
        if (f < 0)
        {
            fprintf(stderr,"write failed for 0x%x, error %d
(%s)\n",buf[0],f, ftdi_get_error_string(ftdi));
        }
        sleep(1);
    }

    printf("\n");

    printf("disabling bitbang mode\n");
    ftdi_disable_bitbang(ftdi);

    ftdi_usb_close(ftdi);
done:
    ftdi_free(ftdi);

    return retval;
}


Output from compilation process


Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/lto-wrapper
Target: arm-openwrt-linux-gnueabi
Configured with:
/media/ware3/Entware-ng.2016.08/build_dir/target-arm_cortex-a9_glibc-2.23_eabi/gcc-5.4.0/configure
--target=arm-openwrt-linux --host=arm-openwrt-linux
--build=x86_64-linux-gnu --program-prefix= --program-suffix=
--prefix=/opt --exec-prefix=/opt --bindir=/opt/bin --sbindir=/opt/sbin
--libexecdir=/opt/lib --sysconfdir=/opt/etc --datadir=/opt/share
--localstatedir=/opt/var --mandir=/opt/man --infodir=/opt/info
--disable-nls --build=x86_64-linux-gnu --host=arm-openwrt-linux-gnueabi
--target=arm-openwrt-linux-gnueabi --enable-languages=c,c++
--with-bugurl=https://dev.openwrt.org/ --with-pkgversion='OpenWrt GCC
5.4.0' --enable-shared --enable-__cxa_atexit
--with-default-libstdcxx-abi=gcc4-compatible --enable-target-optspace
--with-gnu-ld --with-stage1-ldflags='-Wl,-rpath=/opt/lib
-Wl,--dynamic-linker=/opt/lib/ld-linux.so.3'
--with-boot-ldflags='static-libstdc++ -static-libgcc -Wl,-rpath=/opt/lib
-Wl,--dynamic-linker=/opt/lib/ld-linux.so.3' --disable-nls
--disable-libsanitizer --disable-libvtv --disable-libcilkrts
--disable-libmudflap --disable-multilib --disable-libgomp
--disable-libquadmath --disable-libssp --disable-decimal-float
--disable-libstdcxx-pch --with-host-libstdcxx=-lstdc++ --prefix=/opt
--libexecdir=/opt/lib --with-local-prefix=/opt --with-float=soft
--with-default-libstdcxx-abi=gcc4-compatible
Thread model: posix
gcc version 5.4.0 (OpenWrt GCC 5.4.0)
COLLECT_GCC_OPTIONS='-v' '-L/opt/lib' '-O2' '-pipe' '-march=armv7-a'
'-mtune=cortex-a9' '-fno-caller-saves' '-mfloat-abi=soft' '-o' 'd'
'-mtls-dialect=gnu'
 /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/cc1 -quiet -v -imultilib .
-imultiarch arm-linux-gnueabi d.c -quiet -dumpbase d.c -march=armv7-a
-mtune=cortex-a9 -mfloat-abi=soft -mtls-dialect=gnu -auxbase d -O2
-version -fno-caller-saves -o - |
 as -v -march=armv7-a -mfloat-abi=soft -meabi=5 -o /opt/tmp/ccVBKSjn.o
GNU assembler version 2.26.1 (arm-openwrt-linux-gnueabi) using BFD
version (GNU Binutils) 2.26.1
GNU C11 (OpenWrt GCC 5.4.0) version 5.4.0 (arm-openwrt-linux-gnueabi)
        compiled by GNU C version 5.4.0, GMP version 4.3.2, MPFR version
2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=31954
ignoring nonexistent directory "/opt/include/arm-linux-gnueabi"
ignoring nonexistent directory
"/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/../../../../arm-openwrt-linux-gnueabi/include"
ignoring nonexistent directory "/usr/include/arm-linux-gnueabi"
ignoring nonexistent directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here:
 /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/include
 /opt/include
 /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/include-fixed
End of search list.
GNU C11 (OpenWrt GCC 5.4.0) version 5.4.0 (arm-openwrt-linux-gnueabi)
        compiled by GNU C version 5.4.0, GMP version 4.3.2, MPFR version
2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=31954
Compiler executable checksum: a589712d81e28a1300ccb0e03d994135
d.c:5:18: fatal error: ftdi.h: No such file or directory
compilation terminated.

--

Z poważaniem

Piotr Maćkowiak

TEN MAIL JEST PODPISANY ELEKTRONICZNIE


smime.p7s (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can not compile program on ARMv7 native platform

Jim Paris
mackowiakp wrote:

> 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. 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
>
> Below program source and output from compilation process. As You can
> see, ftdi.h file absence is rapport.
> I try to find ftdi.h file in whole system, but there is no such file at
> all. How can I obtain this file for ARMv7 architecture?

You got the package from OpenWRT, but they didn't give you ftdi.h.
So you should ask OpenWRT about that.

On a Linux system like Debian, "libftdi1" just contains the library
itself, and "libftdi1-dev" is needed to get the header files that you
can build against.  I don't know if OpenWRT provides a libftdi1-dev
package.  If not, talk to them, or download and install libftdi from
source: http://www.intra2net.com/en/developer/libftdi/download.php

Jim

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can not compile program on ARMv7 native platform

mackowiakp
Sorry for my ignorance, but I just started with libFTDI.
OK. I download ftdi.h from http://www.intra2net.com/en/developer/libftdi/download.php and place it in /opt/include. OpenWTR does not provide libftdi1-dev. Now I try to compile program again using the same compiler command. That 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

It 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?

Below output from compilation process:

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/lto-wrapper
Target: arm-openwrt-linux-gnueabi
Configured with: /media/ware3/Entware-ng.2016.08/build_dir/target-arm_cortex-a9_glibc-2.23_eabi/gcc-5.4.0/configure --target=arm-openwrt-linux --host=arm-openwrt-linux --build=x86_64-linux-gnu --program-prefix= --program-suffix= --prefix=/opt --exec-prefix=/opt --bindir=/opt/bin --sbindir=/opt/sbin --libexecdir=/opt/lib --sysconfdir=/opt/etc --datadir=/opt/share --localstatedir=/opt/var --mandir=/opt/man --infodir=/opt/info --disable-nls --build=x86_64-linux-gnu --host=arm-openwrt-linux-gnueabi --target=arm-openwrt-linux-gnueabi --enable-languages=c,c++ --with-bugurl=https://dev.openwrt.org/ --with-pkgversion='OpenWrt GCC 5.4.0' --enable-shared --enable-__cxa_atexit --with-default-libstdcxx-abi=gcc4-compatible --enable-target-optspace --with-gnu-ld --with-stage1-ldflags='-Wl,-rpath=/opt/lib -Wl,--dynamic-linker=/opt/lib/ld-linux.so.3' --with-boot-ldflags='static-libstdc++ -static-libgcc -Wl,-rpath=/opt/lib -Wl,--dynamic-linker=/opt/lib/ld-linux.so.3' --disable-nls --disable-libsanitizer --disable-libvtv --disable-libcilkrts --disable-libmudflap --disable-multilib --disable-libgomp --disable-libquadmath --disable-libssp --disable-decimal-float --disable-libstdcxx-pch --with-host-libstdcxx=-lstdc++ --prefix=/opt --libexecdir=/opt/lib --with-local-prefix=/opt --with-float=soft --with-default-libstdcxx-abi=gcc4-compatible
Thread model: posix
gcc version 5.4.0 (OpenWrt GCC 5.4.0)
COLLECT_GCC_OPTIONS='-v' '-L/opt/lib' '-O2' '-pipe' '-march=armv7-a' '-mtune=cortex-a9' '-fno-caller-saves' '-mfloat-abi=soft' '-o' 'd' '-mtls-dialect=gnu'
 /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/cc1 -quiet -v -imultilib . -imultiarch arm-linux-gnueabi d.c -quiet -dumpbase d.c -march=armv7-a -mtune=cortex-a9 -mfloat-abi=soft -mtls-dialect=gnu -auxbase d -O2 -version -fno-caller-saves -o - |
 as -v -march=armv7-a -mfloat-abi=soft -meabi=5 -o /opt/tmp/ccbT3J1L.o
GNU assembler version 2.26.1 (arm-openwrt-linux-gnueabi) using BFD version (GNU Binutils) 2.26.1
GNU C11 (OpenWrt GCC 5.4.0) version 5.4.0 (arm-openwrt-linux-gnueabi)
        compiled by GNU C version 5.4.0, GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=31954
ignoring nonexistent directory "/opt/include/arm-linux-gnueabi"
ignoring nonexistent directory "/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/../../../../arm-openwrt-linux-gnueabi/include"
ignoring nonexistent directory "/usr/include/arm-linux-gnueabi"
ignoring nonexistent directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here:
 /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/include
 /opt/include
 /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/include-fixed
End of search list.
GNU C11 (OpenWrt GCC 5.4.0) version 5.4.0 (arm-openwrt-linux-gnueabi)
        compiled by GNU C version 5.4.0, GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=31954
Compiler executable checksum: a589712d81e28a1300ccb0e03d994135
d.c: In function 'main':
d.c:4:18: warning: implicit declaration of function 'Sleep' [-Wimplicit-function-declaration]
 #define sleep(x) Sleep(x)
                  ^
d.c:34:5: note: in expansion of macro 'sleep'
     sleep(3);
     ^
COMPILER_PATH=/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/:/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/:/opt/lib/gcc/arm-openwrt-linux-gnueabi/:/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/:/opt/lib/gcc/arm-openwrt-linux-gnueabi/
LIBRARY_PATH=/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/:/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-L/opt/lib' '-O2' '-pipe' '-march=armv7-a' '-mtune=cortex-a9' '-fno-caller-saves' '-mfloat-abi=soft' '-o' 'd' '-mtls-dialect=gnu'
 /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/collect2 -plugin /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/liblto_plugin.so -plugin-opt=/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/lto-wrapper -plugin-opt=-fresolution=/opt/tmp/cc87OOFR.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --eh-frame-hdr -dynamic-linker /lib/ld-linux.so.3 -X -m armelf_linux_eabi -o d /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/crt1.o /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/crti.o /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/crtbegin.o -L/opt/lib -L/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0 -L/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/../../.. -rpath=/opt/usr/local/lib --dynamic-linker=/opt/lib/ld-linux.so.3 -lftdi1 /opt/tmp/ccbT3J1L.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/crtend.o /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/crtn.o
/opt/bin/ld: cannot find -lftdi1
collect2: error: ld returned 1 exit status
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can not compile program on ARMv7 native platform

Rob MacKinnon
If you're getting into compilation of code, definitely check out the GCC man page and docs.  Not sure your what GCC version you're using (btw on some libraries it matters), but the following is for v4.9.4.  It sounds like you're include paths do not have the correct path for the location of the libftdi headers. Read up the following and check your includes.

GCC Man Page:
https://linux.die.net/man/1/gcc

GCC Documentation:
https://gcc.gnu.org/onlinedocs/gcc-4.9.4/gcc/


On Sat, Oct 1, 2016 at 2:09 AM, mackowiakp <[hidden email]> wrote:
Sorry for my ignorance, but I just started with libFTDI.
OK. I download ftdi.h from
http://www.intra2net.com/en/developer/libftdi/download.php and place it in
/opt/include. OpenWTR does not provide libftdi1-dev. Now I try to compile
program again using the same compiler command. That 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

It 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?

Below output from compilation process:

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/lto-wrapper
Target: arm-openwrt-linux-gnueabi
Configured with:
/media/ware3/Entware-ng.2016.08/build_dir/target-arm_cortex-a9_glibc-2.23_eabi/gcc-5.4.0/configure
--target=arm-openwrt-linux --host=arm-openwrt-linux --build=x86_64-linux-gnu
--program-prefix= --program-suffix= --prefix=/opt --exec-prefix=/opt
--bindir=/opt/bin --sbindir=/opt/sbin --libexecdir=/opt/lib
--sysconfdir=/opt/etc --datadir=/opt/share --localstatedir=/opt/var
--mandir=/opt/man --infodir=/opt/info --disable-nls --build=x86_64-linux-gnu
--host=arm-openwrt-linux-gnueabi --target=arm-openwrt-linux-gnueabi
--enable-languages=c,c++ --with-bugurl=https://dev.openwrt.org/
--with-pkgversion='OpenWrt GCC 5.4.0' --enable-shared --enable-__cxa_atexit
--with-default-libstdcxx-abi=gcc4-compatible --enable-target-optspace
--with-gnu-ld --with-stage1-ldflags='-Wl,-rpath=/opt/lib
-Wl,--dynamic-linker=/opt/lib/ld-linux.so.3'
--with-boot-ldflags='static-libstdc++ -static-libgcc -Wl,-rpath=/opt/lib
-Wl,--dynamic-linker=/opt/lib/ld-linux.so.3' --disable-nls
--disable-libsanitizer --disable-libvtv --disable-libcilkrts
--disable-libmudflap --disable-multilib --disable-libgomp
--disable-libquadmath --disable-libssp --disable-decimal-float
--disable-libstdcxx-pch --with-host-libstdcxx=-lstdc++ --prefix=/opt
--libexecdir=/opt/lib --with-local-prefix=/opt --with-float=soft
--with-default-libstdcxx-abi=gcc4-compatible
Thread model: posix
gcc version 5.4.0 (OpenWrt GCC 5.4.0)
COLLECT_GCC_OPTIONS='-v' '-L/opt/lib' '-O2' '-pipe' '-march=armv7-a'
'-mtune=cortex-a9' '-fno-caller-saves' '-mfloat-abi=soft' '-o' 'd'
'-mtls-dialect=gnu'
 /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/cc1 -quiet -v -imultilib .
-imultiarch arm-linux-gnueabi d.c -quiet -dumpbase d.c -march=armv7-a
-mtune=cortex-a9 -mfloat-abi=soft -mtls-dialect=gnu -auxbase d -O2 -version
-fno-caller-saves -o - |
 as -v -march=armv7-a -mfloat-abi=soft -meabi=5 -o /opt/tmp/ccbT3J1L.o
GNU assembler version 2.26.1 (arm-openwrt-linux-gnueabi) using BFD version
(GNU Binutils) 2.26.1
GNU C11 (OpenWrt GCC 5.4.0) version 5.4.0 (arm-openwrt-linux-gnueabi)
        compiled by GNU C version 5.4.0, GMP version 4.3.2, MPFR version
2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=31954
ignoring nonexistent directory "/opt/include/arm-linux-gnueabi"
ignoring nonexistent directory
"/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/../../../../arm-openwrt-linux-gnueabi/include"
ignoring nonexistent directory "/usr/include/arm-linux-gnueabi"
ignoring nonexistent directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here:
 /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/include
 /opt/include
 /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/include-fixed
End of search list.
GNU C11 (OpenWrt GCC 5.4.0) version 5.4.0 (arm-openwrt-linux-gnueabi)
        compiled by GNU C version 5.4.0, GMP version 4.3.2, MPFR version
2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=31954
Compiler executable checksum: a589712d81e28a1300ccb0e03d994135
d.c: In function 'main':
d.c:4:18: warning: implicit declaration of function 'Sleep'
[-Wimplicit-function-declaration]
 #define sleep(x) Sleep(x)
                  ^
d.c:34:5: note: in expansion of macro 'sleep'
     sleep(3);
     ^
COMPILER_PATH=/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/:/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/:/opt/lib/gcc/arm-openwrt-linux-gnueabi/:/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/:/opt/lib/gcc/arm-openwrt-linux-gnueabi/
LIBRARY_PATH=/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/:/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-L/opt/lib' '-O2' '-pipe' '-march=armv7-a'
'-mtune=cortex-a9' '-fno-caller-saves' '-mfloat-abi=soft' '-o' 'd'
'-mtls-dialect=gnu'
 /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/collect2 -plugin
/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/liblto_plugin.so
-plugin-opt=/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/lto-wrapper
-plugin-opt=-fresolution=/opt/tmp/cc87OOFR.res
-plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s
-plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc
-plugin-opt=-pass-through=-lgcc_s --eh-frame-hdr -dynamic-linker
/lib/ld-linux.so.3 -X -m armelf_linux_eabi -o d
/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/crt1.o
/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/crti.o
/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/crtbegin.o -L/opt/lib
-L/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0
-L/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/../../..
-rpath=/opt/usr/local/lib --dynamic-linker=/opt/lib/ld-linux.so.3 -lftdi1
/opt/tmp/ccbT3J1L.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc
--as-needed -lgcc_s --no-as-needed
/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/crtend.o
/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/crtn.o
/opt/bin/ld: cannot find -lftdi1
collect2: error: ld returned 1 exit status




--
View this message in context: http://libftdi.141977.n3.nabble.com/Can-not-compile-program-on-ARMv7-native-platform-tp4026111p4026113.html
Sent from the libFTDI mailing list archive at Nabble.com.

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]




libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can not compile program on ARMv7 native platform

Chris Morgan
In reply to this post by mackowiakp
On Sat, Oct 1, 2016 at 5:09 AM, mackowiakp <[hidden email]> wrote:

> Sorry for my ignorance, but I just started with libFTDI.
> OK. I download ftdi.h from
> http://www.intra2net.com/en/developer/libftdi/download.php and place it in
> /opt/include. OpenWTR does not provide libftdi1-dev. Now I try to compile
> program again using the same compiler command. That 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
>
> It 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?
>
> Below output from compilation process:
>
> Using built-in specs.
> COLLECT_GCC=gcc
> COLLECT_LTO_WRAPPER=/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/lto-wrapper
> Target: arm-openwrt-linux-gnueabi
> Configured with:
> /media/ware3/Entware-ng.2016.08/build_dir/target-arm_cortex-a9_glibc-2.23_eabi/gcc-5.4.0/configure
> --target=arm-openwrt-linux --host=arm-openwrt-linux --build=x86_64-linux-gnu
> --program-prefix= --program-suffix= --prefix=/opt --exec-prefix=/opt
> --bindir=/opt/bin --sbindir=/opt/sbin --libexecdir=/opt/lib
> --sysconfdir=/opt/etc --datadir=/opt/share --localstatedir=/opt/var
> --mandir=/opt/man --infodir=/opt/info --disable-nls --build=x86_64-linux-gnu
> --host=arm-openwrt-linux-gnueabi --target=arm-openwrt-linux-gnueabi
> --enable-languages=c,c++ --with-bugurl=https://dev.openwrt.org/
> --with-pkgversion='OpenWrt GCC 5.4.0' --enable-shared --enable-__cxa_atexit
> --with-default-libstdcxx-abi=gcc4-compatible --enable-target-optspace
> --with-gnu-ld --with-stage1-ldflags='-Wl,-rpath=/opt/lib
> -Wl,--dynamic-linker=/opt/lib/ld-linux.so.3'
> --with-boot-ldflags='static-libstdc++ -static-libgcc -Wl,-rpath=/opt/lib
> -Wl,--dynamic-linker=/opt/lib/ld-linux.so.3' --disable-nls
> --disable-libsanitizer --disable-libvtv --disable-libcilkrts
> --disable-libmudflap --disable-multilib --disable-libgomp
> --disable-libquadmath --disable-libssp --disable-decimal-float
> --disable-libstdcxx-pch --with-host-libstdcxx=-lstdc++ --prefix=/opt
> --libexecdir=/opt/lib --with-local-prefix=/opt --with-float=soft
> --with-default-libstdcxx-abi=gcc4-compatible
> Thread model: posix
> gcc version 5.4.0 (OpenWrt GCC 5.4.0)
> COLLECT_GCC_OPTIONS='-v' '-L/opt/lib' '-O2' '-pipe' '-march=armv7-a'
> '-mtune=cortex-a9' '-fno-caller-saves' '-mfloat-abi=soft' '-o' 'd'
> '-mtls-dialect=gnu'
>  /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/cc1 -quiet -v -imultilib .
> -imultiarch arm-linux-gnueabi d.c -quiet -dumpbase d.c -march=armv7-a
> -mtune=cortex-a9 -mfloat-abi=soft -mtls-dialect=gnu -auxbase d -O2 -version
> -fno-caller-saves -o - |
>  as -v -march=armv7-a -mfloat-abi=soft -meabi=5 -o /opt/tmp/ccbT3J1L.o
> GNU assembler version 2.26.1 (arm-openwrt-linux-gnueabi) using BFD version
> (GNU Binutils) 2.26.1
> GNU C11 (OpenWrt GCC 5.4.0) version 5.4.0 (arm-openwrt-linux-gnueabi)
>         compiled by GNU C version 5.4.0, GMP version 4.3.2, MPFR version
> 2.4.2, MPC version 0.8.1
> GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=31954
> ignoring nonexistent directory "/opt/include/arm-linux-gnueabi"
> ignoring nonexistent directory
> "/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/../../../../arm-openwrt-linux-gnueabi/include"
> ignoring nonexistent directory "/usr/include/arm-linux-gnueabi"
> ignoring nonexistent directory "/usr/include"
> #include "..." search starts here:
> #include <...> search starts here:
>  /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/include
>  /opt/include
>  /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/include-fixed
> End of search list.
> GNU C11 (OpenWrt GCC 5.4.0) version 5.4.0 (arm-openwrt-linux-gnueabi)
>         compiled by GNU C version 5.4.0, GMP version 4.3.2, MPFR version
> 2.4.2, MPC version 0.8.1
> GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=31954
> Compiler executable checksum: a589712d81e28a1300ccb0e03d994135
> d.c: In function 'main':
> d.c:4:18: warning: implicit declaration of function 'Sleep'
> [-Wimplicit-function-declaration]
>  #define sleep(x) Sleep(x)
>                   ^
> d.c:34:5: note: in expansion of macro 'sleep'
>      sleep(3);
>      ^
> COMPILER_PATH=/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/:/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/:/opt/lib/gcc/arm-openwrt-linux-gnueabi/:/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/:/opt/lib/gcc/arm-openwrt-linux-gnueabi/
> LIBRARY_PATH=/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/:/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/../../../:/lib/:/usr/lib/
> COLLECT_GCC_OPTIONS='-v' '-L/opt/lib' '-O2' '-pipe' '-march=armv7-a'
> '-mtune=cortex-a9' '-fno-caller-saves' '-mfloat-abi=soft' '-o' 'd'
> '-mtls-dialect=gnu'
>  /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/collect2 -plugin
> /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/liblto_plugin.so
> -plugin-opt=/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/lto-wrapper
> -plugin-opt=-fresolution=/opt/tmp/cc87OOFR.res
> -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s
> -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc
> -plugin-opt=-pass-through=-lgcc_s --eh-frame-hdr -dynamic-linker
> /lib/ld-linux.so.3 -X -m armelf_linux_eabi -o d
> /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/crt1.o
> /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/crti.o
> /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/crtbegin.o -L/opt/lib
> -L/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0
> -L/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/../../..
> -rpath=/opt/usr/local/lib --dynamic-linker=/opt/lib/ld-linux.so.3 -lftdi1
> /opt/tmp/ccbT3J1L.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc
> --as-needed -lgcc_s --no-as-needed
> /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/crtend.o
> /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/crtn.o
> /opt/bin/ld: cannot find -lftdi1
> collect2: error: ld returned 1 exit status
>
>
>

I think you've identified the correct issue in terms of the library
not being found. I'm guessing the linker paths for gcc aren't correct.
What if you add -L/opt/usr/local/lib/ to your compilation line?

Is LD_LIBRARY_PATH used by ld when invoked during compilation? It
seems like it should be but I'm used to using that when attempting to
run an application that needs a library that I've built in a local
directory somewhere and haven't installed at the system level.

Chris

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can not compile program on ARMv7 native platform

Ryan Tennill


On 10/03/2016 04:24 AM, Chris Morgan wrote:

> On Sat, Oct 1, 2016 at 5:09 AM, mackowiakp <[hidden email]> wrote:
>> Sorry for my ignorance, but I just started with libFTDI.
>> OK. I download ftdi.h from
>> http://www.intra2net.com/en/developer/libftdi/download.php and place it in
>> /opt/include. OpenWTR does not provide libftdi1-dev. Now I try to compile
>> program again using the same compiler command. That 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
>>
>> It 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?
>>
>> Below output from compilation process:
>>
>> Using built-in specs.
>> COLLECT_GCC=gcc
>> COLLECT_LTO_WRAPPER=/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/lto-wrapper
>> Target: arm-openwrt-linux-gnueabi
>> Configured with:
>> /media/ware3/Entware-ng.2016.08/build_dir/target-arm_cortex-a9_glibc-2.23_eabi/gcc-5.4.0/configure
>> --target=arm-openwrt-linux --host=arm-openwrt-linux --build=x86_64-linux-gnu
>> --program-prefix= --program-suffix= --prefix=/opt --exec-prefix=/opt
>> --bindir=/opt/bin --sbindir=/opt/sbin --libexecdir=/opt/lib
>> --sysconfdir=/opt/etc --datadir=/opt/share --localstatedir=/opt/var
>> --mandir=/opt/man --infodir=/opt/info --disable-nls --build=x86_64-linux-gnu
>> --host=arm-openwrt-linux-gnueabi --target=arm-openwrt-linux-gnueabi
>> --enable-languages=c,c++ --with-bugurl=https://dev.openwrt.org/
>> --with-pkgversion='OpenWrt GCC 5.4.0' --enable-shared --enable-__cxa_atexit
>> --with-default-libstdcxx-abi=gcc4-compatible --enable-target-optspace
>> --with-gnu-ld --with-stage1-ldflags='-Wl,-rpath=/opt/lib
>> -Wl,--dynamic-linker=/opt/lib/ld-linux.so.3'
>> --with-boot-ldflags='static-libstdc++ -static-libgcc -Wl,-rpath=/opt/lib
>> -Wl,--dynamic-linker=/opt/lib/ld-linux.so.3' --disable-nls
>> --disable-libsanitizer --disable-libvtv --disable-libcilkrts
>> --disable-libmudflap --disable-multilib --disable-libgomp
>> --disable-libquadmath --disable-libssp --disable-decimal-float
>> --disable-libstdcxx-pch --with-host-libstdcxx=-lstdc++ --prefix=/opt
>> --libexecdir=/opt/lib --with-local-prefix=/opt --with-float=soft
>> --with-default-libstdcxx-abi=gcc4-compatible
>> Thread model: posix
>> gcc version 5.4.0 (OpenWrt GCC 5.4.0)
>> COLLECT_GCC_OPTIONS='-v' '-L/opt/lib' '-O2' '-pipe' '-march=armv7-a'
>> '-mtune=cortex-a9' '-fno-caller-saves' '-mfloat-abi=soft' '-o' 'd'
>> '-mtls-dialect=gnu'
>>   /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/cc1 -quiet -v -imultilib .
>> -imultiarch arm-linux-gnueabi d.c -quiet -dumpbase d.c -march=armv7-a
>> -mtune=cortex-a9 -mfloat-abi=soft -mtls-dialect=gnu -auxbase d -O2 -version
>> -fno-caller-saves -o - |
>>   as -v -march=armv7-a -mfloat-abi=soft -meabi=5 -o /opt/tmp/ccbT3J1L.o
>> GNU assembler version 2.26.1 (arm-openwrt-linux-gnueabi) using BFD version
>> (GNU Binutils) 2.26.1
>> GNU C11 (OpenWrt GCC 5.4.0) version 5.4.0 (arm-openwrt-linux-gnueabi)
>>          compiled by GNU C version 5.4.0, GMP version 4.3.2, MPFR version
>> 2.4.2, MPC version 0.8.1
>> GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=31954
>> ignoring nonexistent directory "/opt/include/arm-linux-gnueabi"
>> ignoring nonexistent directory
>> "/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/../../../../arm-openwrt-linux-gnueabi/include"
>> ignoring nonexistent directory "/usr/include/arm-linux-gnueabi"
>> ignoring nonexistent directory "/usr/include"
>> #include "..." search starts here:
>> #include <...> search starts here:
>>   /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/include
>>   /opt/include
>>   /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/include-fixed
>> End of search list.
>> GNU C11 (OpenWrt GCC 5.4.0) version 5.4.0 (arm-openwrt-linux-gnueabi)
>>          compiled by GNU C version 5.4.0, GMP version 4.3.2, MPFR version
>> 2.4.2, MPC version 0.8.1
>> GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=31954
>> Compiler executable checksum: a589712d81e28a1300ccb0e03d994135
>> d.c: In function 'main':
>> d.c:4:18: warning: implicit declaration of function 'Sleep'
>> [-Wimplicit-function-declaration]
>>   #define sleep(x) Sleep(x)
>>                    ^
>> d.c:34:5: note: in expansion of macro 'sleep'
>>       sleep(3);
>>       ^
>> COMPILER_PATH=/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/:/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/:/opt/lib/gcc/arm-openwrt-linux-gnueabi/:/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/:/opt/lib/gcc/arm-openwrt-linux-gnueabi/
>> LIBRARY_PATH=/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/:/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/../../../:/lib/:/usr/lib/
>> COLLECT_GCC_OPTIONS='-v' '-L/opt/lib' '-O2' '-pipe' '-march=armv7-a'
>> '-mtune=cortex-a9' '-fno-caller-saves' '-mfloat-abi=soft' '-o' 'd'
>> '-mtls-dialect=gnu'
>>   /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/collect2 -plugin
>> /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/liblto_plugin.so
>> -plugin-opt=/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/lto-wrapper
>> -plugin-opt=-fresolution=/opt/tmp/cc87OOFR.res
>> -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s
>> -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc
>> -plugin-opt=-pass-through=-lgcc_s --eh-frame-hdr -dynamic-linker
>> /lib/ld-linux.so.3 -X -m armelf_linux_eabi -o d
>> /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/crt1.o
>> /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/crti.o
>> /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/crtbegin.o -L/opt/lib
>> -L/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0
>> -L/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/../../..
>> -rpath=/opt/usr/local/lib --dynamic-linker=/opt/lib/ld-linux.so.3 -lftdi1
>> /opt/tmp/ccbT3J1L.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc
>> --as-needed -lgcc_s --no-as-needed
>> /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/crtend.o
>> /opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/crtn.o
>> /opt/bin/ld: cannot find -lftdi1
>> collect2: error: ld returned 1 exit status
>>
>>
>>
> I think you've identified the correct issue in terms of the library
> not being found. I'm guessing the linker paths for gcc aren't correct.
> What if you add -L/opt/usr/local/lib/ to your compilation line?
>
> Is LD_LIBRARY_PATH used by ld when invoked during compilation? It
> seems like it should be but I'm used to using that when attempting to
> run an application that needs a library that I've built in a local
> directory somewhere and haven't installed at the system level.
>
> Chris
>
> --
> libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
> To unsubscribe send a mail to [hidden email]
>
Try running ldconfig -v on your system. The -v option makes it display
all the links that it creates for libraries. You can pipe the output to
grep to see if libfti is actually on the linker search path.

Also looks like a #define needs fixing or you need to include <unistd.h>
or equivalent for sleep().

> d.c: In function 'main':
> d.c:4:18: warning: implicit declaration of function 'Sleep'
> [-Wimplicit-function-declaration]
>   #define sleep(x) Sleep(x)
>                    ^
> d.c:34:5: note: in expansion of macro 'sleep'
>       sleep(3);

Ryan

--

217-351-2655 ext. 126
Distant Focus Corporation
4114B Fieldstone Rd
Champaign, IL 61822
http://jupiter.distantfocus.com/projects/


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can not compile program on ARMv7 native platform

mackowiakp
OK. Problem resolved! I dont know why (probably bug) but 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. But I have another problem. It will be described in another post.
Loading...