See title: GCC does absolutely nothing. Clang returns a linker error. After a fresh install (pacman -S gcc clang) in a directory only containing program.c, whose content is int main() { return 0; }:
$ gcc program.c
(no output)
$ gcc asdfasdf
(no output even for nonexistent file)
$ gcc
gcc.exe: fatal error: no input files
compilation terminated.
$ clang program.c
clang: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
$ clang asdfasdf
clang: error: no such file or directory: 'asdfasdf'
clang: error: no input files
$ gcc -v asdfasdf
Using built-in specs.
COLLECT_GCC=C:\msys64\mingw64\bin\gcc.exe
COLLECT_LTO_WRAPPER=C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-11.2.0/configure --prefix=/mingw64 --with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/mingw64/x86_64-w64-mingw32/include --libexecdir=/mingw64/lib --enable-bootstrap --enable-checking=release --with-arch=x86-64 --with-tune=generic --enable-languages=c,lto,c++,fortran,ada,objc,obj-c++,jit --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-filesystem-ts --enable-libstdcxx-time --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-lto --enable-libgomp --disable-multilib --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64 --with-pkgversion='Rev5, Built by MSYS2 project' --with-bugurl=https://github.com/msys2/MINGW-packages/issues --with-gnu-as --with-gnu-ld --with-boot-ldflags='-pipe -Wl,--dynamicbase,--high-entropy-va,--nxcompat,--default-image-base-high -Wl,--disable-dynamicbase -static-libstdc++ -static-libgcc' 'LDFLAGS_FOR_TARGET=-pipe -Wl,--dynamicbase,--high-entropy-va,--nxcompat,--default-image-base-high' --enable-linker-plugin-flags='LDFLAGS=-static-libstdc++\ -static-libgcc\ -pipe\ -Wl,--dynamicbase,--high-entropy-va,--nxcompat,--default-image-base-high\ -Wl,--stack,12582912'
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.0 (Rev5, Built by MSYS2 project)
COMPILER_PATH=C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/;C:/msys64/mingw64/bin/../lib/gcc/;C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/
LIBRARY_PATH=C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/;C:/msys64/mingw64/bin/../lib/gcc/;C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/lib/../lib/;C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../lib/;C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/lib/;C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=x86-64' '-dumpdir' 'a.'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/collect2.exe -plugin C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/liblto_plugin.dll -plugin-opt=C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/lto-wrapper.exe -plugin-opt=-fresolution=C:\msys64\tmp\ccYYqACA.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lpthread -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-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lkernel32 -m i386pep -Bdynamic C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/lib/../lib/crt2.o C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/crtbegin.o -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0 -LC:/msys64/mingw64/bin/../lib/gcc -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/lib/../lib -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../lib -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/lib -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../.. asdfasdf -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lkernel32 -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lkernel32 C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/lib/../lib/default-manifest.o C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/crtend.o
$ clang -v program.c
clang version 11.0.0 (https://github.com/msys2/MSYS2-packages ca391a3660d17cdee1e94d5afd2e72a4f750cddb)
Target: x86_64-pc-windows-msys
Thread model: posix
InstalledDir: /usr/bin
"/usr/bin/clang" -cc1 -triple x86_64-pc-windows-msys -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name program.c -mrelocation-model pic -pic-level 2 -mframe-pointer=none -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -debugger-tuning=gdb -v -resource-dir /usr/lib/clang/11.0.0 -fdebug-compilation-dir "/c/dev/opengl/\$" -ferror-limit 19 -fno-use-cxa-atexit -fgnuc-version=4.2.1 -fcolor-diagnostics -faddrsig -o /tmp/program-cff7ba.o -x c program.c
clang -cc1 version 11.0.0 based upon LLVM 11.0.0 default target x86_64-pc-msys
ignoring nonexistent directory "/usr/local/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/clang/11.0.0/include
/usr/include/w32api
/usr/include
End of search list.
"/usr/bin/x86_64-pc-msys-gcc" -v -m64 -o a.exe /tmp/program-cff7ba.o
Using built-in specs.
COLLECT_GCC=/usr/bin/x86_64-pc-msys-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-msys/11.2.0/lto-wrapper.exe
Target: x86_64-pc-msys
Configured with: /c/S/gcc/src/gcc-11.2.0/configure --build=x86_64-pc-msys --prefix=/usr --libexecdir=/usr/lib --enable-bootstrap --enable-shared --enable-shared-libgcc --enable-static --enable-version-specific-runtime-libs --with-arch=x86-64 --with-tune=generic --disable-multilib --enable-__cxa_atexit --with-dwarf2 --enable-languages=c,c++,fortran,lto --enable-graphite --enable-threads=posix --enable-libatomic --enable-libgomp --disable-libitm --enable-libquadmath --enable-libquadmath-support --disable-libssp --disable-win32-registry --disable-symvers --with-gnu-ld --with-gnu-as --disable-isl-version-check --enable-checking=release --without-libiconv-prefix --without-libintl-prefix --with-system-zlib --enable-linker-build-id --with-default-libstdcxx-abi=gcc4-compatible --enable-libstdcxx-filesystem-ts
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.2.0 (GCC)
COMPILER_PATH=/usr/lib/gcc/x86_64-pc-msys/11.2.0/:/usr/lib/gcc/x86_64-pc-msys/11.2.0/:/usr/lib/gcc/x86_64-pc-msys/:/usr/lib/gcc/x86_64-pc-msys/11.2.0/:/usr/lib/gcc/x86_64-pc-msys/:/usr/lib/gcc/x86_64-pc-msys/11.2.0/../../../../x86_64-pc-msys/bin/
LIBRARY_PATH=/usr/lib/gcc/x86_64-pc-msys/11.2.0/:/usr/lib/gcc/x86_64-pc-msys/11.2.0/../../../../x86_64-pc-msys/lib/../lib/:/usr/lib/gcc/x86_64-pc-msys/11.2.0/../../../../lib/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-pc-msys/11.2.0/../../../../x86_64-pc-msys/lib/:/usr/lib/gcc/x86_64-pc-msys/11.2.0/../../../:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-m64' '-o' 'a.exe' '-mtune=generic' '-march=x86-64' '-dumpdir' 'a.'
/usr/lib/gcc/x86_64-pc-msys/11.2.0/collect2.exe -plugin /usr/lib/gcc/x86_64-pc-msys/11.2.0/msys-lto_plugin.dll -plugin-opt=/usr/lib/gcc/x86_64-pc-msys/11.2.0/lto-wrapper.exe -plugin-opt=-fresolution=/tmp/ccDITezv.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmsys-2.0 -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --build-id -m i386pep --wrap _Znwm --wrap _Znam --wrap _ZdlPv --wrap _ZdaPv --wrap _ZnwmRKSt9nothrow_t --wrap _ZnamRKSt9nothrow_t --wrap _ZdlPvRKSt9nothrow_t --wrap _ZdaPvRKSt9nothrow_t -Bdynamic --dll-search-prefix=msys- --tsaware -o a.exe /usr/lib/gcc/x86_64-pc-msys/11.2.0/../../../../lib/crt0.o /usr/lib/gcc/x86_64-pc-msys/11.2.0/crtbegin.o -L/usr/lib/gcc/x86_64-pc-msys/11.2.0 -L/usr/lib/gcc/x86_64-pc-msys/11.2.0/../../../../x86_64-pc-msys/lib/../lib -L/usr/lib/gcc/x86_64-pc-msys/11.2.0/../../../../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-pc-msys/11.2.0/../../../../x86_64-pc-msys/lib -L/usr/lib/gcc/x86_64-pc-msys/11.2.0/../../.. /tmp/program-cff7ba.o -lgcc_s -lgcc -lmsys-2.0 -ladvapi32 -lshell32 -luser32 -lkernel32 -lgcc_s -lgcc /usr/lib/gcc/x86_64-pc-msys/11.2.0/../../../../lib/default-manifest.o /usr/lib/gcc/x86_64-pc-msys/11.2.0/crtend.o
clang: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
$ pacman -Qi | awk '/^Name/ { print $3 }' | tr '\n' ' '
(list all installed packages)
asciidoc autoconf autoconf2.13 autogen automake-wrapper automake1.10 automake1.11 automake1.12 automake1.13 automake1.14 automake1.15 automake1.16 automake1.6 automake1.7 automake1.8 automake1.9 base bash bash-completion binutils bison brotli bsdtar btyacc bzip2 ca-certificates clang cmake coreutils curl dash db diffstat diffutils docbook-xml docbook-xsl dos2unix expat file filesystem findutils flex gawk gcc gcc-libs gdb gdbm getent gettext gettext-devel git glib2 gmp gnupg gperf grep groff gzip heimdal heimdal-libs help2man icu inetutils info intltool isl jsoncpp less libarchive libargp libasprintf libassuan libatomic_ops libbz2 libcrypt libcurl libdb libedit libexpat libffi libgc libgcrypt libgdbm libgettextpo libgnutls libgpg-error libgpgme libguile libhogweed libiconv libiconv-devel libidn2 libintl libksba libltdl liblz4 liblzma libmetalink libnettle libnghttp2 libnpth libopenssl libp11-kit libpcre libpcre16 libpcre2_16 libpcre2_32 libpcre2_8 libpcre2posix libpcre32 libpcrecpp libpcreposix libpipeline libpsl libreadline librhash libsqlite libssh2 libtasn1 libtool libunistring libunrar libunrar-devel libutil-linux libuv libxml2 libxslt libxxhash libzstd llvm m4 make man-db mingw-w64-x86_64-adwaita-icon-theme mingw-w64-x86_64-atk mingw-w64-x86_64-binutils mingw-w64-x86_64-brotli mingw-w64-x86_64-bzip2 mingw-w64-x86_64-ca-certificates mingw-w64-x86_64-cairo mingw-w64-x86_64-crt-git mingw-w64-x86_64-expat mingw-w64-x86_64-fontconfig mingw-w64-x86_64-freetype mingw-w64-x86_64-fribidi mingw-w64-x86_64-gcc mingw-w64-x86_64-gcc-ada mingw-w64-x86_64-gcc-fortran mingw-w64-x86_64-gcc-libgfortran mingw-w64-x86_64-gcc-libs mingw-w64-x86_64-gcc-objc mingw-w64-x86_64-gdb mingw-w64-x86_64-gdb-multiarch mingw-w64-x86_64-gdk-pixbuf2 mingw-w64-x86_64-gettext mingw-w64-x86_64-giflib mingw-w64-x86_64-glib2 mingw-w64-x86_64-gmp mingw-w64-x86_64-graphite2 mingw-w64-x86_64-gtk-update-icon-cache mingw-w64-x86_64-gtk3 mingw-w64-x86_64-harfbuzz mingw-w64-x86_64-headers-git mingw-w64-x86_64-hicolor-icon-theme mingw-w64-x86_64-isl mingw-w64-x86_64-jbigkit mingw-w64-x86_64-json-glib mingw-w64-x86_64-lerc mingw-w64-x86_64-libdatrie mingw-w64-x86_64-libdeflate mingw-w64-x86_64-libepoxy mingw-w64-x86_64-libffi mingw-w64-x86_64-libgccjit mingw-w64-x86_64-libiconv mingw-w64-x86_64-libjpeg-turbo mingw-w64-x86_64-libmangle-git mingw-w64-x86_64-libpng mingw-w64-x86_64-librsvg mingw-w64-x86_64-libsystre mingw-w64-x86_64-libtasn1 mingw-w64-x86_64-libthai mingw-w64-x86_64-libtiff mingw-w64-x86_64-libtre-git mingw-w64-x86_64-libwebp mingw-w64-x86_64-libwinpthread-git mingw-w64-x86_64-libxml2 mingw-w64-x86_64-lzo2 mingw-w64-x86_64-make mingw-w64-x86_64-mpc mingw-w64-x86_64-mpdecimal mingw-w64-x86_64-mpfr mingw-w64-x86_64-ncurses mingw-w64-x86_64-openssl mingw-w64-x86_64-p11-kit mingw-w64-x86_64-pango mingw-w64-x86_64-pcre mingw-w64-x86_64-pixman mingw-w64-x86_64-pkgconf mingw-w64-x86_64-python mingw-w64-x86_64-readline mingw-w64-x86_64-shared-mime-info mingw-w64-x86_64-sqlite3 mingw-w64-x86_64-tcl mingw-w64-x86_64-termcap mingw-w64-x86_64-tk mingw-w64-x86_64-tools-git mingw-w64-x86_64-tzdata mingw-w64-x86_64-windows-default-manifest mingw-w64-x86_64-wineditline mingw-w64-x86_64-winpthreads-git mingw-w64-x86_64-winstorecompat-git mingw-w64-x86_64-xxhash mingw-w64-x86_64-xz mingw-w64-x86_64-zlib mingw-w64-x86_64-zstd mintty mpc mpdecimal mpfr msys2-keyring msys2-launcher msys2-runtime msys2-runtime-devel msys2-w32api-headers msys2-w32api-runtime nano ncurses neofetch nettle openssh openssl p11-kit pacman pacman-contrib pacman-mirrors patch patchutils pcre pcre2 perl perl-Authen-SASL perl-Clone perl-Convert-BinHex perl-Encode-Locale perl-Error perl-File-Listing perl-HTML-Parser perl-HTML-Tagset perl-HTTP-Cookies perl-HTTP-Daemon perl-HTTP-Date perl-HTTP-Message perl-HTTP-Negotiate perl-IO-HTML perl-IO-Socket-SSL perl-IO-Stringy perl-LWP-MediaTypes perl-Locale-Gettext perl-MIME-tools perl-MailTools perl-Module-Build perl-Net-HTTP perl-Net-SMTP-SSL perl-Net-SSLeay perl-TermReadKey perl-Test-Pod perl-TimeDate perl-Try-Tiny perl-URI perl-WWW-RobotRules perl-XML-Parser perl-YAML-Syck perl-inc-latest perl-libwww pinentry pkgconf pkgfile python quilt rebase reflex scons sed swig tar tcl texinfo texinfo-tex tftp-hpa time ttyrec tzcode unrar util-linux vim wget which windows-default-manifest xmlto xxhash xz zlib zstd
Related
I just installed mingw64 in my msys2 env on Win11. The compiler does not produce an object file when compiling a trivial file:
foo.c:
int i;
% /mingw64/bin/gcc -v -c foo.c
Using built-in specs.
COLLECT_GCC=C:\msys64\mingw64\bin\gcc.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-12.2.0/configure --prefix=/mingw64 --with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/mingw64/include --libexecdir=/mingw64/lib --enable-bootstrap --enable-checking=release --with-arch=nocona --with-tune=generic --enable-languages=c,lto,c++,fortran,ada,objc,obj-c++,jit --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-filesystem-ts --enable-libstdcxx-time --disable-libstdcxx-pch --enable-lto --enable-libgomp --disable-multilib --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64 --with-pkgversion='Rev10, Built by MSYS2 project' --with-bugurl=https://github.com/msys2/MINGW-packages/issues --with-gnu-as --with-gnu-ld --disable-libstdcxx-debug --with-boot-ldflags=-static-libstdc++ --with-stage1-ldflags=-static-libstdc++
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.2.0 (Rev10, Built by MSYS2 project)
COLLECT_GCC_OPTIONS='-v' '-c' '-mtune=generic' '-march=nocona'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/cc1.exe -quiet -v -iprefix C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/ -D_REENTRANT foo.c -quiet -dumpbase foo.c -dumpbase-ext .c -mtune=generic -march=nocona -version -o C:\Users\me\AppData\Local\Temp\ccF8KQyo.s
% ls -l
-a--- 7 3 Feb 15:57 foo.c
%
As you can see it just outputs an assembly file into %TMP%. No errors or warnings (compiling without -v produces nothing on stdout/stderr).
I must have something misconfigured, but not sure what. I have reviewed previous SO answers but they are about source code with errors or warnings.
Turns out you need to have /mingw64/bin in $PATH or it fails silently in this way. Solved.
I followed these instructions from github to clone and build the boost libraries.
https://github.com/boostorg/boost/wiki/Getting-Started
The end of the ./b2 command tells me
The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths:
/home/user/Desktop/boost
The following directory should be added to linker library paths:
/home/user/Desktop/boost/stage/lib
What should I do with these folders? I would like to put boost in the "regular place it should go in order for gcc to see it".
This is probably /usr/include ? Is it safe for me to move the folder boost to this location? What about the boost/stage/lib folder. Where does this go?
gcc -v /dev/null -o /dev/null
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/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++,objc,obj-c++,fortran,ada,go,lto --prefix=/usr --mandir=/usr/share/man --infodir=/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 --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --disable-libgcj --with-isl --enable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 6.3.1 20161221 (Red Hat 6.3.1-1) (GCC)
COMPILER_PATH=/usr/libexec/gcc/x86_64-redhat-linux/6.3.1/:/usr/libexec/gcc/x86_64-redhat-linux/6.3.1/:/usr/libexec/gcc/x86_64-redhat-linux/:/usr/lib/gcc/x86_64-redhat-linux/6.3.1/:/usr/lib/gcc/x86_64-redhat-linux/
LIBRARY_PATH=/usr/lib/gcc/x86_64-redhat-linux/6.3.1/:/usr/lib/gcc/x86_64-redhat-linux/6.3.1/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib/gcc/x86_64-redhat-linux/6.3.1/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-o' '/dev/null' '-mtune=generic' '-march=x86-64'
/usr/libexec/gcc/x86_64-redhat-linux/6.3.1/collect2 -plugin /usr/libexec/gcc/x86_64-redhat-linux/6.3.1/liblto_plugin.so -plugin-opt=/usr/libexec/gcc/x86_64-redhat-linux/6.3.1/lto-wrapper -plugin-opt=-fresolution=/tmp/cce2dq2i.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 --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 /dev/null /usr/lib/gcc/x86_64-redhat-linux/6.3.1/../../../../lib64/crt1.o /usr/lib/gcc/x86_64-redhat-linux/6.3.1/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/6.3.1/crtbegin.o -L/usr/lib/gcc/x86_64-redhat-linux/6.3.1 -L/usr/lib/gcc/x86_64-redhat-linux/6.3.1/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/6.3.1/../../.. /dev/null -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-redhat-linux/6.3.1/crtend.o /usr/lib/gcc/x86_64-redhat-linux/6.3.1/../../../../lib64/crtn.o
/dev/null: file not recognized: File truncated
collect2: error: ld returned 1 exit status
I would like to put boost in the "regular place it should go in order for gcc to see it".
For gcc run cpp -v /dev/null -o /dev/null. In its output there are include search directories and LIBRARY_PATH with a list of library search directories. These are the regular places. Copying the headers and libraries into the regular places normally requires root permissions.
Alternatively, use -I/home/user/Desktop/boost extra command line option when compiling and -L/home/user/Desktop/boost/stage/lib -Wl,-rpath=/home/user/Desktop/boost/stage/lib when linking to use it from the current location.
Another way to build boost (and other 3rd-party libraries) is to have it installed in a separate directory, e.g. /usr/local with versioned directories, e.g. /usr/local/boost-1.60.0.
To build boost into /usr/local/boost-1.60.0 do the following commands in bash:
$ cd boost-1.60.0 # The directory with boost sources.
$ JOBS=8
$ PREFIX=/usr/local/boost-1.60.0
$ mkdir -p ${PREFIX}
$ ./bootstrap.sh --prefix=${PREFIX} --libdir=${PREFIX}/lib64
$ B2FLAGS="-j${JOBS} --layout=system --disable-icu variant=release link=shared threading=multi runtime-link=shared linkflags=-Wl,-rpath,${PREFIX}/lib64 boost.locale.icu=off boost.locale.iconv=on"
$ ./b2 ${B2FLAGS}
$ ./b2 ${B2FLAGS} install
The linkflags=-Wl,-rpath,${PREFIX}/lib64 bit makes sure that when you run your application boost shared libraries that depend on other boost shared libraries find them in that ${PREFIX}/lib64 directory.
And then use the following flags when builing your applications with boost you just built:
Flags for compiling (CPPFLAGS): -I/usr/local/boost-1.60.0/include.
Flags for linking (LDFLAGS): -L/usr/local/boost-1.60.0/lib64 -Wl,-rpath=/usr/local/boost-1.60.0/lib64.
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'm trying to use Mono's mkbundle tool to compile a native app for ARM (RaspberryPi) from an AMD64 system (Ubuntu 14.04 running in a VM).
Mono version is 4.4.2.11 (latest, at time of doing this), installed from Mono's package repository, but also tried with 4.2.3.4.
I'm running:
export CC="/usr/bin/arm-linux-gnueabi-gcc"
export AS="/usr/arm-linux-gnueabi/bin/as"
/usr/bin/mkbundle --static --deps --skip-scan \
-o artifacts/MyApp \
bin/Debug/MyApp.exe bin/Debug/*.dll
This works fine if I run it on the RaspberryPi itself (though I don't need to set the CC and AS variables).
If I run it from my AMD64 VM, it eventually runs the command:
/usr/bin/arm-linux-gnueabi-gcc -o artifacts/MyApp -Wall \
-D_REENTRANT -I/usr/lib/pkgconfig/../../include/mono-2.0 \
temp.c \
-L/usr/lib/pkgconfig/../../lib \
-Wl,-Bstatic -lmono-2.0 -Wl,-Bdynamic \
-lm -lrt -ldl -lpthread \
temp.o
Which results in:
/usr/lib/pkgconfig/../../lib/libmono-2.0.a: error adding symbols: File format not recognized
collect2: error: ld returned 1 exit status
Realizing that the libmono-2.0.a comes from an architecture-specific package, I downloaded the armel architecture package from http://download.mono-project.com/repo/debian/pool/main/m/mono/ and extracted it in my home directory (so there is a /home/gregmac/libmono-armel/usr/lib/libmono-2.0.a), then tried:
/usr/bin/arm-linux-gnueabi-gcc -o artifacts/MyApp -Wall \
-D_REENTRANT -I/home/gregmac/libmono-armel/usr/include/mono-2.0 \
temp.c \
-L/home/gregmac/libmono-armel/usr/lib \
-Wl,-Bstatic -lmono-2.0 -Wl,-Bdynamic \
-lm -lrt -ldl -lpthread \
-v \
temp.o
I've also tried setting LIBRARY_PATH and LD_LIBRARY_PATH to /home/gregmac/libmono-armel/usr/lib, but always getting the same problem.
Full output (including -v option):
Using built-in specs.
COLLECT_GCC=/usr/bin/arm-linux-gnueabi-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/lto-wrapper
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 --dis
able-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 --e
nable-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-l
inux-gnueabi --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='-o' 'artifacts/MyApp' '-Wall' '-D' '_REENTRANT' '-I' '/home/gregmac/libmono-armel/usr/include/mono-2.0' '-L/home/gregmac/libmono-armel/usr/lib' '-v' '-march=armv5t' '-mfloat-abi=soft' '-mtls-dialect=gnu'
/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/cc1 -quiet -v -I /home/gregmac/libmono-armel/usr/include/mono-2.0 -imultilib sf -imultiarch arm-linux-gnueabi -D _REENTRANT temp.c -quiet -dumpbase temp.c -march=armv5t -mfloat-abi=soft -mtls-dialect=gnu -auxbase temp -Wall -version -fstack-protector -o /tmp/cchyLX23.s
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/local/include/arm-linux-gnueabi"
ignoring nonexistent directory "/usr/include/arm-linux-gnueabi"
#include "..." search starts here:
#include <...> search starts here:
/home/gregmac/libmono-armel/usr/include/mono-2.0
/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
/usr/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: 550509f4ff92bab4626b84fc11f267f2
temp.c: In function ‘install_dll_config_files’:
temp.c:59:2: warning: pointer targets in passing argument 2 of ‘mono_register_config_for_assembly’ differ in signedness [-Wpointer-sign]
In file included from temp.c:2:0:
/home/gregmac/libmono-armel/usr/include/mono-2.0/mono/metadata/assembly.h:102:24: note: expected ‘const char *’ but argument is of type ‘const unsigned char *’
COLLECT_GCC_OPTIONS='-o' 'artifacts/MyApp' '-Wall' '-D' '_REENTRANT' '-I' '/home/gregmac/libmono-armel/usr/include/mono-2.0' '-L/home/gregmac/libmono-armel/usr/lib' '-v' '-march=armv5t' '-mfloat-abi=soft' '-mtls-dialect=gnu'
/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/bin/as -v -I /home/gregmac/libmono-armel/usr/include/mono-2.0 -march=armv5t -mfloat-abi=soft -meabi=5 -o /tmp/ccbJ6Gk5.o /tmp/cchyLX23.s
GNU assembler version 2.24 (arm-linux-gnueabi) using BFD version (GNU Binutils for Ubuntu) 2.24
COMPILER_PATH=/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/:/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/:/usr/lib/gcc-cross/arm-linux-gnueabi/:/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/:/usr/lib/gcc-cross/arm-linux-gnueabi/:/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/bin/
LIBRARY_PATH=/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/lib/../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/:/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/lib/:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-o' 'artifacts/MyApp' '-Wall' '-D' '_REENTRANT' '-I' '/home/gregmac/libmono-armel/usr/include/mono-2.0' '-L/home/gregmac/libmono-armel/usr/lib' '-v' '-march=armv5t' '-mfloat-abi=soft' '-mtls-dialect=gnu'
/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/collect2 --sysroot=/ --build-id --eh-frame-hdr -dynamic-linker /lib/ld-linux.so.3 -X --hash-style=gnu --as-needed -m armelf_linux_eabi -z relro -o artifacts/MyApp /usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/lib/../lib/crt1.o /usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/lib/../lib/crti.o /usr/lib/gcc-cross/arm-linux-gnueabi/4.7/crtbegin.o -L/home/gregmac/libmono-armel/usr/lib -L/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/lib/../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc-cross/arm-linux-gnueabi/4.7 -L/usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/lib /tmp/ccbJ6Gk5.o -Bstatic -lmono-2.0 -Bdynamic -lm -lrt -ldl -lpthread temp.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc-cross/arm-linux-gnueabi/4.7/crtend.o /usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/lib/../lib/crtn.o
/usr/lib/../lib/libmono-2.0.a: error adding symbols: File format not recognized
collect2: error: ld returned 1 exit status
I've also tried the same command but without --static, and get the same error, but about the .so instead of .a file:
/usr/lib/pkgconfig/../../lib/libmono-2.0.so: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
Am I missing something obvious here? Why is gcc still looking in /usr/lib/ instead of /home/gregmac/libmono-armel/usr/lib? Is there some other environment variable I should be setting so the original mkbundle command can invoke this correctly?
The source code is
package main
import "fmt"
func main() {
fmt.Println("hello world")
}
The Object file is built without error
root#OpenWrt:/mnt/sda3# gccgo -v -c hello.go
Using built-in specs.
COLLECT_GCC=gccgo
Target: mipsel-openwrt-linux-gnu
Configured with: /home/michal/Data/openwrt/mt7621/mtk-openwrt-master-eglibc/build_dir/target-mipsel_1004kc+dsp_eglibc-2.19/gcc-4.9.2/configure --target=mipsel-openwrt-linux --host=mipsel-openwrt-linux --build=x86_64-linux-gnu --program-prefix= --program-suffix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/lib --sysconfdir=/etc --datadir=/usr/share --localstatedir=/var --mandir=/usr/man --infodir=/usr/info --disable-nls --build=x86_64-linux-gnu --host=mipsel-openwrt-linux-gnu --target=mipsel-openwrt-linux-gnu --enable-languages=c,c++,go --with-bugurl=https://dev.openwrt.org/ --with-pkgversion='OpenWrt GCC 4.9.2' --enable-shared --disable-__cxa_atexit --enable-target-optspace --with-gnu-ld --disable-nls --disable-libmudflap --disable-multilib --disable-libgomp --disable-libquadmath --disable-libssp --disable-decimal-float --disable-libstdcxx-pch --with-host-libstdcxx=-lstdc++ --prefix=/usr --libexecdir=/usr/lib --with-float=soft
Thread model: posix
gcc version 4.9.2 (OpenWrt GCC 4.9.2)
COLLECT_GCC_OPTIONS='-v' '-c' '-o' 'hello.o' '-shared-libgcc' '-msoft-float' '-mllsc' '-mno-shared'
/usr/lib/gcc/mipsel-openwrt-linux-gnu/4.9.2/go1 hello.go -quiet -dumpbase hello.go -msoft-float -mllsc -mno-shared -auxbase-strip hello.o -version -L/usr/lib/gcc/mipsel-openwrt-linux-gnu/4.9.2 -L/usr/lib/gcc/mipsel-openwrt-linux-gnu/4.9.2/../../.. -o /tmp/ccWiioSJ.s
GNU Go (OpenWrt GCC 4.9.2) version 4.9.2 (mipsel-openwrt-linux-gnu)
compiled by GNU C version 4.8.3, 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=31962
GNU Go (OpenWrt GCC 4.9.2) version 4.9.2 (mipsel-openwrt-linux-gnu)
compiled by GNU C version 4.8.3, 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=31962
COLLECT_GCC_OPTIONS='-v' '-c' '-o' 'hello.o' '-shared-libgcc' '-msoft-float' '-mllsc' '-mno-shared'
as -v -EL -O1 -no-mdebug -mabi=32 -mno-shared -KPIC -o hello.o /tmp/ccWiioSJ.s
GNU assembler version 2.24 (mipsel-openwrt-linux-gnu) using BFD version (GNU Binutils) 2.24
COMPILER_PATH=/usr/lib/gcc/mipsel-openwrt-linux-gnu/4.9.2/:/usr/lib/gcc/mipsel-openwrt-linux-gnu/4.9.2/:/usr/lib/gcc/mipsel-openwrt-linux-gnu/:/usr/lib/gcc/mipsel-openwrt-linux-gnu/4.9.2/:/usr/lib/gcc/mipsel-openwrt-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/mipsel-openwrt-linux-gnu/4.9.2/:/usr/lib/gcc/mipsel-openwrt-linux-gnu/4.9.2/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-c' '-o' 'hello.o' '-shared-libgcc' '-msoft-float' '-mllsc' '-mno-shared'
But the linker reports an error undefined reference to `sync..import'.
root#OpenWrt:/mnt/sda2# gccgo -v -o hello hello.o
Using built-in specs.
COLLECT_GCC=gccgo
COLLECT_LTO_WRAPPER=/usr/lib/gcc/mipsel-openwrt-linux-gnu/4.9.2/lto-wrapper
Target: mipsel-openwrt-linux-gnu
Configured with: /home/michal/Data/openwrt/mt7621/mtk-openwrt-master-eglibc/build_dir/target-mipsel_1004kc+dsp_eglibc-2.19/gcc-4.9.2/configure --target=mipsel-openwrt-linux --host=mipsel-openwrt-linux --build=x86_64-linux-gnu --program-prefix= --program-suffix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/lib --sysconfdir=/etc --datadir=/usr/share --localstatedir=/var --mandir=/usr/man --infodir=/usr/info --disable-nls --build=x86_64-linux-gnu --host=mipsel-openwrt-linux-gnu --target=mipsel-openwrt-linux-gnu --enable-languages=c,c++,go --with-bugurl=https://dev.openwrt.org/ --with-pkgversion='OpenWrt GCC 4.9.2' --enable-shared --disable-__cxa_atexit --enable-target-optspace --with-gnu-ld --disable-nls --disable-libmudflap --disable-multilib --disable-libgomp --disable-libquadmath --disable-libssp --disable-decimal-float --disable-libstdcxx-pch --with-host-libstdcxx=-lstdc++ --prefix=/usr --libexecdir=/usr/lib --with-float=soft
Thread model: posix
gcc version 4.9.2 (OpenWrt GCC 4.9.2)
COMPILER_PATH=/usr/lib/gcc/mipsel-openwrt-linux-gnu/4.9.2/:/usr/lib/gcc/mipsel-openwrt-linux-gnu/4.9.2/:/usr/lib/gcc/mipsel-openwrt-linux-gnu/:/usr/lib/gcc/mipsel-openwrt-linux-gnu/4.9.2/:/usr/lib/gcc/mipsel-openwrt-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/mipsel-openwrt-linux-gnu/4.9.2/:/usr/lib/gcc/mipsel-openwrt-linux-gnu/4.9.2/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-o' 'hello' '-shared-libgcc' '-msoft-float' '-mllsc' '-mno-shared'
/usr/lib/gcc/mipsel-openwrt-linux-gnu/4.9.2/collect2 --eh-frame-hdr -EL -dynamic-linker /lib/ld.so.1 -o hello /usr/lib/gcc/mipsel-openwrt-linux-gnu/4.9.2/crt1.o /usr/lib/gcc/mipsel-openwrt-linux-gnu/4.9.2/crti.o /usr/lib/gcc/mipsel-openwrt-linux-gnu/4.9.2/crtbegin.o -L/usr/lib/gcc/mipsel-openwrt-linux-gnu/4.9.2 -L/usr/lib/gcc/mipsel-openwrt-linux-gnu/4.9.2/../../.. hello.o -lgobegin -lgo -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/mipsel-openwrt-linux-gnu/4.9.2/crtend.o /usr/lib/gcc/mipsel-openwrt-linux-gnu/4.9.2/crtn.o
hello.o: In function `__go_init_main':
hello.go:(.text+0x16c): undefined reference to `sync..import'
collect2: error: ld returned 1 exit status
What i missed? Thanks for help
I've tried static link the program, add a flag -static-libgo, it works.
Dynamic linking is iffy at best and not all that supported, so take it with a grain of salt.
That being said, it works for me, so something might be wrong with your gcc and/or libgo setup.
➜ gccgo -c hello.go
➜ gccgo -o hello hello.o
➜ ./hello
hello world
➜ ldd hello
linux-vdso.so.1 (0x00007fffb831f000)
libgo.so.5 => /usr/lib/libgo.so.5 (0x00007f214aaba000)
libm.so.6 => /usr/lib/libm.so.6 (0x00007f214a7b5000)
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f214a59f000)
libc.so.6 => /usr/lib/libc.so.6 (0x00007f214a1fc000)
/lib64/ld-linux-x86-64.so.2 (0x00007f214b919000)
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f2149fdf000)
➜ gccgo -v
Using built-in specs.
COLLECT_GCC=gccgo
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /build/gcc-multilib/src/gcc-4.9-20150204/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-cloog-backend=isl --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-multilib --disable-werror --enable-checking=release
Thread model: posix
gcc version 4.9.2 20150204 (prerelease) (GCC)
If you're trying to get a small executable size, look into using upx as a workaround or try to compile gccgo by hand.