My build is failing to link, probably because it's attempting to link against the wrong version of libaries (namely, libssl). The makefile's LIBS directive specifies -lssl, which isn't explicit enough: I have many of these on my system (various system SDKs + newly downloaded version).
My general question is, is there a verbosity option for having make print the explicit paths of the libs used for linking?
Gil.
To see the link step in detail you would usually pass a "verbose" option to the compiler or linker. What system are you using? If gcc, add -v to the compile command. This will produce output like
$ gcc -v hello.c
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --disable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=i386-redhat-linux
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-50)
/usr/libexec/gcc/i386-redhat-linux/4.1.2/cc1 -quiet -v hello.c -quiet -dumpbase hello.c -mtune=generic -auxbase hello -version -o /tmp/ccAtBXVy.s
ignoring nonexistent directory "/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../i386-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/lib/gcc/i386-redhat-linux/4.1.2/include
/usr/include
End of search list.
GNU C version 4.1.2 20080704 (Red Hat 4.1.2-50) (i386-redhat-linux)
compiled by GNU C version 4.1.2 20080704 (Red Hat 4.1.2-50).
GGC heuristics: --param ggc-min-expand=81 --param ggc-min-heapsize=95810
Compiler executable checksum: d8d95095eb3c93dae4bed2137d559f95
as -V -Qy -o /tmp/ccDL1N2O.o /tmp/ccAtBXVy.s
GNU assembler version 2.17.50.0.6-14.el5 (i386-redhat-linux) using BFD version 2.17.50.0.6-14.el5 20061020
/usr/libexec/gcc/i386-redhat-linux/4.1.2/collect2 --eh-frame-hdr -m elf_i386 --hash-style=gnu -dynamic-linker /lib/ld-linux.so.2 /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crt1.o /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crti.o /usr/lib/gcc/i386-redhat-linux/4.1.2/crtbegin.o -L/usr/lib/gcc/i386-redhat-linux/4.1.2 -L/usr/lib/gcc/i386-redhat-linux/4.1.2 -L/usr/lib/gcc/i386-redhat-linux/4.1.2/../../.. /tmp/ccDL1N2O.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/i386-redhat-linux/4.1.2/crtend.o /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crtn.o
Where the last line is the link command in all its glory. The -L options specify the directories where the libs given by -l are searched, in order.
Related
I have system with CentOS 6.4 and it comes with GNU Fortran (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18).
I am doing quadrupule precision calculation and for that I installed devtoolset-6 w/o a problem. Since the system has a default gcc/gfortran installed, i cleared the shell with
env -i bash
and following that i set the devtoolset-6 environment
scl enable devtoolset-6 bash
If i check the installed gcc and gfortran version, they are as following
gcc (GCC) 6.3.1 20170216 (Red Hat 6.3.1-3)
GNU Fortran (GCC) 6.3.1 20170216 (Red Hat 6.3.1-3)
so far so good. I also have a testing example given below
implicit double precision(a-h,o-z)
print * , ' i:'
read(5,*) i
if(i.le.0) stop
a=i
b=sqrt(a)
print * , b
c=b*b
print * , c
end
compiled with
gfortran -fdefault-real-8 -o test.exe test.F
When i try to compile i am getting the following error
(.text+0x20): undefined reference to main'
/tmp/cc7n6vIv.o: In functionljacoeff_':test.F:(.text+0xf0): undefined reference to _gfortran_transfer_real128_write'
test.F:(.text+0x16b): undefined reference to_gfortran_transfer_complex128_write'
test.F:(.text+0x1ea): undefined reference to `_gfortran_transfer_complex128_write'
collect2: error: ld returned 1 exit status
At first, i thought the _gfortran_transfer_real128_write function is not defined and checked the library comes with devtoolset-6 using default "nm" command and indeed that function is defined in libgfortran.a. After some debugging and more debugging i discovered the "-v" option and recompiled the code, then noticed something confusing looks like ld checks the system old libraries instead of the one comes with devtoolset-6. The LIBRARY_PATH includes the /usr/lib/../lib64/ folder and that causes the error. In any case, If the linker couldn't find these function, it should also check the devtoolset-6 libraries. Looks like this doesn't happen. How could i resolve this linking error?
Driving: gfortran -v -fdefault-real-8 -o test.exe test.F -l gfortran
-l m -shared-libgcc Using built-in specs. COLLECT_GCC=gfortran COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-6/root/usr/libexec/gcc/x86_64-redhat-linux/6.3.1/lto-wrapper
Target: x86_64-redhat-linux Configured with: ../configure
--enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-6/root/usr --mandir=/opt/rh/devtoolset-6/root/usr/share/man --infodir=/opt/rh/devtoolset-6/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --enable-plugin --with-linker-hash-style=gnu --enable-initfini-array --disable-libgcj --with-default-libstdcxx-abi=gcc4-compatible --with-isl=/builddir/build/BUILD/gcc-6.3.1-20170216/obj-x86_64-redhat-linux/isl-install
--enable-libmpx --with-mpc=/builddir/build/BUILD/gcc-6.3.1-20170216/obj-x86_64-redhat-linux/mpc-install
--with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux Thread model: posix gcc version 6.3.1 20170216 (Red Hat 6.3.1-3) (GCC)
COLLECT_GCC_OPTIONS='-v' '-fdefault-real-8' '-o' 'test.exe'
'-shared-libgcc' '-mtune=generic' '-march=x86-64'
/opt/rh/devtoolset-6/root/usr/libexec/gcc/x86_64-redhat-linux/6.3.1/f951
test.F -ffixed-form -cpp=/tmp/ccjQiTpi.f90 -quiet -v test.F -quiet
-dumpbase test.F -mtune=generic -march=x86-64 -auxbase test -version -fdefault-real-8 -fintrinsic-modules-path /opt/rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/6.3.1/finclude
-o /tmp/cceJeO1o.s GNU Fortran (GCC) version 6.3.1 20170216 (Red Hat 6.3.1-3) (x86_64-redhat-linux) compiled by GNU C version 6.3.1 20170216 (Red Hat 6.3.1-3), GMP version 4.3.1, MPFR version 2.4.1, MPC
version 0.8.1, isl version 0.14 or 0.13 GGC heuristics: --param
ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring
nonexistent directory
"/opt/rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/6.3.1/include-fixed"
ignoring nonexistent directory
"/opt/rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/6.3.1/../../../../x86_64-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here: /opt/rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/6.3.1/finclude
/opt/rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/6.3.1/include
/usr/local/include /opt/rh/devtoolset-6/root/usr/include
/usr/include End of search list. GNU Fortran2008 (GCC) version 6.3.1
20170216 (Red Hat 6.3.1-3) (x86_64-redhat-linux) compiled by GNU C
version 6.3.1 20170216 (Red Hat 6.3.1-3), GMP version 4.3.1, MPFR
version 2.4.1, MPC version 0.8.1, isl version 0.14 or 0.13 GGC
heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
COLLECT_GCC_OPTIONS='-v' '-fdefault-real-8' '-o' 'test.exe'
'-shared-libgcc' '-mtune=generic' '-march=x86-64'
/opt/rh/devtoolset-6/root/usr/libexec/gcc/x86_64-redhat-linux/6.3.1/as
-v --64 -o /tmp/cc7n6vIv.o /tmp/cceJeO1o.s GNU assembler version 2.27 (x86_64-redhat-linux) using BFD version version 2.27-8.el6 Reading
specs from
/opt/rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/6.3.1/libgfortran.spec
rename spec lib to liborig COLLECT_GCC_OPTIONS='-v' '-fdefault-real-8'
'-o' 'test.exe' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
COMPILER_PATH=/opt/rh/devtoolset-6/root/usr/libexec/gcc/x86_64-redhat-linux/6.3.1/:/opt/rh/devtoolset-6/root/usr/libexec/gcc/x86_64-redhat-linux/6.3.1/:/opt/rh/devtoolset-6/root/usr/libexec/gcc/x86_64-redhat-linux/:/opt/rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/6.3.1/:/opt/rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/
LIBRARY_PATH=/opt/rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/6.3.1/:/opt/rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/6.3.1/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:
/opt/rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/6.3.1/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-fdefault-real-8' '-o' 'test.exe'
'-shared-libgcc' '-mtune=generic' '-march=x86-64'
/opt/rh/devtoolset-6/root/usr/libexec/gcc/x86_64-redhat-linux/6.3.1/collect2
-plugin /opt/rh/devtoolset-6/root/usr/libexec/gcc/x86_64-redhat-linux/6.3.1/liblto_plugin.so
-plugin-opt=/opt/rh/devtoolset-6/root/usr/libexec/gcc/x86_64-redhat-linux/6.3.1/lto-wrapper
-plugin-opt=-fresolution=/tmp/ccQAAlqC.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lquadmath -plugin-opt=-pass-through=-lm -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --build-id --no-add-needed --eh-frame-hdr --hash-style=gnu -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o test.exe /usr/lib/../lib64/crt1.o
/usr/lib/../lib64/crti.o
/opt/rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/6.3.1/crtbegin.o
-L/opt/rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/6.3.1 -L/opt/rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/6.3.1/../../../../lib64
-L/lib/../lib64 -L/usr/lib/../lib64 -L/opt/rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/6.3.1/../../..
/tmp/cc7n6vIv.o -lgfortran -lm -lgcc_s -lgcc -lquadmath -lm -lgcc_s
-lgcc -lc -lgcc_s -lgcc /opt/rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/6.3.1/crtend.o
/usr/lib/../lib64/crtn.o /usr/lib/../lib64/crt1.o: In function
_start': (.text+0x20): undefined reference tomain' /tmp/cc7n6vIv.o:
In function ljacoeff_': test.F:(.text+0xf0): undefined reference to
_gfortran_transfer_real128_write' test.F:(.text+0x16b): undefined
reference to _gfortran_transfer_complex128_write'
test.F:(.text+0x1ea): undefined reference to
_gfortran_transfer_complex128_write' collect2: error: ld returned 1
exit status
I try to compile program in C, dedicated for FTDI chip. My enviroment is Advanced Tomato based Asus router + 16GB USB mem stick, mounted as /opt. Additionaly I have compiler + dependences + the newest FTDI library for ARMv7 from FTDI web site.
My compilation command is:
gcc -v -Wl,-rpath=/opt/usr/local/lib -Wl,--dynamic-linker=/opt/lib/ld-linux.so.3 -L/opt/usr/local/lib -O2 -pipe -march=armv7-a -mtune=cortex-a9 -fno-caller-saves -mfloat-abi=soft -l ftd2xx arco.c -o arco
Library patch is:
LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib:/opt/lib:/opt/usr/lib:/opt/include:/opt/usr/local/lib:/opt/usr/include
Below verbose output from compilation process. Strange think is that in the first part of compilation, location od dynamic linker is correct, that is:
/opt/lib/ld-linux.so.3
But in the second part is wrong, that is:
/lib/ld-linux.so.3
It is not possible to copy/link ld-linux.so.3 to /lib because it is read only filesystem.
All this cause that when I run program, an library error occurs:
./arco: error while loading shared libraries: /opt/usr/local/lib/libftd2xx.so: internal error
Any idea what I am doing wrong?
Compilation output:
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/usr/local/lib' '-O2' '-pipe' '-march=armv7-a' '-mtune=cortex-a9' '-fno-caller-saves' '-mfloat-abi=soft' '-o' 'arco' '-mtls-dialect=gnu'
/opt/lib/gcc/arm-openwrt-linux-gnueabi/5.4.0/cc1 -quiet -v -imultilib . -imultiarch arm-linux-gnueabi arco.c -quiet -dumpbase arco.c -march=armv7-a -mtune=cortex-a9 -mfloat-abi=soft -mtls-dialect=gnu -auxbase arco -O2 -version -fno-caller-saves -o - |
as -v -march=armv7-a -mfloat-abi=soft -meabi=5 -o /opt/tmp/ccMeNAyM.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
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/usr/local/lib' '-O2' '-pipe' '-march=armv7-a' '-mtune=cortex-a9' '-fno-caller-saves' '-mfloat-abi=soft' '-o' 'arco' '-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/ccOsGCvJ.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 arco /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/usr/local/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 -lftd2xx /opt/tmp/ccMeNAyM.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
I am using Cygwin on 64-bit Windows 8.1.
I wanted to make native windows executables inside the Cygwin environment (i.e. I didn't want to deal with cygwin dll issues). I saw Cygwin had minGW packages so I downloaded the
i686-pc-mingw32-gcc
x86_64-w64-mingw32-gcc
packages. From this post I've gathered the i686 one is 32-bit and the x86_64 one is 64-bit.
I used both the i686 and x86_64 version of g++ to compile a simple hello world program and both compiled without error.
The executable compiled by the i686 works as expected.
My problem: When I try to run the executable compiled by the x86_64 version, I get an windows error box saying "The application was unable to start correctly (0x000007b). Click OK to close the application."
I am very confused by this. Why does the 32-bit compiler work and the 64-bit compiler not work on my system?
In case it helps, here the stuff the x86_64 compiler is doing when I call it
$ x86_64-w64-mingw32-g++ test.cpp -o dd -v
Using built-in specs.
COLLECT_GCC=x86_64-w64-mingw32-g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: /cygdrive/i/szsz/tmpp/cygwin64/mingw64-x86_64/mingw64- x86_64-gc c-4.9.2-1.x86_64/src/gcc-4.9.2/configure --srcdir=/cygdrive/i/szsz/tmpp/cygwin64 /mingw64-x86_64/mingw64-x86_64-gcc-4.9.2-1.x86_64/src/gcc-4.9.2 --prefix=/usr -- exec-prefix=/usr --localstatedir=/var --sysconfdir=/etc --docdir=/usr/share/doc/ mingw64-x86_64-gcc --htmldir=/usr/share/doc/mingw64-x86_64-gcc/html -C --build=x 86_64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-w64-mingw32 --without-li biconv-prefix --without-libintl-prefix --with-sysroot=/usr/x86_64-w64-mingw32/sy s-root --with-build-sysroot=/usr/x86_64-w64-mingw32/sys-root --disable-multilib --disable-win32-registry --enable-languages=c,ada,c++,fortran,lto,objc,obj-c++ - -enable-fully-dynamic-strings --enable-graphite --enable-libgomp --enable-libqua dmath --enable-libquadmath-support --enable-libssp --enable-version-specific-run time-libs --with-dwarf2 --with-gnu-ld --with-gnu-as --with-tune=generic --with-c loog-include=/usr/include/cloog-isl --with-system-zlib --libexecdir=/usr/lib
Thread model: win32
gcc version 4.9.2 (GCC)
COLLECT_GCC_OPTIONS='-o' 'dd.exe' '-v' '-shared-libgcc' '-mtune=generic' '- march =x86-64'
/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/cc1plus.exe -quiet -v -U_REENTRANT test.c pp -quiet -dumpbase test.cpp -mtune=generic -march=x86-64 -auxbase test -version -o /tmp/ccKIncrs.s
GNU C++ (GCC) version 4.9.2 (x86_64-w64-mingw32)
compiled by GNU C version 4.9.2, GMP version 6.0.0, MPFR version 3.1.2-p 11, MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/x86_64-w64-mingw32/sys- root/usr/local/inclu de"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-w64- mingw32/4.9.2/../../../. ./x86_64-w64-mingw32/include"
\#include "..." search starts here:
\#include <...> search starts here:
/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++
/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/x86_64-w64-mingw32
/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/backward
/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/include
/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/include-fixed
/usr/x86_64-w64-mingw32/sys-root/mingw/include
End of search list.
GNU C++ (GCC) version 4.9.2 (x86_64-w64-mingw32)
compiled by GNU C version 4.9.2, GMP version 6.0.0, MPFR version 3.1.2-p 11, MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: aee7f7b7ca14852762daf4c41db46c26
COLLECT_GCC_OPTIONS='-o' 'dd.exe' '-v' '-shared-libgcc' '-mtune=generic' '- march =x86-64'
/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64- mingw32/bin/as.exe -v -o /tmp/ccSHmwxw.o /tmp/ccKIncrs.s
GNU assembler version 2.25.51 (x86_64-w64-mingw32) using BFD version (GNU Binuti ls) 2.25.51.20150320
COMPILER_PATH=/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/:/usr/lib/gcc/x86_64-w64-min gw32/4.9.2/:/usr/lib/gcc/x86_64-w64-mingw32/:/usr/lib/gcc/x86_64-w64-mingw32/4.9 .2/:/usr/lib/gcc/x86_64-w64-mingw32/:/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/../.. /../../x86_64-w64-mingw32/bin/
LIBRARY_PATH=/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/:/usr/lib/gcc/x86_64-w64- ming w32/4.9.2/../../../../x86_64-w64-mingw32/lib/../lib/:/usr/x86_64-w64-mingw32/sys -root/mingw/lib/../lib/:/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64 -w64-mingw32/lib/:/usr/x86_64-w64-mingw32/sys-root/mingw/lib/
COLLECT_GCC_OPTIONS='-o' 'dd.exe' '-v' '-shared-libgcc' '-mtune=generic' '- march =x86-64'
/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/collect2.exe -plugin /usr/lib/gcc/x86_64- w64-mingw32/4.9.2/cyglto_plugin.dll -plugin-opt=/usr/lib/gcc/x86_64-w64-mingw32/ 4.9.2/lto-wrapper.exe -plugin-opt=-fresolution=/tmp/ccaaJ5U7.res -plugin-opt=-pa ss-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through =-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-ladvapi32 -plugin- opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass -through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-throug h=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname - plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt --sysroot= /usr/x86_64-w64-mingw32/sys-root -m i386pep -Bdynamic -o dd.exe /usr/x86_64-w64- mingw32/sys-root/mingw/lib/../lib/crt2.o /usr/x86_64-w64-mingw32/sys-root/mingw/ lib/../lib/crtbegin.o -L/usr/lib/gcc/x86_64-w64-mingw32/4.9.2 -L/usr/lib/gcc/x86 _64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/lib/../lib -L/usr/x86_64-w6 4-mingw32/sys-root/mingw/lib/../lib -L/usr/lib/gcc/x86_64-w64-mingw32/4.9.2/../. ./../../x86_64-w64-mingw32/lib -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib /tmp /ccSHmwxw.o -lstdc++ -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -ladv api32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt /usr/x86_64-w64-mingw32/sys-root/mingw/lib/../lib/default-manifest.o / usr/x86_64-w64-mingw32/sys-root/mingw/lib/../lib/crtend.o
EDIT: Did some more testing. When I made a program more complex than hello world (I used a #include ) the i686 version of the executable failed as it was missing some GCC related dll. When I add -static-libgcc -static-libstdc++, both version of the compilers work.
This leads me to conclude stuffs messed up with my linkers and DLLs. I don't know too much about this :(
I am creating the Embedded Mono Archive for one of my application. As per this link I need to create c/c++ executable which will instantiate appropriate framework and will load my managed assembly into it.
I tried creating the statically linked executable by specifying -static in g++ commandline but did not worked. below is verbose output from my g++ command -
$>g++ -Wall -o monolauncherstatic.out MonoLauncher.cpp `pkg-config --cflags --libs mono-2` -v -static
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i586-suse-linux/4.7/lto-wrapper
Target: i586-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib --libexecdir=/usr/lib --enable-languages=c,c++,objc,fortran,obj-c++,java,ada --enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.7 --enable-ssp --disable-libssp --disable-libitm --disable-plugin --with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux' --disable-libgcj --disable-libmudflap --with-slibdir=/lib --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch --enable-version-specific-runtime-libs --enable-linker-build-id --program-suffix=-4.7 --enable-linux-futex --without-system-libunwind --with-arch-32=i586 --with-tune=generic --build=i586-suse-linux
Thread model: posix
gcc version 4.7.2 20130108 [gcc-4_7-branch revision 195012] (SUSE Linux)
COLLECT_GCC_OPTIONS='-Wall' '-o' 'monolauncherstatic.out' '-D' '_REENTRANT' '-I' '/usr/lib/pkgconfig/../../include/mono-2.0' '-L/usr/lib/pkgconfig/../../lib' '-v' '-static' '-mtune=generic' '-march=i586'
/usr/lib/gcc/i586-suse-linux/4.7/cc1plus -quiet -v -I /usr/lib/pkgconfig/../../include/mono-2.0 -D_GNU_SOURCE -D _REENTRANT MonoLauncher.cpp -quiet -dumpbase MonoLauncher.cpp -mtune=generic -march=i586 -auxbase MonoLauncher -Wall -version -o /tmp/cc9htj2d.s
GNU C++ (SUSE Linux) version 4.7.2 20130108 [gcc-4_7-branch revision 195012] (i586-suse-linux)
compiled by GNU C version 4.7.2 20130108 [gcc-4_7-branch revision 195012], GMP version 5.0.5, MPFR version 3.1.1, MPC version 1.0
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/pkgconfig/../../include/mono-2.0
/usr/include/c++/4.7
/usr/include/c++/4.7/i586-suse-linux
/usr/include/c++/4.7/backward
/usr/lib/gcc/i586-suse-linux/4.7/include
/usr/local/include
/usr/lib/gcc/i586-suse-linux/4.7/include-fixed
/usr/lib/gcc/i586-suse-linux/4.7/../../../../i586-suse-linux/include
/usr/include
End of search list.
GNU C++ (SUSE Linux) version 4.7.2 20130108 [gcc-4_7-branch revision 195012] (i586-suse-linux)
compiled by GNU C version 4.7.2 20130108 [gcc-4_7-branch revision 195012], GMP version 5.0.5, MPFR version 3.1.1, MPC version 1.0
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 909fa5113dc6c530ae791996b13c020f
COLLECT_GCC_OPTIONS='-Wall' '-o' 'monolauncherstatic.out' '-D' '_REENTRANT' '-I' '/usr/lib/pkgconfig/../../include/mono-2.0' '-L/usr/lib/pkgconfig/../../lib' '-v' '-static' '-mtune=generic' '-march=i586'
/usr/lib/gcc/i586-suse-linux/4.7/../../../../i586-suse-linux/bin/as -v -I /usr/lib/pkgconfig/../../include/mono-2.0 --32 -o /tmp/ccwER6Jm.o /tmp/cc9htj2d.s
GNU assembler version 2.23.1 (i586-suse-linux) using BFD version (GNU Binutils; openSUSE 12.3) 2.23.1
COMPILER_PATH=/usr/lib/gcc/i586-suse-linux/4.7/:/usr/lib/gcc/i586-suse-linux/4.7/:/usr/lib/gcc/i586-suse-linux/:/usr/lib/gcc/i586-suse-linux/4.7/:/usr/lib/gcc/i586-suse-linux/:/usr/lib/gcc/i586-suse-linux/4.7/../../../../i586-suse-linux/bin/
LIBRARY_PATH=/usr/lib/gcc/i586-suse-linux/4.7/:/usr/lib/gcc/i586-suse-linux/4.7/../../../../i586-suse-linux/lib/:/usr/lib/gcc/i586-suse-linux/4.7/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-Wall' '-o' 'monolauncherstatic.out' '-D' '_REENTRANT' '-I' '/usr/lib/pkgconfig/../../include/mono-2.0' '-L/usr/lib/pkgconfig/../../lib' '-v' '-static' '-mtune=generic' '-march=i586'
/usr/lib/gcc/i586-suse-linux/4.7/collect2 --build-id -m elf_i386 -static -o monolauncherstatic.out /usr/lib/gcc/i586-suse-linux/4.7/../../../crt1.o /usr/lib/gcc/i586-suse-linux/4.7/../../../crti.o /usr/lib/gcc/i586-suse-linux/4.7/crtbeginT.o -L/usr/lib/pkgconfig/../../lib -L/usr/lib/gcc/i586-suse-linux/4.7 -L/usr/lib/gcc/i586-suse-linux/4.7/../../../../i586-suse-linux/lib -L/usr/lib/gcc/i586-suse-linux/4.7/../../.. /tmp/ccwER6Jm.o -lmono-2.0 -lrt -ldl -lpthread -lstdc++ -lm --start-group -lgcc -lgcc_eh -lc --end-group /usr/lib/gcc/i586-suse-linux/4.7/crtend.o /usr/lib/gcc/i586-suse-linux/4.7/../../../crtn.o
/usr/lib/gcc/i586-suse-linux/4.7/../../../../i586-suse-linux/bin/ld: cannot find -lrt
/usr/lib/gcc/i586-suse-linux/4.7/../../../../i586-suse-linux/bin/ld: cannot find -ldl
/usr/lib/gcc/i586-suse-linux/4.7/../../../../i586-suse-linux/bin/ld: cannot find -lpthread
/usr/lib/gcc/i586-suse-linux/4.7/../../../../i586-suse-linux/bin/ld: cannot find -lm
/usr/lib/gcc/i586-suse-linux/4.7/../../../../i586-suse-linux/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
I also tried pkg-config --cflags --libs mono-2
It seems you don't have static libraries installed, e.g. libc.a, libm.a, libpthread.a, etc.
If you're using SuSE, perhaps yum install glibc-devel-static will work. Maybe some of the other libraries will need other packages to be installed.
G'day,
on a 64bit RHEL5 box we need to install our 32bit application. For some reasons we need to use gcc 4.0.3 for this, so I tried to install that version on the target machine first, like I did a thousand times on 32bit target platforms.
This time, however, I am experiencing problems. I have bootstrapped and instaled gcc 4.0.3 into a path, let's say /foo. Like always I set the LD_LIBRARY_PATH to point into the directory containing shared libraries:
$ echo $LD_LIBRARY_PATH
/foo/lib:/foo/lib/gcc/x86_64-unknown-linux-gnu/lib64:/foo/lib/gcc/x86_64-unknown-linux-gnu/4.0.3:/lib64
There really are the necessary libraries in these directories:
$ ls /foo/lib/gcc/x86_64-unknown-linux-gnu/lib64
libgcc_s.so libgcc_s.so.1
$ ls /foo/lib/gcc/x86_64-unknown-linux-gnu/4.0.3
32 crtendS.o libgcov.a libmudflap.so.0.0.0 libmudflapth.so.0.0.0 libstdc++.so.6.0.7
crtbegin.o include libmudflap.a libmudflapth.a libstdc++.a libsupc++.a
crtbeginS.o install-tools libmudflap.la libmudflapth.la libstdc++.la libsupc++.la
crtbeginT.o libgcc.a libmudflap.so libmudflapth.so libstdc++.so
crtend.o libgcc_eh.a libmudflap.so.0 libmudflapth.so.0 libstdc++.so.6
However, if I try to create a simple program, ld can't find libgcc_s:
$ gcc-4.0 t.cc
/foo/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.0.3/../../../../x86_64-unknown-linux-gnu/bin/ld: cannot find -lgcc_s
collect2: ld returned 1 exit status
Why doesn't it find the libgcc_s.so library?
Any help appreciated!
Stefan
It seems your folder /foo/lib/gcc/x86_64-unknown-linux-gnu/lib64 where libgcc_s.so is not included. For the sake of experiment do this:
gcc-4.0 -v t.cc -L/foo/lib/gcc/x86_64-unknown-linux-gnu/lib64
$ gcc-4.0 -v t.cc
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.0.3/configure --prefix=/foo --program-suffix=-4.0 --enable-version-specific-runtime-libs --enable-languages=c,c++ --with-gnu-as --with-gnu-ld
Thread model: posix
gcc version 4.0.3
/foo/i686-pc-linux-gnu/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.0.3/cc1plus -quiet -v -iprefix /foo/i686-pc-linux-gnu/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.0.3/ -D_GNU_SOURCE t.cc -quiet -dumpbase t.cc -mtune=k8 -auxbase t -version -o /tmp/ccDiWiMk.s
ignoring nonexistent directory "/foo/i686-pc-linux-gnu/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.0.3/../../../../x86_64-unknown-linux-gnu/include"
ignoring duplicate directory "/foo/lib/gcc/x86_64-unknown-linux-gnu/4.0.3/include/c++"
ignoring duplicate directory "/foo/lib/gcc/x86_64-unknown-linux-gnu/4.0.3/include/c++/x86_64-unknown-linux-gnu"
ignoring duplicate directory "/foo/lib/gcc/x86_64-unknown-linux-gnu/4.0.3/include/c++/backward"
ignoring duplicate directory "/foo/lib/gcc/x86_64-unknown-linux-gnu/4.0.3/include"
ignoring nonexistent directory "/foo/lib/gcc/x86_64-unknown-linux-gnu/4.0.3/../../../../x86_64-unknown-linux-gnu/include"
#include "..." search starts here:
#include search starts here:
/foo/i686-pc-linux-gnu/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.0.3/include/c++
/foo/i686-pc-linux-gnu/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.0.3/include/c++/x86_64-unknown-linux-gnu
/foo/i686-pc-linux-gnu/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.0.3/include/c++/backward
/foo/i686-pc-linux-gnu/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.0.3/include
/usr/local/include
/foo/include
/usr/include
End of search list.
GNU C++ version 4.0.3 (x86_64-unknown-linux-gnu)
compiled by GNU C version 4.1.2 20080704 (Red Hat 4.1.2-46).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
/foo/i686-pc-linux-gnu/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.0.3/../../../../x86_64-unknown-linux-gnu/bin/as -V -Qy -o /tmp/ccAemlDJ.o /tmp/ccDiWiMk.s
GNU assembler version 2.19.1 (x86_64-unknown-linux-gnu) using BFD version (GNU Binutils) 2.19.1
/foo/i686-pc-linux-gnu/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.0.3/collect2 --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /usr/lib/../lib64/crt1.o /usr/lib/../lib64/crti.o /foo/i686-pc-linux-gnu/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.0.3/crtbegin.o -L/foo/i686-pc-linux-gnu/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.0.3 -L/foo/i686-pc-linux-gnu/bin/../lib/gcc -L/foo/lib/gcc/x86_64-unknown-linux-gnu/4.0.3 -L/foo/i686-pc-linux-gnu/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.0.3/../../../../x86_64-unknown-linux-gnu/lib -L/foo/lib/gcc/x86_64-unknown-linux-gnu/4.0.3/../../../../x86_64-unknown-linux-gnu/lib -L/foo/i686-pc-linux-gnu/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.0.3/../../../../lib64 -L/foo/i686-pc-linux-gnu/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.0.3/../../.. -L/foo/lib/gcc/x86_64-unknown-linux-gnu/4.0.3/../../../../lib64 -L/foo/lib/gcc/x86_64-unknown-linux-gnu/4.0.3/../../.. -L/lib/../lib64 -L/usr/lib/../lib64 /tmp/ccAemlDJ.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /foo/i686-pc-linux-gnu/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.0.3/crtend.o /usr/lib/../lib64/crtn.o
/foo/i686-pc-linux-gnu/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.0.3/../../../../x86_64-unknown-linux-gnu/bin/ld: cannot find -lgcc_s
collect2: ld returned 1 exit status