Why arm-linux-gnueabi-gcc cannot compile even simple test file? - linux

I installed cross-compilation tools on my Ubuntu system using:
sudo apt-get install gcc-arm-linux-gnueabi binutils-arm-linux-gnueabi
And then i made simple .c file which compiles ok, but when gcc runs assembler stage, it is for unknown reason invokes 'as' command, instead of appropriate 'arm-linux-gnueabi-as' command and as result compilation fails with following errors:
arm-linux-gnueabi-gcc -v test.c
Using built-in specs.
COLLECT_GCC=arm-linux-gnueabi-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/arm-linux-gnueabi/6/lto-wrapper
Target: arm-linux-gnueabi
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 6.3.0-12ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-6 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libquadmath --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-armel-cross/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-armel-cross --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-armel-cross --with-arch-directory=arm --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libgcj --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --enable-multilib --disable-sjlj-exceptions --with-arch=armv5t --with-float=soft --disable-werror --enable-multilib --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=arm-linux-gnueabi --program-prefix=arm-linux-gnueabi- --includedir=/usr/arm-linux-gnueabi/include
Thread model: posix
gcc version 6.3.0 20170406 (Ubuntu/Linaro 6.3.0-12ubuntu2)
COLLECT_GCC_OPTIONS='-v' '-march=armv5t' '-mfloat-abi=soft' '-mtls-dialect=gnu'
/usr/lib/gcc-cross/arm-linux-gnueabi/6/cc1 -quiet -v -imultiarch arm-linux-gnueabi test.c -quiet -dumpbase test.c -march=armv5t -mfloat-abi=soft -mtls-dialect=gnu -auxbase test -version -fstack-protector-strong -Wformat -Wformat-security -o /tmp/cccUVSll.s
GNU C11 (Ubuntu/Linaro 6.3.0-12ubuntu2) version 6.3.0 20170406 (arm-linux-gnueabi)
compiled by GNU C version 6.3.0 20170406, GMP version 6.1.2, MPFR version 3.1.5, MPC version 1.0.3, isl version 0.15
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include/arm-linux-gnueabi"
ignoring nonexistent directory "/usr/lib/gcc-cross/arm-linux-gnueabi/6/../../../../arm-linux-gnueabi/include"
ignoring nonexistent directory "/usr/include/arm-linux-gnueabi"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc-cross/arm-linux-gnueabi/6/include
/usr/lib/gcc-cross/arm-linux-gnueabi/6/include-fixed
/usr/include
End of search list.
GNU C11 (Ubuntu/Linaro 6.3.0-12ubuntu2) version 6.3.0 20170406 (arm-linux-gnueabi)
compiled by GNU C version 6.3.0 20170406, GMP version 6.1.2, MPFR version 3.1.5, MPC version 1.0.3, isl version 0.15
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 50226affb1339dba25cfdfb2ad79e687
COLLECT_GCC_OPTIONS='-v' '-march=armv5t' '-mfloat-abi=soft' '-mtls-dialect=gnu'
as -v -march=armv5t -mfloat-abi=soft -meabi=5 -o /tmp/cczGBXSH.o /tmp/cccUVSll.s
GNU assembler version 2.28 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.28
Assembler messages:
Fatal error: invalid -march= option: `armv5t'
As you can see, it fails, because it invoking wrong command - as, which knows only about x86_64-linux-gnu target, and does not recognizing armv5t architecture option.
How to force gcc toolchain to use correct cross-platform assembler/linker to produce binary, instead of 'as' 'ld' etc?
Is there something in my environment, that causing such behavior?
P.S. On my college's machine, installing same toolchain works without problem, however he has Ubuntu 16.04, while mine are 17.04..
And GCC executing following command for assembler:
/usr/lib/gcc-cross/arm-linux-gnueabi/5/../../../../arm-linux-gnueabi/bin/as
-v -march=armv5t -mfloat-abi=soft -meabi=5 -o /tmp/ccXru9b3.o /tmp/ccUwNPuq.s
As you can see, it takes right assembler and all is ok.. but not on my system..

Related

Using `riscv64-unknown-elf-g++` to link rust static lib failed

I try to use riscv64-unknown-elf-g++ which is rv64imac architecture to compile C code with rust static lib.
The simple example is https://github.com/zzhengzhuo/base_bin .
When I use riscv64-unknown-elf-gcc, it works well. But when I use riscv64-unknown-elf-g++, it reports errors like this:
riscv64-unknown-elf-g++ -Ibase_lib -v -o build/base_bin main.c base_lib/target/riscv64imac-unknown-none-elf/release/libbase_lib.a
Using built-in specs.
COLLECT_GCC=riscv64-unknown-elf-g++
COLLECT_LTO_WRAPPER=/opt/riscv/libexec/gcc/riscv64-unknown-elf/11.1.0/lto-wrapper
Target: riscv64-unknown-elf
Configured with: /home/zhengzhuo/riscv-gnu-toolchain/riscv-gcc/configure --target=riscv64-unknown-elf --prefix=/opt/riscv --disable-shared --disable-threads --enable-languages=c,c++ --with-system-zlib --enable-tls --with-newlib --with-sysroot=/opt/riscv/riscv64-unknown-elf --with-native-system-header-dir=/include --disable-libmudflap --disable-libssp --disable-libquadmath --disable-libgomp --disable-nls --disable-tm-clone-registry --src=.././riscv-gcc --enable-multilib --with-abi=lp64 --with-arch=rv64imac --with-tune=rocket 'CFLAGS_FOR_TARGET=-Os -mcmodel=medlow' 'CXXFLAGS_FOR_TARGET=-Os -mcmodel=medlow'
Thread model: single
Supported LTO compression algorithms: zlib
gcc version 11.1.0 (GCC)
COLLECT_GCC_OPTIONS='-I' 'base_lib' '-v' '-o' 'build/base_bin' '-mtune=rocket' '-march=rv64imac' '-mabi=lp64' '-march=rv64imac' '-dumpdir' 'build/base_bin-'
/opt/riscv/libexec/gcc/riscv64-unknown-elf/11.1.0/cc1plus -quiet -v -I base_lib main.c -quiet -dumpdir build/base_bin- -dumpbase main.c -dumpbase-ext .c -mtune=rocket -march=rv64imac -mabi=lp64 -march=rv64imac -version -o /tmp/ccpwBEao.s
GNU C++17 (GCC) version 11.1.0 (riscv64-unknown-elf)
compiled by GNU C version 9.4.0, GMP version 6.2.0, MPFR version 4.0.2, MPC version 1.1.0, isl version none
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/opt/riscv/riscv64-unknown-elf/usr/local/include"
ignoring duplicate directory "/opt/riscv/riscv64-unknown-elf/include"
#include "..." search starts here:
#include <...> search starts here:
base_lib
/opt/riscv/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/include/c++/11.1.0
/opt/riscv/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/include/c++/11.1.0/riscv64-unknown-elf
/opt/riscv/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/include/c++/11.1.0/backward
/opt/riscv/lib/gcc/riscv64-unknown-elf/11.1.0/include
/opt/riscv/lib/gcc/riscv64-unknown-elf/11.1.0/include-fixed
/opt/riscv/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/include
End of search list.
GNU C++17 (GCC) version 11.1.0 (riscv64-unknown-elf)
compiled by GNU C version 9.4.0, GMP version 6.2.0, MPFR version 4.0.2, MPC version 1.1.0, isl version none
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 70c8dfad8a0cf9a76df8ead2812f5775
COLLECT_GCC_OPTIONS='-I' 'base_lib' '-v' '-o' 'build/base_bin' '-mtune=rocket' '-march=rv64imac' '-mabi=lp64' '-march=rv64imac' '-dumpdir' 'build/base_bin-'
/opt/riscv/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/bin/as -v -I base_lib --traditional-format -march=rv64imac -march=rv64imac -mabi=lp64 -o /tmp/cc4pRmao.o /tmp/ccpwBEao.s
GNU assembler version 2.37 (riscv64-unknown-elf) using BFD version (GNU Binutils) 2.37
COMPILER_PATH=/opt/riscv/libexec/gcc/riscv64-unknown-elf/11.1.0/:/opt/riscv/libexec/gcc/riscv64-unknown-elf/11.1.0/:/opt/riscv/libexec/gcc/riscv64-unknown-elf/:/opt/riscv/lib/gcc/riscv64-unknown-elf/11.1.0/:/opt/riscv/lib/gcc/riscv64-unknown-elf/:/opt/riscv/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/bin/
LIBRARY_PATH=/opt/riscv/lib/gcc/riscv64-unknown-elf/11.1.0/:/opt/riscv/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/lib/:/opt/riscv/riscv64-unknown-elf/lib/
COLLECT_GCC_OPTIONS='-I' 'base_lib' '-v' '-o' 'build/base_bin' '-mtune=rocket' '-march=rv64imac' '-mabi=lp64' '-march=rv64imac' '-dumpdir' 'build/base_bin.'
/opt/riscv/libexec/gcc/riscv64-unknown-elf/11.1.0/collect2 -plugin /opt/riscv/libexec/gcc/riscv64-unknown-elf/11.1.0/liblto_plugin.so -plugin-opt=/opt/riscv/libexec/gcc/riscv64-unknown-elf/11.1.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccQyuKYm.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgloss -plugin-opt=-pass-through=-lgcc --sysroot=/opt/riscv/riscv64-unknown-elf -melf64lriscv -o build/base_bin /opt/riscv/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/lib/crt0.o /opt/riscv/lib/gcc/riscv64-unknown-elf/11.1.0/crtbegin.o -L/opt/riscv/lib/gcc/riscv64-unknown-elf/11.1.0 -L/opt/riscv/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/lib -L/opt/riscv/riscv64-unknown-elf/lib /tmp/cc4pRmao.o base_lib/target/riscv64imac-unknown-none-elf/release/libbase_lib.a -lstdc++ -lm -lgcc --start-group -lc -lgloss --end-group -lgcc /opt/riscv/lib/gcc/riscv64-unknown-elf/11.1.0/crtend.o
/opt/riscv/lib/gcc/riscv64-unknown-elf/11.1.0/../../../../riscv64-unknown-elf/bin/ld: /tmp/cc4pRmao.o: in function `.L0 ':
main.c:(.text+0xa): undefined reference to `echo(unsigned int)'
collect2: error: ld returned 1 exit status
make: *** [Makefile:5: build/base_bin] Error 1
Thanks for any help.
Adding extern "C" in the header file will work, more details see What is the effect of extern "C" in C++? .
related to https://github.com/riscv-collab/riscv-gnu-toolchain/issues/1021.
Thanks for everyone helped me.

gdb can't cross-compile for arm-linux

The Linux already having both gcc & arm-gcc in the environment path:
[fit#localhost gdb-arm]$ gcc -v
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-cpu=generic --build=i386-redhat-linux
Thread model: posix
gcc version 4.3.0 20080428 (Red Hat 4.3.0-8) (GCC)
[fit#localhost gdb-arm]$ arm-none-linux-gnueabi-gcc -v
Using built-in specs.
Target: arm-none-linux-gnueabi
Configured with: /scratch/mitchell/builds/4.3-arm-none-linux-gnueabi-respin/src/gcc-4.3/configure --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=arm-none-linux-gnueabi --enable-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch --with-gnu-as --with-gnu-ld --with-specs='%{funwind-tables|fno-unwind-tables|mabi=*|ffreestanding|nostdlib:;:-funwind-tables}' --enable-languages=c,c++ --enable-shared --enable-symvers=gnu --enable-__cxa_atexit --with-pkgversion='Sourcery G++ Lite 2009q1-203' --with-bugurl=https://support.codesourcery.com/GNUToolchain/ --disable-nls --prefix=/opt/codesourcery --with-sysroot=/opt/codesourcery/arm-none-linux-gnueabi/libc --with-build-sysroot=/scratch/mitchell/builds/4.3-arm-none-linux-gnueabi-respin/lite/install/arm-none-linux-gnueabi/libc --with-gmp=/scratch/mitchell/builds/4.3-arm-none-linux-gnueabi-respin/lite/obj/host-libs-2009q1-203-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --with-mpfr=/scratch/mitchell/builds/4.3-arm-none-linux-gnueabi-respin/lite/obj/host-libs-2009q1-203-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --disable-libgomp --enable-poison-system-directories --with-build-time-tools=/scratch/mitchell/builds/4.3-arm-none-linux-gnueabi-respin/lite/install/arm-none-linux-gnueabi/bin --with-build-time-tools=/scratch/mitchell/builds/4.3-arm-none-linux-gnueabi-respin/lite/install/arm-none-linux-gnueabi/bin
Thread model: posix
gcc version 4.3.3 (Sourcery G++ Lite 2009q1-203)
So I configure the gdb 6.6:
$ ./configure --target=arm-none-linux-gnueabi --host=i386-redhat-linux -v
compiled without error, but looks like gdb used the wrong compiler.
file ./gdb-build/bin/arm-none-linux-gnueabi-gdb
./gdb-build/bin/arm-none-linux-gnueabi-gdb: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped
So How to indicate the correct CC for gdb?
I tried make CC=arm-none-linux-gnueabi-gcc, but will get the error:
arm-none-linux-gnueabi-gcc ../.././sim/arm/../common/gentmap.c -o gentmap -g -O -I. -I../.././sim/arm -I../common -I../.././sim/arm/../common -I../../include -I../.././sim/arm/../../include -I../../bfd -I../.././sim/arm/../../bfd -I../../opcodes -I../.././sim/arm/../../opcodes
rm -f tmp-tvals.h tmp-tmap.c
./gentmap -h >tmp-tvals.h
/bin/sh: ./gentmap: cannot execute binary file
./configure --target=arm-none-linux-gnueabi --host=i386-redhat-linux -v
Don't use --target. It means something else to Autotools.
Use --build and --host. Something like:
./configure --build=$(config.guess) --host=arm-none-linux-gnueabi
--build should specify the machine you are running Autotools on, and --host should specify the machine the package will run on.
Note there is some Autootols bug that requires you to specify both --build and --host. It is yet another Autotools problem that has never been fixed.
Also see 2.2.8, Cross-Compilation in the Autools manual.
You will still need to get the paths and sysroot right, but this should provide the proper configure command so things begin to fail as expected.
config.guess will return a triplet for the machine you are running Autotools on:
$ find /usr/share/ -name config.guess
/usr/share/libtool/build-aux/config.guess
...
$ /usr/share/libtool/build-aux/config.guess
x86_64-pc-linux-gnu
If you find the package has one but it is out of date you can update it with the following command. You usually need to do this for AIX and Solaris machines.
wget 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess' -O config.guess
And you can update config.sub the same way:
wget 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub' -O config.sub

Cannot link libsqlite3.so in gcc

I'm trying to compile the following program with gcc 4.8.2 on Ubuntu 14.04.1
with the package libsqlite3-dev installed:
#include <sqlite3.h>
int main(int argc, char *argv[])
{
struct sqlite3 *s3;
char *filename = ":memory:";
sqlite3_open(filename, &s3);
return 0;
}
When running gcc -L/usr/lib/x86_64-linux-gnu -lsqlite3 program.c I get
the error:
/tmp/ccjvJqkW.o: In function `main':
program.c:(.text+0x26): undefined reference to `sqlite3_open'
collect2: error: ld returned 1 exit status
It looks to me like I have the correct library installed:
autobound#Calcium:~$ locate libsqlite3.so
/usr/lib/i386-linux-gnu/libsqlite3.so.0
/usr/lib/i386-linux-gnu/libsqlite3.so.0.8.6
/usr/lib/x86_64-linux-gnu/libsqlite3.so
/usr/lib/x86_64-linux-gnu/libsqlite3.so.0
/usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6
autobound#Calcium:~$ readelf -a /usr/lib/x86_64-linux-gnu/libsqlite3.so | grep sqlite3_open
71: 00000000000947b0 5 FUNC GLOBAL DEFAULT 11 sqlite3_open_v2
157: 00000000000947a0 12 FUNC GLOBAL DEFAULT 11 sqlite3_open
194: 00000000000947c0 181 FUNC GLOBAL DEFAULT 11 sqlite3_open16
Running clang with the same arguments (clang -L/usr/lib/x86_64-linux-gnu -lsqlite3 program.c)
builds the executable just fine. In fact, the -L argument isn't even
needed for clang to build it.
The verbose output of gcc is:
autobound#Calcium:~/src/c/sqlitetest (master)$ gcc --verbose -L/usr/lib/x86_64-linux-gnu -lsqlite3 program.c
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.2-19ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1)
COLLECT_GCC_OPTIONS='-v' '-L/usr/lib/x86_64-linux-gnu' '-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-linux-gnu/4.8/cc1 -quiet -v -imultiarch x86_64-linux-gnu program.c -quiet -dumpbase program.c -mtune=generic -march=x86-64 -auxbase program -version -fstack-protector -Wformat -Wformat-security -o /tmp/ccIBEqw6.s
GNU C (Ubuntu 4.8.2-19ubuntu1) version 4.8.2 (x86_64-linux-gnu)
compiled by GNU C version 4.8.2, GMP version 5.1.3, MPFR version 3.1.2-p3, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/x86_64-linux-gnu/4.8/include
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
GNU C (Ubuntu 4.8.2-19ubuntu1) version 4.8.2 (x86_64-linux-gnu)
compiled by GNU C version 4.8.2, GMP version 5.1.3, MPFR version 3.1.2-p3, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: dc75e0628c9356affcec059d0c81cc01
COLLECT_GCC_OPTIONS='-v' '-L/usr/lib/x86_64-linux-gnu' '-mtune=generic' '-march=x86-64'
as -v --64 -o /tmp/cca2r2gq.o /tmp/ccIBEqw6.s
GNU assembler version 2.24 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.24
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-L/usr/lib/x86_64-linux-gnu' '-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-linux-gnu/4.8/collect2 --sysroot=/ --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -dynamic-linker /lib64/ld-linux-x86-64.so.2 -z relro /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.8/crtbegin.o -L/usr/lib/x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.8 -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../.. -lsqlite3 /tmp/cca2r2gq.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-linux-gnu/4.8/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crtn.o
/tmp/cca2r2gq.o: In function `main':
program.c:(.text+0x26): undefined reference to `sqlite3_open'
collect2: error: ld returned 1 exit status
Try to change order of parameters
gcc program.c -L/usr/lib/x86_64-linux-gnu -lsqlite3

Some headers in PWD are skipped by arm-linux-gnueabi?

I'm trying to compile a library on Ubuntu 14.04 with packages gcc-arm-linux-gnueabi and g++-arm-linux-gnueabi installed.
The compile fails on the first source file it encounters:
/usr/bin/arm-linux-gnueabi-g++ -DNDEBUG -g2 -Os -pipe -fPIC -I. -DCRYPTOPP_DISABLE_ASM
-mcpu=cortex-m3 -mthumb --sysroot=/usr/arm-linux-gnueabi -c 3way.cpp
In file included from cryptlib.h:83:0,
from seckey.h:8,
from 3way.h:7,
from 3way.cpp:5:
stdcpp.h:14:18: fatal error: memory: No such file or directory
compilation terminated.
Here's what the include line looks like in cryptlib.h:
#ifndef CRYPTOPP_CRYPTLIB_H
#define CRYPTOPP_CRYPTLIB_H
#include "config.h"
#include "stdcpp.h"
...
Obviously, stdcpp.h exists:
$ pwd
/home/jwalton/cryptopp-embedded
$ ls 3way.h cryptlib.h stdcpp.h
3way.h cryptlib.h stdcpp.h
Adding -v shows:
...
ignoring nonexistent directory "/usr/arm-linux-gnueabi/usr/include"
#include "..." search starts here:
#include <...> search starts here:
.
/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/include
...
End of search list.
I've cross compiled the library on other platforms (like Android, iOS and Windows Phone), so I have a good idea of what needs to be done. This is my first time with arm-linux-gnueabi, however.
Why is arm-linux-gnueabi skipping the header in the present working directory? How can I resolve the issue?
Full output from arm-linux-gnueabi-g++ -v:
/usr/bin/arm-linux-gnueabi-g++ -v -DNDEBUG -g2 -Os -pipe -fPIC -I. -DCRYPTOPP_DISABLE_ASM
-mcpu=cortex-m3 -mthumb --sysroot=/usr/arm-linux-gnueabi -c 3way.cpp
Using built-in specs.
COLLECT_GCC=/usr/bin/arm-linux-gnueabi-g++
Target: arm-linux-gnueabi
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.7.3-12ubuntu1'
--with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++
--prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/arm-linux-gnueabi/include/c++/4.7.3
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-gnu-unique-object
--disable-libmudflap --disable-libitm --enable-plugin --with-system-zlib --enable-objc-gc --with-cloog
--enable-cloog-backend=ppl --disable-cloog-version-check --disable-ppl-version-check --enable-multiarch --enable-multilib
--disable-sjlj-exceptions --with-arch=armv5t --with-float=soft --disable-werror --enable-checking=release
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=arm-linux-gnueab --program-prefix=arm-linux-gnueabi-
--includedir=/usr/arm-linux-gnueabi/include
Thread model: posix
gcc version 4.7.3 (Ubuntu/Linaro 4.7.3-12ubuntu1)
COLLECT_GCC_OPTIONS='-v' '-D' 'NDEBUG' '-g2' '-Os' '-pipe' '-fPIC' '-I' '.' '-D' 'CRYPTOPP_DISABLE_ASM'
'-mcpu=cortex-m3' '-mthumb' '-c' '-shared-libgcc' '-mfloat-abi=soft' '-mtls-dialect=gnu'
/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/cc1plus -quiet -v -I . -imultilib sf -imultiarch
arm-linux-gnueabi
-isysroot /usr/arm-linux-gnueabi -D_GNU_SOURCE -D NDEBUG -D CRYPTOPP_DISABLE_ASM
3way.cpp -quiet
-dumpbase 3way.cpp -mcpu=cortex-m3 -mthumb -mfloat-abi=soft -mtls-dialect=gnu -auxbase 3way
-g2 -Os -version -fPIC -fstack-protector -o - |
/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/bin/as -v -I . -mcpu=cortex-m3
-mfloat-abi=soft -meabi=5 -o 3way.o
GNU assembler version 2.24 (arm-linux-gnueabi) using BFD version (GNU Binutils for Ubuntu) 2.24
GNU C++ (Ubuntu/Linaro 4.7.3-12ubuntu1) version 4.7.3 (arm-linux-gnueabi)
compiled by GNU C version 4.8.2, GMP version 5.1.3, MPFR version 3.1.2-p3, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/arm-linux-gnueabi/usr/arm-linux-gnueabi/include/c++/4.7.3"
ignoring nonexistent directory "/usr/arm-linux-gnueabi/usr/arm-linux-gnueabi/include/c++/4.7.3/arm-linux-gnueabi/sf"
ignoring nonexistent directory "/usr/arm-linux-gnueabi/usr/arm-linux-gnueabi/include/c++/4.7.3/backward"
ignoring nonexistent directory "/usr/arm-linux-gnueabi/usr/local/include/arm-linux-gnueabi"
ignoring nonexistent directory "/usr/arm-linux-gnueabi/usr/include/arm-linux-gnueabi"
ignoring nonexistent directory "/usr/arm-linux-gnueabi/usr/include"
#include "..." search starts here:
#include <...> search starts here:
.
/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/include
/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/include-fixed
/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/include
End of search list.
GNU C++ (Ubuntu/Linaro 4.7.3-12ubuntu1) version 4.7.3 (arm-linux-gnueabi)
compiled by GNU C version 4.8.2, GMP version 5.1.3, MPFR version 3.1.2-p3, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: dd2bb0d8e9ec09589fb3eaca028d0191
In file included from cryptlib.h:83:0,
from seckey.h:8,
from 3way.h:7,
from 3way.cpp:5:
stdcpp.h:14:18: fatal error: memory: No such file or directory
compilation terminated.
make: *** [3way.o] Error 1
stdcpp.h:14:18: fatal error: memory: No such file or directory
Arg... The missing header is memory, and not stdcpp.h. (Damn C++ header names...).
And the un-found <memory> appears to be a bug in Ubuntu's g++arm-linux-gnueabi: g++-arm-linux-gnueabi cannot compile a C++ program with --sysroot.

gfortran: debian 6.0.8 - compilation fails

I am trying to use several programs for watershed generation, genericaly called TOPAZ, from
ftp://solar1.msa-oxford.ars.usda.gov/pub/outgoing/TOPAZ/TOPAZ312/Ascii/
the source code is available, so everybody can try
The code is not mine, and i thank publicly here to the authors for their work.
Machine for development is debian 6.0.8, kernel 2.6.32-5-amd64
The source code of all programs conforms strictly to FORTRAN 90 standards, acording to the documentation.
installed gfortran, and when compiling i get
root#geo:/usr/src/topaz.src/tmp# gfortran -v DEDNM.F90
Driving: gfortran -v DEDNM.F90 -lgfortranbegin -lgfortran -lm -shared-libgcc
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.4.5-8' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.4 --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.5 (Debian 4.4.5-8)
COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mtune=generic'
/usr/lib/gcc/x86_64-linux-gnu/4.4.5/f951 DEDNM.F90 -cpp /tmp/ccLDYiVO.f90 -quiet -v DEDNM.F90 -quiet -dumpbase DEDNM.F90 -mtune=generic -auxbase DEDNM -version -fintrinsic-modules-path /usr/lib/gcc/x86_64-linux-gnu/4.4.5/finclude -o /tmp/ccy4DOzn.s
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../../x86_64-linux-gnu/include"
ignoring nonexistent directory "/usr/include/x86_64-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/x86_64-linux-gnu/4.4.5/finclude
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/4.4.5/include
/usr/lib/gcc/x86_64-linux-gnu/4.4.5/include-fixed
/usr/include
End of search list.
GNU Fortran (Debian 4.4.5-8) version 4.4.5 (x86_64-linux-gnu)
compiled by GNU C version 4.4.5, GMP version 4.3.2, MPFR version 3.0.0-p3.
GGC heuristics: --param ggc-min-expand=55 --param ggc-min-heapsize=47475
DEDNM.F90:12415.1:
\x1A
1
Error: Invalid character in name at (1)
i get a similar error on compiling the other programs,
the source is ANSI Standard Fortran90, acording to documentation
i don't know much of fortran, but i would like to use a linux machine rather than going back to windows, and so need to compile the programs instead of using precompliled ones for win95
many thanks
André

Resources