Trouble building gcc on 64bit RHEL5 - gcc

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

Related

gcc: CreateProcess: No such file or directory

I have tried to use other solutions posted on the web for the same error but it doesn't work for me.
I am testing the installation of MinGW compiler on my pc and I get the following error when running the code:
gcc -v hello.c
C:\Python34\swigibpy-master>gcc -v hello.c
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.5.2/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.5.2/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --
enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs --disable-we
rror --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.5.2 (GCC)
COLLECT_GCC_OPTIONS='-v' '-mtune=i386' '-march=i386'
c:/mingw/bin/../libexec/gcc/mingw32/4.5.2/cc1.exe -quiet -v -iprefix c:\mingw\bin\../lib/gcc/mingw32/4.5.2/ hello.c -quiet -dumpbas
e hello.c -mtune=i386 -march=i386 -auxbase hello -version -o C:\Users\E039256\AppData\Local\Temp\cc87BHBZ.s
GNU C (GCC) version 4.5.2 (mingw32)
compiled by GNU C version 4.5.2, GMP version 5.0.1, MPFR version 2.4.1, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "c:\mingw\bin\../lib/gcc/mingw32/4.5.2/../../../../mingw32/include"
ignoring duplicate directory "/mingw/lib/gcc/mingw32/4.5.2/../../../../include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.5.2/include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.5.2/include-fixed"
ignoring nonexistent directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.5.2/../../../../mingw32/include"
ignoring duplicate directory "/mingw/include"#include "..." search starts here:#include <...> search starts here: C:\mingw\bin\../lib/gcc/mingw32/4.5.2/../../../../include
c:\mingw\bin\../lib/gcc/mingw32/4.5.2/include
c:\mingw\bin\../lib/gcc/mingw32/4.5.2/include-fixed
End of search list.
GNU C (GCC) version 4.5.2 (mingw32)
compiled by GNU C version 4.5.2, GMP version 5.0.1, MPFR version 2.4.1, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 48c0bd49e9a9404f24c600b71b435d06
COLLECT_GCC_OPTIONS='-v' '-mtune=i386' '-march=i386'
as -o C:\Users\E039256\AppData\Local\Temp\ccwHyCqZ.o C:\Users\E039256\AppData\Local\Temp\cc87BHBZ.s
gcc: CreateProcess: No such file or directory
The mingw32-gcc, mingw32-g++, etc. binaries exist as an aid to cross development. They are created in a typical build of gcc. They are therefore distributed as the maintainers of GCC meant them to be. The gcc.exe indicates that the binary produces binaries for a target equal to the build, while the mingw32-gcc binary produces binaries to be executed on the mingw32 target.
You can see that at http://www.mingw.org/wiki/FAQ

Why don't programs compiled with 64-bit MinGW g++ work on my 64-bit PC?

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 :(

GCC 4.9.2 issues - linking error "start" symbol undefined (after yosemite update)

So, I upgraded to Yosemite and also updated gcc to gcc-4.9. Now nothing works. Even a basic C program like this:
#include "stdio.h"
void main() {
printf("woh!");
}
The details of gcc -v a.c is below. The basic error is:
Undefined symbols for architecture x86_64:
"start", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
Here is my configuration for CC, clang and gcc.
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/4.9.2/libexec/gcc/x86_64-apple-darwin14.0.0/4.9.2/lto-wrapper
Target: x86_64-apple-darwin14.0.0
Configured with: ../configure --build=x86_64-apple-darwin14.0.0 --prefix=/usr/local/Cellar/gcc/4.9.2 --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-4.9 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-cloog=/usr/local/opt/cloog --with-isl=/usr/local/opt/isl --with-system-zlib --enable-version-specific-runtime-libs --enable-libstdcxx-time=yes --enable-stage1-checking --enable-checking=release --enable-lto --disable-werror --with-pkgversion='Homebrew gcc 4.9.2' --with-bugurl=https://github.com/Homebrew/homebrew/issues --enable-plugin --disable-nls --enable-multilib
Thread model: posix
gcc version 4.9.2 (Homebrew gcc 4.9.2)
I had created links for gcc to gcc-4.9 which was installed successfully using Homebrew. I have run brew doctor and received no issues. Command Line Tools was updated using code-select -install
Gautams-MacBook-Pro:~ gautamrege$ ls -l /usr/local/bin/gcc
lrwxrwxr-x 1 gautamrege admin 22 Nov 14 20:14 /usr/local/bin/gcc# -> /usr/local/bin/gcc-4.9
Gautams-MacBook-Pro:~ gautamrege$ ls -l /usr/local/bin/gcc-4.9
lrwxrwxr-x 1 gautamrege admin 31 Nov 14 20:14 /usr/local/bin/gcc-4.9# -> ../Cellar/gcc/4.9.2/bin/gcc-4.9
These are my CC and clang versions (basically the same)
Gautams-MacBook-Pro:~ gautamrege$ CC -v
Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix
Gautams-MacBook-Pro:~ gautamrege$ clang -c
clang: error: no input files
Gautams-MacBook-Pro:~ gautamrege$ clang -v
Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix
Finally, here is the detailed log using gcc -v.
$ gcc -v a.c
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/4.9.2/libexec/gcc/x86_64-apple-darwin14.0.0/4.9.2/lto-wrapper
Target: x86_64-apple-darwin14.0.0
Configured with: ../configure --build=x86_64-apple-darwin14.0.0 --prefix=/usr/local/Cellar/gcc/4.9.2 --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-4.9 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-cloog=/usr/local/opt/cloog --with-isl=/usr/local/opt/isl --with-system-zlib --enable-version-specific-runtime-libs --enable-libstdcxx-time=yes --enable-stage1-checking --enable-checking=release --enable-lto --disable-werror --with-pkgversion='Homebrew gcc 4.9.2' --with-bugurl=https://github.com/Homebrew/homebrew/issues --enable-plugin --disable-nls --enable-multilib
Thread model: posix
gcc version 4.9.2 (Homebrew gcc 4.9.2)
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.10.0' '-v' '-mtune=core2'
/usr/local/Cellar/gcc/4.9.2/libexec/gcc/x86_64-apple-darwin14.0.0/4.9.2/cc1 -quiet -v -D__DYNAMIC__ a.c -fPIC -quiet -dumpbase a.c -mmacosx-version-min=10.10.0 -mtune=core2 -auxbase a -version -o /var/folders/dr/kc0cps51533gqx5zm8gv33x80000gn/T//ccvx7Ydq.s
GNU C (Homebrew gcc 4.9.2) version 4.9.2 (x86_64-apple-darwin14.0.0)
compiled by GNU C version 4.9.2, GMP version 6.0.0, MPFR version 3.1.2-p10, MPC version 1.0.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/Cellar/gcc/4.9.2/include"
ignoring nonexistent directory "/usr/local/Cellar/gcc/4.9.2/lib/gcc/x86_64-apple-darwin14.0.0/4.9.2/../../../../x86_64-apple-darwin14.0.0/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/Cellar/gcc/4.9.2/lib/gcc/x86_64-apple-darwin14.0.0/4.9.2/include
/usr/local/include
/usr/local/Cellar/gcc/4.9.2/lib/gcc/x86_64-apple-darwin14.0.0/4.9.2/include-fixed
/usr/include
/System/Library/Frameworks
/Library/Frameworks
End of search list.
GNU C (Homebrew gcc 4.9.2) version 4.9.2 (x86_64-apple-darwin14.0.0)
compiled by GNU C version 4.9.2, GMP version 6.0.0, MPFR version 3.1.2-p10, MPC version 1.0.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: f90e36a64a568856fa161772b1b4076f
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.10.0' '-v' '-mtune=core2'
as -arch x86_64 -force_cpusubtype_ALL -o /var/folders/dr/kc0cps51533gqx5zm8gv33x80000gn/T//cckdbo1t.o /var/folders/dr/kc0cps51533gqx5zm8gv33x80000gn/T//ccvx7Ydq.s
COMPILER_PATH=/usr/local/Cellar/gcc/4.9.2/libexec/gcc/x86_64-apple-darwin14.0.0/4.9.2/:/usr/local/Cellar/gcc/4.9.2/libexec/gcc/x86_64-apple-darwin14.0.0/4.9.2/:/usr/local/Cellar/gcc/4.9.2/libexec/gcc/x86_64-apple-darwin14.0.0/:/usr/local/Cellar/gcc/4.9.2/lib/gcc/x86_64-apple-darwin14.0.0/4.9.2/:/usr/local/Cellar/gcc/4.9.2/lib/gcc/x86_64-apple-darwin14.0.0/
LIBRARY_PATH=/usr/local/Cellar/gcc/4.9.2/lib/gcc/x86_64-apple-darwin14.0.0/4.9.2/:/usr/local/Cellar/gcc/4.9.2/lib/gcc/x86_64-apple-darwin14.0.0/4.9.2/../../../:/usr/lib/
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.10.0' '-v' '-mtune=core2'
/usr/local/Cellar/gcc/4.9.2/libexec/gcc/x86_64-apple-darwin14.0.0/4.9.2/collect2 -dynamic -arch x86_64 -macosx_version_min 10.10.0 -weak_reference_mismatches non-weak -o a.out -L/usr/local/Cellar/gcc/4.9.2/lib/gcc/x86_64-apple-darwin14.0.0/4.9.2 -L/usr/local/Cellar/gcc/4.9.2/lib/gcc/x86_64-apple-darwin14.0.0/4.9.2/../../.. /var/folders/dr/kc0cps51533gqx5zm8gv33x80000gn/T//cckdbo1t.o -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lSystem -v
collect2 version 4.9.2
/usr/bin/ld -dynamic -arch x86_64 -macosx_version_min 10.10.0 -weak_reference_mismatches non-weak -o a.out -L/usr/local/Cellar/gcc/4.9.2/lib/gcc/x86_64-apple-darwin14.0.0/4.9.2 -L/usr/local/Cellar/gcc/4.9.2/lib/gcc/x86_64-apple-darwin14.0.0/4.9.2/../../.. /var/folders/dr/kc0cps51533gqx5zm8gv33x80000gn/T//cckdbo1t.o -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lSystem -v
#(#)PROGRAM:ld PROJECT:ld64-136
configured to support archs: armv6 armv7 armv7s i386 x86_64
Library search paths:
/usr/local/Cellar/gcc/4.9.2/lib/gcc/x86_64-apple-darwin14.0.0/4.9.2
/usr/local/Cellar/gcc/4.9.2/lib
/usr/lib
/usr/local/lib
Framework search paths:
/Library/Frameworks/
/System/Library/Frameworks/
Undefined symbols for architecture x86_64:
"start", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
I'm pretty sure I am making some basic mistake.Needless to day, all other package installations are failing because of this same error. Any ideas?
Copying information from comments to this Community Wiki answer.
Tim Smith pointed out that the key to this problem is to run:
sudo xcode-select -s /Library/Developer/CommandLineTools/
This makes sure that clang invokes the XCode 6 version of clang.

Creating statically linked executable using GCC

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.

Which libraries are used by the make process?

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.

Resources