How to make g++ require a standard `main`? - c++

In particular, how can g++ be made to reject this invalid-as-standard-C++ code:
main(){}
?
I'm using MinGW g++ 6.2.0, but I imagine an answer will apply to all currently used variants of g++.
Example of what I've tried:
[C:\my\temp]
> g++ --version | find "++"
g++ (i686-win32-dwarf-rev1, Built by MinGW-W64 project) 6.2.0
[C:\my\temp]
> type foo.cpp
main() {}
[C:\my\temp]
> dir /b
foo.cpp
[C:\my\temp]
> g++ foo.cpp -Wall -Wextra -Wreturn-type -pedantic
[C:\my\temp]
> dir /b
a.exe
foo.cpp
[C:\my\temp]
> _
Version info with verbose compiler output:
C:\my\temp]
> g++ -v --version
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=C:/Program\ Files\ (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../libexec/gcc/i686-w64-mingw32/6.2.0/lto-wrapper.exe
g++ (i686-win32-dwarf-rev1, Built by MinGW-W64 project) 6.2.0
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Target: i686-w64-mingw32
Configured with: ../../../src/gcc-6.2.0/configure --host=i686-w64-mingw32 --build=i686-w64-mingw32 --target=i686-w64-mingw32 --prefix=/mingw32 --with-sysroot=/c/mingw620/i686-620-win32-dwarf-rt_v5-rev1/mingw32 --enable-shared --enable-static --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=win32 --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --enable-libstdcxx-filesystem-ts=yes --disable-sjlj-exceptions --with-dwarf2 --disable-isl-version-check --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=i686 --with-tune=generic --with-libiconv --with-system-zlib --with-gmp=/c/mingw620/prerequisites/i686-w64-mingw32-static --with-mpfr=/c/mingw620/prerequisites/i686-w64-mingw32-static --with-mpc=/c/mingw620/prerequisites/i686-w64-mingw32-static --with-isl=/c/mingw620/prerequisites/i686-w64-mingw32-static --with-pkgversion='i686-win32-dwarf-rev1, Built by MinGW-W64 project' --with-bugurl=http://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -I/c/mingw620/i686-620-win32-dwarf-rt_v5-rev1/mingw32/opt/include -I/c/mingw620/prerequisites/i686-zlib-static/include -I/c/mingw620/prerequisites/i686-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -I/c/mingw620/i686-620-win32-dwarf-rt_v5-rev1/mingw32/opt/include -I/c/mingw620/prerequisites/i686-zlib-static/include -I/c/mingw620/prerequisites/i686-w64-mingw32-static/include' CPPFLAGS= LDFLAGS='-pipe -L/c/mingw620/i686-620-win32-dwarf-rt_v5-rev1/mingw32/opt/lib -L/c/mingw620/prerequisites/i686-zlib-static/lib -L/c/mingw620/prerequisites/i686-w64-mingw32-static/lib -Wl,--large-address-aware'
Thread model: win32
gcc version 6.2.0 (i686-win32-dwarf-rev1, Built by MinGW-W64 project)
COLLECT_GCC_OPTIONS='-v' '--version' '-shared-libgcc' '-mtune=generic' '-march=i686'
C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../libexec/gcc/i686-w64-mingw32/6.2.0/cc1.exe -quiet -v -iprefix C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/ -U_REENTRANT help-dummy -quiet -dumpbase help-dummy -mtune=generic -march=i686 -auxbase help-dummy -version --version -o C:\Users\AlfP\AppData\Local\Temp\cc4K0l79.s
GNU C11 (i686-win32-dwarf-rev1, Built by MinGW-W64 project) version 6.2.0 (i686-w64-mingw32)
compiled by GNU C version 6.2.0, GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.3, isl version 0.15
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
COLLECT_GCC_OPTIONS='-v' '--version' '-shared-libgcc' '-mtune=generic' '-march=i686'
C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../../../i686-w64-mingw32/bin/as.exe -v --version -o C:\Users\AlfP\AppData\Local\Temp\ccn2QnTg.o C:\Users\AlfP\AppData\Local\Temp\cc4K0l79.s
GNU assembler version 2.25 (i686-w64-mingw32) using BFD version (GNU Binutils) 2.25
GNU assembler (GNU Binutils) 2.25
Copyright (C) 2014 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `i686-w64-mingw32'.
COMPILER_PATH=C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../libexec/gcc/i686-w64-mingw32/6.2.0/;C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../libexec/gcc/;C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../../../i686-w64-mingw32/bin/
LIBRARY_PATH=C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/;C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/;C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../../../i686-w64-mingw32/lib/../lib/;C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../../../lib/;C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../../../i686-w64-mingw32/lib/;C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../../
COLLECT_GCC_OPTIONS='-v' '--version' '-shared-libgcc' '-mtune=generic' '-march=i686'
C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../libexec/gcc/i686-w64-mingw32/6.2.0/collect2.exe -plugin C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../libexec/gcc/i686-w64-mingw32/6.2.0/liblto_plugin-0.dll -plugin-opt=C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../libexec/gcc/i686-w64-mingw32/6.2.0/lto-wrapper.exe -plugin-opt=-fresolution=C:\Users\AlfP\AppData\Local\Temp\ccXVaxln.res -plugin-opt=-pass-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=-liconv -plugin-opt=-pass-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 --sysroot=C:/mingw620/i686-620-win32-dwarf-rt_v5-rev1/mingw32 -m i386pe -Bdynamic -u ___register_frame_info -u ___deregister_frame_info --version C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../../../i686-w64-mingw32/lib/../lib/crt2.o C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/crtbegin.o -LC:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0 -LC:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc -LC:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../../../i686-w64-mingw32/lib/../lib -LC:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../../../lib -LC:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../../../i686-w64-mingw32/lib -LC:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../.. C:\Users\AlfP\AppData\Local\Temp\ccn2QnTg.o -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 -liconv -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/crtend.o
collect2 version 6.2.0
C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../../../i686-w64-mingw32/bin/ld.exe -plugin C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../libexec/gcc/i686-w64-mingw32/6.2.0/liblto_plugin-0.dll -plugin-opt=C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../libexec/gcc/i686-w64-mingw32/6.2.0/lto-wrapper.exe -plugin-opt=-fresolution=C:\Users\AlfP\AppData\Local\Temp\ccXVaxln.res -plugin-opt=-pass-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=-liconv -plugin-opt=-pass-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 --sysroot=C:/mingw620/i686-620-win32-dwarf-rt_v5-rev1/mingw32 -m i386pe -Bdynamic -u ___register_frame_info -u ___deregister_frame_info --version C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../../../i686-w64-mingw32/lib/../lib/crt2.o C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/crtbegin.o -LC:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0 -LC:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc -LC:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../../../i686-w64-mingw32/lib/../lib -LC:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../../../lib -LC:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../../../i686-w64-mingw32/lib -LC:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/../../.. C:\Users\AlfP\AppData\Local\Temp\ccn2QnTg.o -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 -liconv -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt C:/Program Files (x86)/mingw-w64/i686-6.2.0-win32-dwarf-rt_v5-rev1/mingw32/bin/../lib/gcc/i686-w64-mingw32/6.2.0/crtend.o
GNU ld (GNU Binutils) 2.25
Copyright (C) 2014 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
COLLECT_GCC_OPTIONS='-v' '--version' '-shared-libgcc' '-mtune=generic' '-march=i686'
[C:\my\temp]
> _

You can pass -pedantic-errors, which gives the following error message on g++ 6.3:
main.cpp:1:6: error: ISO C++ forbids declaration of 'main' with no type [-Wpedantic]
main(){}
Live demo
Here is the documentation for -pedantic-errors:
Give an error whenever the base standard (see -Wpedantic) requires a diagnostic, in some cases where
there is undefined behavior at compile-time and in some other cases that do not prevent compilation of
programs that are valid according to the standard. This is not equivalent to -Werror=pedantic, since
there are errors enabled by this option and not enabled by the latter and vice versa.

Once you enable warnings (-Wall), g++ will complain about this code. Additionally you can have the warnings be treated as errors (-Werror), so that the compilation fails (a good thing to have).
Example with g++ 5.4.0:
kos#Starbuck ~$ cat bar.cpp
main(){}
kos#Starbuck ~$ g++ bar.cpp
kos#Starbuck ~$ g++ bar.cpp -Wall -Werror
bar.cpp:1:6: error: ISO C++ forbids declaration of ‘main’ with no type [-Werror=return-type]
main(){}
^
cc1plus: all warnings being treated as errors

Related

G++ not understanding console option

So, I need to compile, assemble, and link a C++ file. But, I need to use an external library with it. So, I'm attempting to do so with G++ using this batch file:
g++ -c WindowTest.cpp -I include\bgfx-master\include\bgfx -I include\glfw-3.3.8.bin.WIN32\include\GLFW --verbose
g++ WindowTest.o -o WindowTest.exe -static -L include\glfw-3.3.8.bin.WIN32\lib-vc2022 -l glfw3.lib --verbose
However, when run, I get this output:
g++ -c WindowTest.cpp -I include\bgfx-master\include\bgfx -I include\glfw-3.3.8.bin.WIN32\include\GLFW --verbose
Using built-in specs.
COLLECT_GCC=g++
Target: mingw32
Configured with: ../src/gcc-6.3.0/configure --build=x86_64-pc-linux-gnu --host=mingw32 --with-gmp=/mingw --with-mpfr=/mingw --with-mpc=/mingw --with-isl=/mingw --prefix=/mingw --disable-win32-registry --target=mingw32 --with-arch=i586 --enable-languages=c,c++,objc,obj-c++,fortran,ada --with-pkgversion='MinGW.org GCC-6.3.0-1' --enable-static --enable-shared --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --with-libiconv-prefix=/mingw --with-libintl-prefix=/mingw --enable-libstdcxx-debug --with-tune=generic --enable-libgomp --disable-libvtv --enable-nls
Thread model: win32
gcc version 6.3.0 (MinGW.org GCC-6.3.0-1)
COLLECT_GCC_OPTIONS='-c' '-I' 'include\bgfx-master\include\bgfx' '-I' 'include\glfw-3.3.8.bin.WIN32\include\GLFW' '-v' '-shared-libgcc' '-mtune=generic' '-march=i586'
c:/mingw/bin/../libexec/gcc/mingw32/6.3.0/cc1plus.exe -quiet -v -I include\bgfx-master\include\bgfx -I include\glfw-3.3.8.bin.WIN32\include\GLFW -iprefix c:\mingw\bin\../lib/gcc/mingw32/6.3.0/ WindowTest.cpp -quiet -dumpbase WindowTest.cpp -mtune=generic -march=i586 -auxbase WindowTest -version -o C:\Users\owenr\AppData\Local\Temp\ccnfsknd.s
GNU C++14 (MinGW.org GCC-6.3.0-1) version 6.3.0 (mingw32)
compiled by GNU C version 6.3.0, GMP version 6.1.2, MPFR version 3.1.5, MPC version 1.0.2, isl version 0.15
warning: MPC header version 1.0.2 differs from library version 1.0.3.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/6.3.0/include/c++"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/6.3.0/include/c++/mingw32"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/6.3.0/include/c++/backward"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/6.3.0/include"
ignoring duplicate directory "/mingw/lib/gcc/mingw32/6.3.0/../../../../include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/6.3.0/include-fixed"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/6.3.0/../../../../mingw32/include"
ignoring duplicate directory "/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
include\bgfx-master\include\bgfx
include\glfw-3.3.8.bin.WIN32\include\GLFW
c:\mingw\bin\../lib/gcc/mingw32/6.3.0/include/c++
c:\mingw\bin\../lib/gcc/mingw32/6.3.0/include/c++/mingw32
c:\mingw\bin\../lib/gcc/mingw32/6.3.0/include/c++/backward
c:\mingw\bin\../lib/gcc/mingw32/6.3.0/include
c:\mingw\bin\../lib/gcc/mingw32/6.3.0/../../../../include
c:\mingw\bin\../lib/gcc/mingw32/6.3.0/include-fixed
c:\mingw\bin\../lib/gcc/mingw32/6.3.0/../../../../mingw32/include
End of search list.
GNU C++14 (MinGW.org GCC-6.3.0-1) version 6.3.0 (mingw32)
compiled by GNU C version 6.3.0, GMP version 6.1.2, MPFR version 3.1.5, MPC version 1.0.2, isl version 0.15
warning: MPC header version 1.0.2 differs from library version 1.0.3.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: af09a87986453bf79da3565f33c7648f
COLLECT_GCC_OPTIONS='-c' '-I' 'include\bgfx-master\include\bgfx' '-I' 'include\glfw-3.3.8.bin.WIN32\include\GLFW' '-v' '-shared-libgcc' '-mtune=generic' '-march=i586'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/as.exe -v -I include\bgfx-master\include\bgfx -I include\glfw-3.3.8.bin.WIN32\include\GLFW -o WindowTest.o C:\Users\owenr\AppData\Local\Temp\ccnfsknd.s
GNU assembler version 2.28 (mingw32) using BFD version (GNU Binutils) 2.28
COMPILER_PATH=c:/mingw/bin/../libexec/gcc/mingw32/6.3.0/;c:/mingw/bin/../libexec/gcc/;c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/
LIBRARY_PATH=c:/mingw/bin/../lib/gcc/mingw32/6.3.0/;c:/mingw/bin/../lib/gcc/;c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/lib/;c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../
COLLECT_GCC_OPTIONS='-c' '-I' 'include\bgfx-master\include\bgfx' '-I' 'include\glfw-3.3.8.bin.WIN32\include\GLFW' '-v' '-shared-libgcc' '-mtune=generic' '-march=i586'
$-> g++ WindowTest.o -o WindowTest.exe -static -L include\glfw-3.3.8.bin.WIN32\lib-vc2022 -l glfw3.lib --verbose
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/6.3.0/lto-wrapper.exe
Target: mingw32
Configured with: ../src/gcc-6.3.0/configure --build=x86_64-pc-linux-gnu --host=mingw32 --with-gmp=/mingw --with-mpfr=/mingw --with-mpc=/mingw --with-isl=/mingw --prefix=/mingw --disable-win32-registry --target=mingw32 --with-arch=i586 --enable-languages=c,c++,objc,obj-c++,fortran,ada --with-pkgversion='MinGW.org GCC-6.3.0-1' --enable-static --enable-shared --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --with-libiconv-prefix=/mingw --with-libintl-prefix=/mingw --enable-libstdcxx-debug --with-tune=generic --enable-libgomp --disable-libvtv --enable-nls
Thread model: win32
gcc version 6.3.0 (MinGW.org GCC-6.3.0-1)
COMPILER_PATH=c:/mingw/bin/../libexec/gcc/mingw32/6.3.0/;c:/mingw/bin/../libexec/gcc/;c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/
LIBRARY_PATH=c:/mingw/bin/../lib/gcc/mingw32/6.3.0/;c:/mingw/bin/../lib/gcc/;c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/lib/;c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../
COLLECT_GCC_OPTIONS='-o' 'WindowTest.exe' '-static' '-Linclude\glfw-3.3.8.bin.WIN32\lib-vc2022' '-v' '-mtune=generic' '-march=i586'
c:/mingw/bin/../libexec/gcc/mingw32/6.3.0/collect2.exe -plugin c:/mingw/bin/../libexec/gcc/mingw32/6.3.0/liblto_plugin-0.dll -plugin-opt=c:/mingw/bin/../libexec/gcc/mingw32/6.3.0/lto-wrapper.exe -plugin-opt=-fresolution=C:\Users\owenr\AppData\Local\Temp\ccyUGRgT.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=-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 -Bstatic -o WindowTest.exe c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../crt2.o c:/mingw/bin/../lib/gcc/mingw32/6.3.0/crtbegin.o -Linclude\glfw-3.3.8.bin.WIN32\lib-vc2022 -Lc:/mingw/bin/../lib/gcc/mingw32/6.3.0 -Lc:/mingw/bin/../lib/gcc -Lc:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/lib -Lc:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../.. WindowTest.o -lglfw3.lib -lstdc++ -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt c:/mingw/bin/../lib/gcc/mingw32/6.3.0/crtend.o
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot find -lglfw3.lib
collect2.exe: error: ld returned 1 exit status
I've tried moving the library file, adding or removing space between the -l option and glfw3.lib, and many other things. It gives this output every time unless I just don't try to include the library file, in which case I get this error:
WindowTest.o:WindowTest.cpp:(.text+0xc): undefined reference to `glfwInit'
collect2.exe: error: ld returned 1 exit status
Edit:
Here's the file system
Main Directory:
include
glfw-3.3.8.bin.WIN32
include
glw3.h (Header file included in WindowTest.cpp)
lib-vc2022
glfw3.lib (Library file I want to include)
WindowTest.cpp
MakeFile.bat (Has g++ commands)

How to compile C++ using MinGW on Windows?

I'm getting the following error
cannot find -lstdc++
collect2.exe: error: ld returned 1 exit status
it's a simple Hello World program.
g++ version returns
g++ (MinGW.org GCC Build-2) 9.2.0
g++ -v <filename.cpp> returns
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/9.2.0/lto-wrapper.exe
Target: mingw32
Configured with: ../src/gcc-9.2.0/configure --build=x86_64-pc-linux-gnu --host=mingw32 --target=mingw32 --disable-win32-registry --with-arch=i586 --with-tune=generic --enable-static --enable-shared --enable-threads --enable-languages=c,c++,objc,obj-c++,fortran,ada --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --enable-libgomp --disable-libvtv --with-libiconv-prefix=/mingw --with-libintl-prefix=/mingw --enable-libstdcxx-debug --disable-build-format-warnings --prefix=/mingw --with-gmp=/mingw --with-mpfr=/mingw --with-mpc=/mingw --with-isl=/mingw --enable-nls --with-pkgversion='MinGW.org GCC Build-2'
Thread model: win32
gcc version 9.2.0 (MinGW.org GCC Build-2)
COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mtune=generic' '-march=i586'
c:/mingw/bin/../libexec/gcc/mingw32/9.2.0/cc1plus.exe -quiet -v -iprefix c:\mingw\bin\../lib/gcc/mingw32/9.2.0/ hw.cpp -quiet -dumpbase hw.cpp -mtune=generic -march=i586 -auxbase hw -version -o C:\Users\move78~1\AppData\Local\Temp\ccQus9Kp.s
GNU C++14 (MinGW.org GCC Build-2) version 9.2.0 (mingw32)
compiled by GNU C version 9.2.0, GMP version 6.1.2, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.21-GMP
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "c:\mingw\bin\../lib/gcc/mingw32/9.2.0/../../../../mingw32/include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/9.2.0/include/c++"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/9.2.0/include/c++/mingw32"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/9.2.0/include/c++/backward"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/9.2.0/include"
ignoring duplicate directory "/mingw/lib/gcc/mingw32/9.2.0/../../../../include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/9.2.0/include-fixed"
ignoring nonexistent directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/9.2.0/../../../../mingw32/include"
ignoring duplicate directory "/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
c:\mingw\bin\../lib/gcc/mingw32/9.2.0/include/c++
c:\mingw\bin\../lib/gcc/mingw32/9.2.0/include/c++/mingw32
c:\mingw\bin\../lib/gcc/mingw32/9.2.0/include/c++/backward
c:\mingw\bin\../lib/gcc/mingw32/9.2.0/include
c:\mingw\bin\../lib/gcc/mingw32/9.2.0/../../../../include
c:\mingw\bin\../lib/gcc/mingw32/9.2.0/include-fixed
End of search list.
GNU C++14 (MinGW.org GCC Build-2) version 9.2.0 (mingw32)
compiled by GNU C version 9.2.0, GMP version 6.1.2, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.21-GMP
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: cb31672760a9c1b42d1ddb86616116cd
COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mtune=generic' '-march=i586'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/as.exe -v -o C:\Users\move78~1\AppData\Local\Temp\cctjBjko.o C:\Users\move78~1\AppData\Local\Temp\ccQus9Kp.s
GNU assembler version 2.32 (mingw32) using BFD version (GNU Binutils) 2.32
COMPILER_PATH=c:/mingw/bin/../libexec/gcc/mingw32/9.2.0/;c:/mingw/bin/../libexec/gcc/;c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/
LIBRARY_PATH=c:/mingw/bin/../lib/gcc/mingw32/9.2.0/;c:/mingw/bin/../lib/gcc/;c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/lib/;c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../
COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mtune=generic' '-march=i586'
c:/mingw/bin/../libexec/gcc/mingw32/9.2.0/collect2.exe -plugin c:/mingw/bin/../libexec/gcc/mingw32/9.2.0/liblto_plugin-0.dll -plugin-opt=c:/mingw/bin/../libexec/gcc/mingw32/9.2.0/lto-wrapper.exe -plugin-opt=-fresolution=C:\Users\move78~1\AppData\Local\Temp\ccxROszG.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -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-through=-lmingwex -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmsvcrt -Bdynamic -u ___register_frame_info -u ___deregister_frame_info c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../crt2.o c:/mingw/bin/../lib/gcc/mingw32/9.2.0/crtbegin.o -Lc:/mingw/bin/../lib/gcc/mingw32/9.2.0 -Lc:/mingw/bin/../lib/gcc -Lc:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/lib -Lc:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../.. C:\Users\move78~1\AppData\Local\Temp\cctjBjko.o -lstdc++ -lmingw32 -lmingwex -lmingw32 -lmingwex -lgcc_s -lgcc -lmoldname -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lmingwex -lmingw32 -lmingwex -lgcc_s -lgcc -lmoldname -lmsvcrt c:/mingw/bin/../lib/gcc/mingw32/9.2.0/crtend.o
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: cannot find -lstdc++
collect2.exe: error: ld returned 1 exit status
You need 3 things to build:
Your tools (like g++.exe) need to be in your PATH (or specified via their full path when calling them, e.g. C:\mingw\mingw32\bin\g++.exe).
The compiler needs to be able to find the include files. If needed you can add include paths (pointing to the folder, not the actual file) using -I flags (or you can use C_INCLUDE_PATH (for C) and CPLUS_INCLUDE_PATH (for C++) environment variables).
The linker needs be able to find your libraries (like libstdc++.a). If needed you can add library paths (pointing to the folder, not the actual file) using -L flags (or you can use LIBRARY_PATH environment variable).
If you use MSYS2 shell these things should already have been set up.
The standalone build from http://winlibs.com/ looks for relative locations and should just work wherever you extract it on your disk.
You didn't mention which shell you were running your commands from (Command Prompt, PowerShell, MSYS), but it's important the above is respected correctly in whatever shell you are using.
As far as I know http://winlibs.com/ works in MSYS shell, Command Prompt and PowerShell (though parameters starting with - need to be put in quotes when using PowerShell).

debugging remote application with Eclipse gdb/gdbserver

I want to debug an application with Eclipse Oxygen on an arm-linux (debian) target where ssh is not installed.
So I used the C/C++ Attach to Application method.
I've compiled the application with g3option of course and copied the application on the target.
I've started gdbserver on the target.
When I start debugging (using the cross gdb of course), it connects to gdbserver via TCP and it stops on the application's start address but it doesn't load the source file.
When I click on resume, the application starts normally.
If I debug it locally, everything works well of course.
What is missing here to get the source files loaded?
What usefull info I can provide to guess what's wrong?
Edit
make all
Building file: ../src/main.c
Invoking: Cross GCC Compiler
arm-buildroot-linux-gnueabihf-gcc -std=c99 -I"/home/user/Documents/Dev/Xwidgets/inc" -I"/home/user/Documents/Dev/myApp/inc" -O0 -g3 -Wall -c -fmessage-length=0 -Wno-missing-braces --sysroot=/home/user/Documents/myProject/sysroot -D_REENTRANT -fsigned-char -v -MMD -MP -MF"src/main.d" -MT"src/main.o" -o "src/main.o" "../src/main.c"
Utilisation des specs internes.
COLLECT_GCC=/home/user/Documents/myProject/buildroot-2017.05.2/board/a20som_IM4/cross/usr/bin/arm-buildroot-linux-gnueabihf-gcc.br_real
Target: arm-buildroot-linux-gnueabihf
Configuré avec: ./configure --prefix=/home/user/Documents/myProject/buildroot-2017.05.2/buildroot-2017.05.2/../board/a20som_IM4/cross/usr --sysconfdir=/home/user/Documents/myProject/buildroot-2017.05.2/buildroot-2017.05.2/../board/a20som_IM4/cross/etc --enable-static --target=arm-buildroot-linux-gnueabihf --with-sysroot=/home/user/Documents/myProject/buildroot-2017.05.2/buildroot-2017.05.2/../board/a20som_IM4/cross/usr/arm-buildroot-linux-gnueabihf/sysroot --disable-__cxa_atexit --with-gnu-ld --disable-libssp --disable-multilib --with-gmp=/home/user/Documents/myProject/buildroot-2017.05.2/buildroot-2017.05.2/../board/a20som_IM4/cross/usr --with-mpc=/home/user/Documents/myProject/buildroot-2017.05.2/buildroot-2017.05.2/../board/a20som_IM4/cross/usr --with-mpfr=/home/user/Documents/myProject/buildroot-2017.05.2/buildroot-2017.05.2/../board/a20som_IM4/cross/usr --with-pkgversion='Buildroot 2017.05.2-g3bca02e-dirty' --with-bugurl=http://bugs.buildroot.net/ --disable-libquadmath --enable-tls --disable-libmudflap --enable-threads --without-isl --without-cloog --disable-decimal-float --with-abi=aapcs-linux --with-cpu=cortex-a7 --with-fpu=vfpv4-d16 --with-float=hard --with-mode=arm --enable-languages=c --with-build-time-tools=/home/user/Documents/myProject/buildroot-2017.05.2/buildroot-2017.05.2/../board/a20som_IM4/cross/usr/arm-buildroot-linux-gnueabihf/bin --enable-shared --disable-libgomp
Modèle de thread: posix
gcc version 4.9.4 (Buildroot 2017.05.2-g3bca02e-dirty)
COLLECT_GCC_OPTIONS='-std=c99' '-I' '/home/user/Documents/Dev/Xwidgets/inc' '-I' '/home/user/Documents/Dev/myApp/inc' '-O0' '-g3' '-Wall' '-c' '-fmessage-length=0' '-Wno-missing-braces' '-D' '_REENTRANT' '-fsigned-char' '-v' '-MMD' '-MP' '-MF' 'src/main.d' '-MT' 'src/main.o' '-o' 'src/main.o' '-mcpu=cortex-a7' '-mfloat-abi=hard' '-mfpu=vfpv4-d16' '-mabi=aapcs-linux' '-marm' '-mtls-dialect=gnu'
/home/user/Documents/myProject/buildroot-2017.05.2/board/a20som_IM4/cross/usr/bin/../libexec/gcc/arm-buildroot-linux-gnueabihf/4.9.4/cc1 -quiet -v -I /home/user/Documents/Dev/Xwidgets/inc -I /home/user/Documents/Dev/myApp/inc -iprefix /home/user/Documents/myProject/buildroot-2017.05.2/board/a20som_IM4/cross/usr/bin/../lib/gcc/arm-buildroot-linux-gnueabihf/4.9.4/ -isysroot /home/user/Documents/myProject/sysroot -MMD src/main.d -MF src/main.d -MP -MT src/main.o -dD -D _REENTRANT ../src/main.c -quiet -dumpbase main.c -mcpu=cortex-a7 -mfloat-abi=hard -mfpu=vfpv4-d16 -mabi=aapcs-linux -marm -mtls-dialect=gnu -auxbase-strip src/main.o -g3 -O0 -Wall -Wno-missing-braces -std=c99 -version -fmessage-length=0 -fsigned-char -o /tmp/ccdyGfCH.s
GNU C (Buildroot 2017.05.2-g3bca02e-dirty) version 4.9.4 (arm-buildroot-linux-gnueabihf)
compiled by GNU C version 6.3.0 20170516, GMP version 6.1.2, MPFR version 3.1.5, MPC version 1.0.3
heuristiques GGC: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
directory « /home/user/Documents/myProject/buildroot-2017.05.2/board/a20som_IM4/cross/usr/bin/../lib/gcc/arm-buildroot-linux-gnueabihf/4.9.4/../../../../arm-buildroot-linux-gnueabihf/include » est ignoré car inexistant
directory « /home/user/Documents/myProject/buildroot-2017.05.2/board/a20som_IM4/cross/usr/bin/../lib/gcc/../../lib/gcc/arm-buildroot-linux-gnueabihf/4.9.4/include » est ignoré car présent deux fois
directory « /home/user/Documents/myProject/sysroot/usr/local/include » est ignoré car inexistant
directory « /home/user/Documents/myProject/buildroot-2017.05.2/board/a20som_IM4/cross/usr/bin/../lib/gcc/../../lib/gcc/arm-buildroot-linux-gnueabihf/4.9.4/include-fixed » est ignoré car présent deux fois
directory « /home/user/Documents/myProject/buildroot-2017.05.2/board/a20som_IM4/cross/usr/bin/../lib/gcc/../../lib/gcc/arm-buildroot-linux-gnueabihf/4.9.4/../../../../arm-buildroot-linux-gnueabihf/include » est ignoré car inexistant
la recherche pour #include "..." débute ici :
la recherche pour #include <...> débute ici:
/home/user/Documents/Dev/Xwidgets/inc
/home/user/Documents/Dev/myApp/inc
/home/user/Documents/myProject/buildroot-2017.05.2/board/a20som_IM4/cross/usr/bin/../lib/gcc/arm-buildroot-linux-gnueabihf/4.9.4/include
/home/user/Documents/myProject/buildroot-2017.05.2/board/a20som_IM4/cross/usr/bin/../lib/gcc/arm-buildroot-linux-gnueabihf/4.9.4/include-fixed
/home/user/Documents/myProject/sysroot/usr/include
Fin de la liste de recherche.
GNU C (Buildroot 2017.05.2-g3bca02e-dirty) version 4.9.4 (arm-buildroot-linux-gnueabihf)
compiled by GNU C version 6.3.0 20170516, GMP version 6.1.2, MPFR version 3.1.5, MPC version 1.0.3
heuristiques GGC: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 97c01351799a22899fe6b56e86741046
COLLECT_GCC_OPTIONS='-std=c99' '-I' '/home/user/Documents/Dev/Xwidgets/inc' '-I' '/home/user/Documents/Dev/myApp/inc' '-O0' '-g3' '-Wall' '-c' '-fmessage-length=0' '-Wno-missing-braces' '-D' '_REENTRANT' '-fsigned-char' '-v' '-MMD' '-MP' '-MF' 'src/main.d' '-MT' 'src/main.o' '-o' 'src/main.o' '-mcpu=cortex-a7' '-mfloat-abi=hard' '-mfpu=vfpv4-d16' '-mabi=aapcs-linux' '-marm' '-mtls-dialect=gnu'
/home/user/Documents/myProject/buildroot-2017.05.2/board/a20som_IM4/cross/usr/bin/../lib/gcc/arm-buildroot-linux-gnueabihf/4.9.4/../../../../arm-buildroot-linux-gnueabihf/bin/as -v -I /home/user/Documents/Dev/Xwidgets/inc -I /home/user/Documents/Dev/myApp/inc -mcpu=cortex-a7 -mfloat-abi=hard -mfpu=vfpv4-d16 -meabi=5 -o src/main.o /tmp/ccdyGfCH.s
Version de l'assembleur GNU 2.27 (arm-buildroot-linux-gnueabihf) utilisant la version BFD (GNU Binutils) 2.27
COMPILER_PATH=/home/user/Documents/myProject/buildroot-2017.05.2/board/a20som_IM4/cross/usr/bin/../libexec/gcc/arm-buildroot-linux-gnueabihf/4.9.4/:/home/user/Documents/myProject/buildroot-2017.05.2/board/a20som_IM4/cross/usr/bin/../libexec/gcc/:/home/user/Documents/myProject/buildroot-2017.05.2/board/a20som_IM4/cross/usr/bin/../lib/gcc/arm-buildroot-linux-gnueabihf/4.9.4/../../../../arm-buildroot-linux-gnueabihf/bin/
LIBRARY_PATH=/home/user/Documents/myProject/buildroot-2017.05.2/board/a20som_IM4/cross/usr/bin/../lib/gcc/arm-buildroot-linux-gnueabihf/4.9.4/:/home/user/Documents/myProject/buildroot-2017.05.2/board/a20som_IM4/cross/usr/bin/../lib/gcc/:/home/user/Documents/myProject/buildroot-2017.05.2/board/a20som_IM4/cross/usr/bin/../lib/gcc/arm-buildroot-linux-gnueabihf/4.9.4/../../../../arm-buildroot-linux-gnueabihf/lib/:/home/user/Documents/myProject/sysroot/lib/:/home/user/Documents/myProject/sysroot/usr/lib/
COLLECT_GCC_OPTIONS='-std=c99' '-I' '/home/user/Documents/Dev/Xwidgets/inc' '-I' '/home/user/Documents/Dev/myApp/inc' '-O0' '-g3' '-Wall' '-c' '-fmessage-length=0' '-Wno-missing-braces' '-D' '_REENTRANT' '-fsigned-char' '-v' '-MMD' '-MP' '-MF' 'src/main.d' '-MT' 'src/main.o' '-o' 'src/main.o' '-mcpu=cortex-a7' '-mfloat-abi=hard' '-mfpu=vfpv4-d16' '-mabi=aapcs-linux' '-marm' '-mtls-dialect=gnu'
Finished building: ../src/main.c
Building target: myApp
Invoking: Cross GCC Linker
arm-buildroot-linux-gnueabihf-gcc -L"/home/user/Documents/Dev/Xwidgets/a20som_IM4" -v --sysroot=/home/user/Documents/myProject/sysroot -o "myApp" ./src/IMV_asymmetry.o ./src/IMV_power.o ./src/IMV_precision.o ./src/IMV_random.o ./src/IMV_sensibility.o ./src/IMV_speed.o ./src/IMV_timer.o ./src/free_session_screen.o ./src/fs_big_toolbar.o ./src/fs_page_1.o ./src/fs_page_2.o ./src/fs_page_3.o ./src/fs_page_4.o ./src/fs_right_sidebar.o ./src/fs_small_toolbar.o ./src/main.o ./src/patient_screen.o ./src/programs_screen.o ./src/run_timeline.o ./src/running_screen.o ./src/welcome_screen.o -lXwidgets -lpthread -lm -ljpeg -lpng16 -lSDL2 -lSDL2_image -lSDL2_ttf -ljson-c
Utilisation des specs internes.
COLLECT_GCC=/home/user/Documents/myProject/buildroot-2017.05.2/board/a20som_IM4/cross/usr/bin/arm-buildroot-linux-gnueabihf-gcc.br_real
COLLECT_LTO_WRAPPER=/home/user/Documents/myProject/buildroot-2017.05.2/board/a20som_IM4/cross/usr/bin/../libexec/gcc/arm-buildroot-linux-gnueabihf/4.9.4/lto-wrapper
Target: arm-buildroot-linux-gnueabihf
Configuré avec: ./configure --prefix=/home/user/Documents/myProject/buildroot-2017.05.2/buildroot-2017.05.2/../board/a20som_IM4/cross/usr --sysconfdir=/home/user/Documents/myProject/buildroot-2017.05.2/buildroot-2017.05.2/../board/a20som_IM4/cross/etc --enable-static --target=arm-buildroot-linux-gnueabihf --with-sysroot=/home/user/Documents/myProject/buildroot-2017.05.2/buildroot-2017.05.2/../board/a20som_IM4/cross/usr/arm-buildroot-linux-gnueabihf/sysroot --disable-__cxa_atexit --with-gnu-ld --disable-libssp --disable-multilib --with-gmp=/home/user/Documents/myProject/buildroot-2017.05.2/buildroot-2017.05.2/../board/a20som_IM4/cross/usr --with-mpc=/home/user/Documents/myProject/buildroot-2017.05.2/buildroot-2017.05.2/../board/a20som_IM4/cross/usr --with-mpfr=/home/user/Documents/myProject/buildroot-2017.05.2/buildroot-2017.05.2/../board/a20som_IM4/cross/usr --with-pkgversion='Buildroot 2017.05.2-g3bca02e-dirty' --with-bugurl=http://bugs.buildroot.net/ --disable-libquadmath --enable-tls --disable-libmudflap --enable-threads --without-isl --without-cloog --disable-decimal-float --with-abi=aapcs-linux --with-cpu=cortex-a7 --with-fpu=vfpv4-d16 --with-float=hard --with-mode=arm --enable-languages=c --with-build-time-tools=/home/user/Documents/myProject/buildroot-2017.05.2/buildroot-2017.05.2/../board/a20som_IM4/cross/usr/arm-buildroot-linux-gnueabihf/bin --enable-shared --disable-libgomp
Modèle de thread: posix
gcc version 4.9.4 (Buildroot 2017.05.2-g3bca02e-dirty)
COMPILER_PATH=/home/user/Documents/myProject/buildroot-2017.05.2/board/a20som_IM4/cross/usr/bin/../libexec/gcc/arm-buildroot-linux-gnueabihf/4.9.4/:/home/user/Documents/myProject/buildroot-2017.05.2/board/a20som_IM4/cross/usr/bin/../libexec/gcc/:/home/user/Documents/myProject/buildroot-2017.05.2/board/a20som_IM4/cross/usr/bin/../lib/gcc/arm-buildroot-linux-gnueabihf/4.9.4/../../../../arm-buildroot-linux-gnueabihf/bin/
LIBRARY_PATH=/home/user/Documents/myProject/buildroot-2017.05.2/board/a20som_IM4/cross/usr/bin/../lib/gcc/arm-buildroot-linux-gnueabihf/4.9.4/:/home/user/Documents/myProject/buildroot-2017.05.2/board/a20som_IM4/cross/usr/bin/../lib/gcc/:/home/user/Documents/myProject/buildroot-2017.05.2/board/a20som_IM4/cross/usr/bin/../lib/gcc/arm-buildroot-linux-gnueabihf/4.9.4/../../../../arm-buildroot-linux-gnueabihf/lib/:/home/user/Documents/myProject/sysroot/lib/:/home/user/Documents/myProject/sysroot/usr/lib/
COLLECT_GCC_OPTIONS='-L/home/user/Documents/Dev/Xwidgets/a20som_IM4' '-v' '-o' 'myApp' '-mcpu=cortex-a7' '-mfloat-abi=hard' '-mfpu=vfpv4-d16' '-mabi=aapcs-linux' '-marm' '-mtls-dialect=gnu'
/home/user/Documents/myProject/buildroot-2017.05.2/board/a20som_IM4/cross/usr/bin/../libexec/gcc/arm-buildroot-linux-gnueabihf/4.9.4/collect2 -plugin /home/user/Documents/myProject/buildroot-2017.05.2/board/a20som_IM4/cross/usr/bin/../libexec/gcc/arm-buildroot-linux-gnueabihf/4.9.4/liblto_plugin.so -plugin-opt=/home/user/Documents/myProject/buildroot-2017.05.2/board/a20som_IM4/cross/usr/bin/../libexec/gcc/arm-buildroot-linux-gnueabihf/4.9.4/lto-wrapper -plugin-opt=-fresolution=/tmp/cc9MsoIV.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 --sysroot=/home/user/Documents/myProject/sysroot --eh-frame-hdr -dynamic-linker /lib/ld-linux-armhf.so.3 -X -m armelf_linux_eabi -o myApp /home/user/Documents/myProject/sysroot/usr/lib/crt1.o /home/user/Documents/myProject/sysroot/usr/lib/crti.o /home/user/Documents/myProject/buildroot-2017.05.2/board/a20som_IM4/cross/usr/bin/../lib/gcc/arm-buildroot-linux-gnueabihf/4.9.4/crtbegin.o -L/home/user/Documents/Dev/Xwidgets/a20som_IM4 -L/home/user/Documents/myProject/buildroot-2017.05.2/board/a20som_IM4/cross/usr/bin/../lib/gcc/arm-buildroot-linux-gnueabihf/4.9.4 -L/home/user/Documents/myProject/buildroot-2017.05.2/board/a20som_IM4/cross/usr/bin/../lib/gcc -L/home/user/Documents/myProject/buildroot-2017.05.2/board/a20som_IM4/cross/usr/bin/../lib/gcc/arm-buildroot-linux-gnueabihf/4.9.4/../../../../arm-buildroot-linux-gnueabihf/lib -L/home/user/Documents/myProject/sysroot/lib -L/home/user/Documents/myProject/sysroot/usr/lib ./src/IMV_asymmetry.o ./src/IMV_power.o ./src/IMV_precision.o ./src/IMV_random.o ./src/IMV_sensibility.o ./src/IMV_speed.o ./src/IMV_timer.o ./src/free_session_screen.o ./src/fs_big_toolbar.o ./src/fs_page_1.o ./src/fs_page_2.o ./src/fs_page_3.o ./src/fs_page_4.o ./src/fs_right_sidebar.o ./src/fs_small_toolbar.o ./src/main.o ./src/patient_screen.o ./src/programs_screen.o ./src/run_timeline.o ./src/running_screen.o ./src/welcome_screen.o -lXwidgets -lpthread -lm -ljpeg -lpng16 -lSDL2 -lSDL2_image -lSDL2_ttf -ljson-c -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /home/user/Documents/myProject/buildroot-2017.05.2/board/a20som_IM4/cross/usr/bin/../lib/gcc/arm-buildroot-linux-gnueabihf/4.9.4/crtend.o /home/user/Documents/myProject/sysroot/usr/lib/crtn.o
Finished building target: myApp
You need to map the source path in GDB. Have a look here for the documentation.
Finding Source file mapping
You can try running the following command in cross GDB to find the source file mapping:
info sources
# Find the source files used to build the executable.
Mapping the binary source file paths to absolute file paths
For example, if the file /foo/bar/baz.c was moved to /mnt/cross/baz.c, then the command:
set substitute-path /foo/bar /mnt/cross
Note: Referenced from GDB documentation available here.

How to mix C++ and Fortran using CMake -G Xcode?

I created a simple C++ file where I call a Fortran subroutine. Using CMake without the Xcode IDE everything compiles just fine, whereas trying to add the Xcode IDE with the command:
cmake .. -G Xcode
returns the following error:
Compilation of the Fortran compiler identification source "CMakeFortranCompilerId.F" did not produce an executable in ...
Somebody can give me a hint on how to debug this one?
The source files are given by:
CMakeLists.txt
cmake_minimum_required(VERSION 3.7.0)
project(mixing CXX Fortran)
add_executable(mixing
testC.cpp
testF.f
)
testC.cpp
#include <iostream>
using namespace std;
extern"C" {
void fortfunc_(int *ii, float *ff);
}
int main()
{
int ii=5;
float ff=5.5;
fortfunc_(&ii, &ff);
return 0;
}
testF.f
subroutine fortfunc(ii,ff)
integer ii
real*4 ff
write(6,100) ii, ff
100 format('ii=',i2,' ff=',f6.3)
return
end
CMakeFiles/CMakeError.log
Compilation of the Fortran compiler identification source "CMakeFortranCompilerId.F" did not produce an executable in "/Users/Knowledge/Developer/Tutorials/MixingFortranAndC/XCode_CMake_FortranMixing/build/CMakeFiles/3.7.0/CompilerIdFortran".
CMakeFiles/CMakeOutput.log
bins
cmake .. -G Xcode
cmake ..
difference between the two files
Compiling the Fortran compiler identification source file "CMakeFortranCompilerId.F" succeeded.
Compiler:
Build flags:
Id flags:
The output was:
0
=== BUILD TARGET CompilerIdFortran OF PROJECT CompilerIdFortran WITH THE DEFAULT CONFIGURATION (Debug) ===
Check dependencies
warning: no rule to process file '/Users/Knowledge/Developer/Tutorials/MixingFortranAndC/XCode_CMake_FortranMixing/build/CMakeFiles/3.7.0/CompilerIdFortran/CMakeFortranCompilerId.F' of type sourcecode.fortran.f90 for architecture x86_64
Write auxiliary files
write-file /Users/Knowledge/Developer/Tutorials/MixingFortranAndC/XCode_CMake_FortranMixing/build/CMakeFiles/3.7.0/CompilerIdFortran/CompilerIdFortran.build/Debug/CompilerIdFortran.build/Script-2C8FEB8E15DC1A1A00E56A5D.sh
chmod 0755 /Users/Knowledge/Developer/Tutorials/MixingFortranAndC/XCode_CMake_FortranMixing/build/CMakeFiles/3.7.0/CompilerIdFortran/CompilerIdFortran.build/Debug/CompilerIdFortran.build/Script-2C8FEB8E15DC1A1A00E56A5D.sh
PhaseScriptExecution Run\ Script CompilerIdFortran.build/Debug/CompilerIdFortran.build/Script-2C8FEB8E15DC1A1A00E56A5D.sh
cd /Users/Knowledge/Developer/Tutorials/MixingFortranAndC/XCode_CMake_FortranMixing/build/CMakeFiles/3.7.0/CompilerIdFortran
/bin/sh -c /Users/Knowledge/Developer/Tutorials/MixingFortranAndC/XCode_CMake_FortranMixing/build/CMakeFiles/3.7.0/CompilerIdFortran/CompilerIdFortran.build/Debug/CompilerIdFortran.build/Script-2C8FEB8E15DC1A1A00E56A5D.sh
GCC_VERSION=com.apple.compilers.llvm.clang.1_0
** BUILD SUCCEEDED **
Compiling the Fortran compiler identification source file "CMakeFortranCompilerId.F" succeeded.
Compiler:
Build flags:
Id flags:
The output was:
0
=== BUILD TARGET CompilerIdFortran OF PROJECT CompilerIdFortran WITH THE DEFAULT CONFIGURATION (Debug) ===
Check dependencies
warning: no rule to process file '/Users/Knowledge/Developer/Tutorials/MixingFortranAndC/XCode_CMake_FortranMixing/build/CMakeFiles/3.7.0/CompilerIdFortran/CMakeFortranCompilerId.F' of type sourcecode.fortran.f90 for architecture x86_64
Write auxiliary files
write-file /Users/Knowledge/Developer/Tutorials/MixingFortranAndC/XCode_CMake_FortranMixing/build/CMakeFiles/3.7.0/CompilerIdFortran/CompilerIdFortran.build/Debug/CompilerIdFortran.build/Script-2C8FEB8E15DC1A1A00E56A5D.sh
chmod 0755 /Users/Knowledge/Developer/Tutorials/MixingFortranAndC/XCode_CMake_FortranMixing/build/CMakeFiles/3.7.0/CompilerIdFortran/CompilerIdFortran.build/Debug/CompilerIdFortran.build/Script-2C8FEB8E15DC1A1A00E56A5D.sh
PhaseScriptExecution Run\ Script CompilerIdFortran.build/Debug/CompilerIdFortran.build/Script-2C8FEB8E15DC1A1A00E56A5D.sh
cd /Users/Knowledge/Developer/Tutorials/MixingFortranAndC/XCode_CMake_FortranMixing/build/CMakeFiles/3.7.0/CompilerIdFortran
/bin/sh -c /Users/Knowledge/Developer/Tutorials/MixingFortranAndC/XCode_CMake_FortranMixing/build/CMakeFiles/3.7.0/CompilerIdFortran/CompilerIdFortran.build/Debug/CompilerIdFortran.build/Script-2C8FEB8E15DC1A1A00E56A5D.sh
GCC_VERSION=com.apple.compilers.llvm.clang.1_0
** BUILD SUCCEEDED **
Compiling the Fortran compiler identification source file "CMakeFortranCompilerId.F" succeeded.
Compiler: /opt/local/bin/gfortran
Build flags:
Id flags: -v
The output was:
0
Driving: /opt/local/bin/gfortran -v CMakeFortranCompilerId.F -mmacosx-version-min=10.12.1 -l gfortran -shared-libgcc
Using built-in specs.
COLLECT_GCC=/opt/local/bin/gfortran
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin16/6.2.0/lto-wrapper
Target: x86_64-apple-darwin16
Configured with: /opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_gcc6/gcc6/work/gcc-6.2.0/configure --prefix=/opt/local --build=x86_64-apple-darwin16 --enable-languages=c,c++,objc,obj-c++,lto,fortran --libdir=/opt/local/lib/gcc6 --includedir=/opt/local/include/gcc6 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-6 --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-6 --with-gxx-include-dir=/opt/local/include/gcc6/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local --with-isl=/opt/local --enable-stage1-checking --disable-multilib --enable-lto --enable-libstdcxx-time --with-build-config=bootstrap-debug --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar --with-bugurl=https://trac.macports.org/newticket --with-pkgversion='MacPorts gcc6 6.2.0_2'
Thread model: posix
gcc version 6.2.0 (MacPorts gcc6 6.2.0_2)
COLLECT_GCC_OPTIONS='-v' '-mmacosx-version-min=10.12.1' '-shared-libgcc' '-mtune=core2'
/opt/local/libexec/gcc/x86_64-apple-darwin16/6.2.0/f951 CMakeFortranCompilerId.F -ffixed-form -cpp=/var/folders/gn/07hkp3pd0r53c8sqglm6_3g40000gn/T//ccYnQZ27.f90 -quiet -v -D__DYNAMIC__ CMakeFortranCompilerId.F -fPIC -quiet -dumpbase CMakeFortranCompilerId.F -mmacosx-version-min=10.12.1 -mtune=core2 -auxbase CMakeFortranCompilerId -version -fintrinsic-modules-path /opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0/finclude -o /var/folders/gn/07hkp3pd0r53c8sqglm6_3g40000gn/T//ccfUnwPI.s
GNU Fortran (MacPorts gcc6 6.2.0_2) version 6.2.0 (x86_64-apple-darwin16)
compiled by GNU C version 6.2.0, GMP version 6.1.1, MPFR version 3.1.4, MPC version 1.0.3, isl version 0.14 or 0.13
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0/../../../../../x86_64-apple-darwin16/include"
#include "..." search starts here:
#include <...> search starts here:
/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0/finclude
/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0/include
/opt/local/include
/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0/include-fixed
/usr/include
End of search list.
GNU Fortran2008 (MacPorts gcc6 6.2.0_2) version 6.2.0 (x86_64-apple-darwin16)
compiled by GNU C version 6.2.0, GMP version 6.1.1, MPFR version 3.1.4, MPC version 1.0.3, isl version 0.14 or 0.13
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
COLLECT_GCC_OPTIONS='-v' '-mmacosx-version-min=10.12.1' '-shared-libgcc' '-mtune=core2'
/opt/local/bin/as -v -arch x86_64 -force_cpusubtype_ALL -o /var/folders/gn/07hkp3pd0r53c8sqglm6_3g40000gn/T//ccExsLaB.o /var/folders/gn/07hkp3pd0r53c8sqglm6_3g40000gn/T//ccfUnwPI.s
Apple Inc version cctools-886, GNU assembler version 1.38
Reading specs from /opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0/../../../libgfortran.spec
rename spec lib to liborig
COLLECT_GCC_OPTIONS='-v' '-mmacosx-version-min=10.12.1' '-shared-libgcc' '-mtune=core2'
COMPILER_PATH=/opt/local/libexec/gcc/x86_64-apple-darwin16/6.2.0/:/opt/local/libexec/gcc/x86_64-apple-darwin16/6.2.0/:/opt/local/libexec/gcc/x86_64-apple-darwin16/:/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0/:/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/
LIBRARY_PATH=/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0/:/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0/../../../
COLLECT_GCC_OPTIONS='-v' '-mmacosx-version-min=10.12.1' '-shared-libgcc' '-mtune=core2'
/opt/local/libexec/gcc/x86_64-apple-darwin16/6.2.0/collect2 -dynamic -arch x86_64 -macosx_version_min 10.12.1 -weak_reference_mismatches non-weak -o a.out -L/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0 -L/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0/../../.. /var/folders/gn/07hkp3pd0r53c8sqglm6_3g40000gn/T//ccExsLaB.o -lgfortran -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lquadmath -lm -lgcc_ext.10.5 -lgcc -lSystem -v
collect2 version 6.2.0
/opt/local/bin/ld -dynamic -arch x86_64 -macosx_version_min 10.12.1 -weak_reference_mismatches non-weak -o a.out -L/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0 -L/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0/../../.. /var/folders/gn/07hkp3pd0r53c8sqglm6_3g40000gn/T//ccExsLaB.o -lgfortran -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lquadmath -lm -lgcc_ext.10.5 -lgcc -lSystem -v
#(#)PROGRAM:ld PROJECT:ld64-264.3.102
configured to support archs: i386 x86_64 x86_64h armv6 armv7 armv7s armv7m armv7k arm64 (tvOS)
Library search paths:
/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0
/opt/local/lib/gcc6
/usr/lib
/usr/local/lib
Framework search paths:
/Library/Frameworks/
/System/Library/Frameworks/
/opt/local/bin/nm -n /var/folders/gn/07hkp3pd0r53c8sqglm6_3g40000gn/T//ccExsLaB.o
Compilation of the Fortran compiler identification source "CMakeFortranCompilerId.F" produced "a.out"
The Fortran compiler identification is GNU, found in "/Users/Knowledge/Developer/Tutorials/MixingFortranAndC/XCode_CMake_FortranMixing/build/CMakeFiles/3.7.0/CompilerIdFortran/a.out"
Determining if the Fortran compiler works passed with the following output:
Change Dir: /Users/Knowledge/Developer/Tutorials/MixingFortranAndC/XCode_CMake_FortranMixing/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_ec5cc/fast"
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_ec5cc.dir/build.make CMakeFiles/cmTC_ec5cc.dir/build
Building Fortran object CMakeFiles/cmTC_ec5cc.dir/testFortranCompiler.f.o
/opt/local/bin/gfortran -c /Users/Knowledge/Developer/Tutorials/MixingFortranAndC/XCode_CMake_FortranMixing/build/CMakeFiles/CMakeTmp/testFortranCompiler.f -o CMakeFiles/cmTC_ec5cc.dir/testFortranCompiler.f.o
Linking Fortran executable cmTC_ec5cc
/opt/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_ec5cc.dir/link.txt --verbose=1
/opt/local/bin/gfortran CMakeFiles/cmTC_ec5cc.dir/testFortranCompiler.f.o -o cmTC_ec5cc
Detecting Fortran compiler ABI info compiled with the following output:
Change Dir: /Users/Knowledge/Developer/Tutorials/MixingFortranAndC/XCode_CMake_FortranMixing/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_61cbd/fast"
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_61cbd.dir/build.make CMakeFiles/cmTC_61cbd.dir/build
Building Fortran object CMakeFiles/cmTC_61cbd.dir/CMakeFortranCompilerABI.F.o
/opt/local/bin/gfortran -c /opt/local/share/cmake-3.7/Modules/CMakeFortranCompilerABI.F -o CMakeFiles/cmTC_61cbd.dir/CMakeFortranCompilerABI.F.o
Linking Fortran executable cmTC_61cbd
/opt/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_61cbd.dir/link.txt --verbose=1
/opt/local/bin/gfortran -v -Wl,-v CMakeFiles/cmTC_61cbd.dir/CMakeFortranCompilerABI.F.o -o cmTC_61cbd
Driving: /opt/local/bin/gfortran -v -Wl,-v CMakeFiles/cmTC_61cbd.dir/CMakeFortranCompilerABI.F.o -o cmTC_61cbd -mmacosx-version-min=10.12.1 -l gfortran -shared-libgcc
Using built-in specs.
COLLECT_GCC=/opt/local/bin/gfortran
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin16/6.2.0/lto-wrapper
Target: x86_64-apple-darwin16
Configured with: /opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_gcc6/gcc6/work/gcc-6.2.0/configure --prefix=/opt/local --build=x86_64-apple-darwin16 --enable-languages=c,c++,objc,obj-c++,lto,fortran --libdir=/opt/local/lib/gcc6 --includedir=/opt/local/include/gcc6 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-6 --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-6 --with-gxx-include-dir=/opt/local/include/gcc6/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local --with-isl=/opt/local --enable-stage1-checking --disable-multilib --enable-lto --enable-libstdcxx-time --with-build-config=bootstrap-debug --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar --with-bugurl=https://trac.macports.org/newticket --with-pkgversion='MacPorts gcc6 6.2.0_2'
Thread model: posix
gcc version 6.2.0 (MacPorts gcc6 6.2.0_2)
Reading specs from /opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0/../../../libgfortran.spec
rename spec lib to liborig
COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_61cbd' '-mmacosx-version-min=10.12.1' '-shared-libgcc' '-mtune=core2'
COMPILER_PATH=/opt/local/libexec/gcc/x86_64-apple-darwin16/6.2.0/:/opt/local/libexec/gcc/x86_64-apple-darwin16/6.2.0/:/opt/local/libexec/gcc/x86_64-apple-darwin16/:/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0/:/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/
LIBRARY_PATH=/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0/:/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0/../../../
COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_61cbd' '-mmacosx-version-min=10.12.1' '-shared-libgcc' '-mtune=core2'
/opt/local/libexec/gcc/x86_64-apple-darwin16/6.2.0/collect2 -dynamic -arch x86_64 -macosx_version_min 10.12.1 -weak_reference_mismatches non-weak -o cmTC_61cbd -L/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0 -L/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0/../../.. -v CMakeFiles/cmTC_61cbd.dir/CMakeFortranCompilerABI.F.o -lgfortran -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lquadmath -lm -lgcc_ext.10.5 -lgcc -lSystem -v
collect2 version 6.2.0
/opt/local/bin/ld -dynamic -arch x86_64 -macosx_version_min 10.12.1 -weak_reference_mismatches non-weak -o cmTC_61cbd -L/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0 -L/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0/../../.. -v CMakeFiles/cmTC_61cbd.dir/CMakeFortranCompilerABI.F.o -lgfortran -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lquadmath -lm -lgcc_ext.10.5 -lgcc -lSystem -v
#(#)PROGRAM:ld PROJECT:ld64-264.3.102
configured to support archs: i386 x86_64 x86_64h armv6 armv7 armv7s armv7m armv7k arm64 (tvOS)
#(#)PROGRAM:ld PROJECT:ld64-264.3.102
configured to support archs: i386 x86_64 x86_64h armv6 armv7 armv7s armv7m armv7k arm64 (tvOS)
Library search paths:
/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0
/opt/local/lib/gcc6
/usr/lib
/usr/local/lib
Framework search paths:
/Library/Frameworks/
/System/Library/Frameworks/
/opt/local/bin/nm -n CMakeFiles/cmTC_61cbd.dir/CMakeFortranCompilerABI.F.o
Parsed Fortran implicit link information from above output:
link line regex: [^( *|.*[/\])(ld|([^/\]+-)?ld|collect2)[^/\]*( |$)]
ignore line: [Change Dir: /Users/Knowledge/Developer/Tutorials/MixingFortranAndC/XCode_CMake_FortranMixing/build/CMakeFiles/CMakeTmp]
ignore line: []
ignore line: [Run Build Command:"/usr/bin/make" "cmTC_61cbd/fast"]
ignore line: [/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_61cbd.dir/build.make CMakeFiles/cmTC_61cbd.dir/build]
ignore line: [Building Fortran object CMakeFiles/cmTC_61cbd.dir/CMakeFortranCompilerABI.F.o]
ignore line: [/opt/local/bin/gfortran -c /opt/local/share/cmake-3.7/Modules/CMakeFortranCompilerABI.F -o CMakeFiles/cmTC_61cbd.dir/CMakeFortranCompilerABI.F.o]
ignore line: [Linking Fortran executable cmTC_61cbd]
ignore line: [/opt/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_61cbd.dir/link.txt --verbose=1]
ignore line: [/opt/local/bin/gfortran -v -Wl,-v CMakeFiles/cmTC_61cbd.dir/CMakeFortranCompilerABI.F.o -o cmTC_61cbd ]
ignore line: [Driving: /opt/local/bin/gfortran -v -Wl,-v CMakeFiles/cmTC_61cbd.dir/CMakeFortranCompilerABI.F.o -o cmTC_61cbd -mmacosx-version-min=10.12.1 -l gfortran -shared-libgcc]
ignore line: [Using built-in specs.]
ignore line: [COLLECT_GCC=/opt/local/bin/gfortran]
ignore line: [COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin16/6.2.0/lto-wrapper]
ignore line: [Target: x86_64-apple-darwin16]
ignore line: [Configured with: /opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_gcc6/gcc6/work/gcc-6.2.0/configure --prefix=/opt/local --build=x86_64-apple-darwin16 --enable-languages=c,c++,objc,obj-c++,lto,fortran --libdir=/opt/local/lib/gcc6 --includedir=/opt/local/include/gcc6 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-6 --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-6 --with-gxx-include-dir=/opt/local/include/gcc6/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local --with-isl=/opt/local --enable-stage1-checking --disable-multilib --enable-lto --enable-libstdcxx-time --with-build-config=bootstrap-debug --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar --with-bugurl=https://trac.macports.org/newticket --with-pkgversion='MacPorts gcc6 6.2.0_2']
ignore line: [Thread model: posix]
ignore line: [gcc version 6.2.0 (MacPorts gcc6 6.2.0_2) ]
ignore line: [Reading specs from /opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0/../../../libgfortran.spec]
ignore line: [rename spec lib to liborig]
ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_61cbd' '-mmacosx-version-min=10.12.1' '-shared-libgcc' '-mtune=core2']
ignore line: [COMPILER_PATH=/opt/local/libexec/gcc/x86_64-apple-darwin16/6.2.0/:/opt/local/libexec/gcc/x86_64-apple-darwin16/6.2.0/:/opt/local/libexec/gcc/x86_64-apple-darwin16/:/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0/:/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/]
ignore line: [LIBRARY_PATH=/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0/:/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0/../../../]
ignore line: [COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_61cbd' '-mmacosx-version-min=10.12.1' '-shared-libgcc' '-mtune=core2']
link line: [ /opt/local/libexec/gcc/x86_64-apple-darwin16/6.2.0/collect2 -dynamic -arch x86_64 -macosx_version_min 10.12.1 -weak_reference_mismatches non-weak -o cmTC_61cbd -L/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0 -L/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0/../../.. -v CMakeFiles/cmTC_61cbd.dir/CMakeFortranCompilerABI.F.o -lgfortran -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lquadmath -lm -lgcc_ext.10.5 -lgcc -lSystem -v]
arg [/opt/local/libexec/gcc/x86_64-apple-darwin16/6.2.0/collect2] ==> ignore
arg [-dynamic] ==> ignore
arg [-arch] ==> ignore
arg [x86_64] ==> ignore
arg [-macosx_version_min] ==> ignore
arg [10.12.1] ==> ignore
arg [-weak_reference_mismatches] ==> ignore
arg [non-weak] ==> ignore
arg [-o] ==> ignore
arg [cmTC_61cbd] ==> ignore
arg [-L/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0] ==> dir [/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0]
arg [-L/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0/../../..] ==> dir [/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0/../../..]
arg [-v] ==> ignore
arg [CMakeFiles/cmTC_61cbd.dir/CMakeFortranCompilerABI.F.o] ==> ignore
arg [-lgfortran] ==> lib [gfortran]
arg [-no_compact_unwind] ==> ignore
arg [-lSystem] ==> lib [System]
arg [-lgcc_ext.10.5] ==> lib [gcc_ext.10.5]
arg [-lgcc] ==> lib [gcc]
arg [-lquadmath] ==> lib [quadmath]
arg [-lm] ==> lib [m]
arg [-lgcc_ext.10.5] ==> lib [gcc_ext.10.5]
arg [-lgcc] ==> lib [gcc]
arg [-lSystem] ==> lib [System]
arg [-v] ==> ignore
Library search paths: [;/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0;/opt/local/lib/gcc6;/usr/lib;/usr/local/lib]
Framework search paths: [;/Library/Frameworks/;/System/Library/Frameworks/]
remove lib [System]
remove lib [gcc_ext.10.5]
remove lib [gcc]
remove lib [gcc_ext.10.5]
remove lib [gcc]
remove lib [System]
collapse library dir [/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0] ==> [/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0]
collapse library dir [/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0/../../..] ==> [/opt/local/lib/gcc6]
collapse library dir [/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0] ==> [/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0]
collapse library dir [/opt/local/lib/gcc6] ==> [/opt/local/lib/gcc6]
collapse library dir [/usr/lib] ==> [/usr/lib]
collapse library dir [/usr/local/lib] ==> [/usr/local/lib]
collapse framework dir [/Library/Frameworks/] ==> [/Library/Frameworks]
collapse framework dir [/System/Library/Frameworks/] ==> [/System/Library/Frameworks]
implicit libs: [gfortran;quadmath;m]
implicit dirs: [/opt/local/lib/gcc6/gcc/x86_64-apple-darwin16/6.2.0;/opt/local/lib/gcc6;/usr/lib;/usr/local/lib]
implicit fwks: [/Library/Frameworks;/System/Library/Frameworks]
Determining if the Fortran compiler supports Fortran 90 passed with the following output:
Change Dir: /Users/Knowledge/Developer/Tutorials/MixingFortranAndC/XCode_CMake_FortranMixing/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_e62a9/fast"
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_e62a9.dir/build.make CMakeFiles/cmTC_e62a9.dir/build
Building Fortran object CMakeFiles/cmTC_e62a9.dir/testFortranCompilerF90.f90.o
/opt/local/bin/gfortran -c /Users/Knowledge/Developer/Tutorials/MixingFortranAndC/XCode_CMake_FortranMixing/build/CMakeFiles/CMakeTmp/testFortranCompilerF90.f90 -o CMakeFiles/cmTC_e62a9.dir/testFortranCompilerF90.f90.o
Linking Fortran executable cmTC_e62a9
/opt/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_e62a9.dir/link.txt --verbose=1
/opt/local/bin/gfortran CMakeFiles/cmTC_e62a9.dir/testFortranCompilerF90.f90.o -o cmTC_e62a9
CMAKE stdout
-- The CXX compiler identification is AppleClang 8.0.0.8000042
-- The Fortran compiler identification is unknown
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:2 (project):
No CMAKE_Fortran_COMPILER could be found.

Can't link BOTAN library with eclipse

I have installed and built the BOTAN cryptographic library.
Everything seems correctly installed, since I have the following entries in /usr/local/lib directory:
-rw-r--r-- 1 root root 7676350 2012-06-03 11:01 libbotan-1.10.a
lrwxrwxrwx 1 root root 20 2012-06-03 11:01 libbotan-1.10.so -> libbotan-1.10.so.0.1
lrwxrwxrwx 1 root root 20 2012-06-03 11:01 libbotan-1.10.so.0 -> libbotan-1.10.so.0.1
-rwxr-xr-x 1 root root 3396354 2012-06-03 11:01 libbotan-1.10.so.0.1
and in the /usr/local/include one too:
drwxr-xr-x 3 root root 4096 2012-06-03 11:01 botan-1.10
And eventually I managed to include the libraries in the main of my program, and write code without error.
However when building my project (on Eclipse Indigo) I get the following output on console, with the red stderr fashion:
error while loading shared libraries: libbotan-1.10.so.0: cannot open shared object file: No such file or directory
The code I'm trying to execute is the following:
try
{
cout << "In try" << endl;
Botan::LibraryInitializer init;
}catch(std::exception& e)
{
cout << "In catch" << endl;
cerr << e.what() << endl;
}
I have the following doubts:
Is it a problem of the Linker? (And if yes, why isn't the linker throwing the error, but the stderr?)
If not, how can I figure out to let my program find the libbotan-1.10.so.0 file which is actually there? (in /usr/local/lib).
Note that my environment variable $LD_LIBRARY_PATH is currently set, and has the following value:
$> echo $LD_LIBRARY_PATH
$> /usr/local/lib/
Compiler Command Line:
Invoking: GCC C++ Compiler
g++ -I/usr/include/c++/4.5.2 -I/usr/local/include/botan-1.10 -O3 -g3 -Wall -c -fmessage-length=0 -std=c++0x -v -MMD -MP -MF"mainOobClient.d" -MT"mainOobClient.d" -o "mainOobClient.o" "../mainOobClient.cpp"
g++ -I/usr/include/c++/4.5.2 -I/usr/local/include/botan-1.10 -O3 -g3 -Wall -c -fmessage-length=0 -std=c++0x -v -MMD -MP -MF"oobClientClass.d" -MT"oobClientClass.d" -o "oobClientClass.o" "../oobClientClass.cpp"
Invoking: GCC C++ Linker
g++ -L/usr/local/lib -o "MTVS_oobClient" ./mainOobClient.o ./oobClientClass.o -lbotan-1.10
Complete Build Output:
Build of configuration Debug for project MTVS_oobClient
make all
Building file: ../mainOobClient.cpp
Invoking: GCC C++ Compiler
g++ -I/usr/include/c++/4.5.2 -I/usr/local/include/botan-1.10 -O3 -g3 -Wall -c -fmessage-length=0 -std=c++0x -v -MMD -MP -MF"mainOobClient.d" -MT"mainOobClient.d" -o "mainOobClient.o" "../mainOobClient.cpp"
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/lto-wrapper
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.5.2-8ubuntu4' --with-bugurl=file:///usr/share/doc/gcc-4.5/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.5 --enable-shared --enable-multiarch --with-multiarch-defaults=i386-linux-gnu --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib/i386-linux-gnu --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.5 --libdir=/usr/lib/i386-linux-gnu --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-gold --enable-ld=default --with-plugin-ld=ld.gold --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4)
Finished building: ../mainOobClient.cpp
Building file: ../oobClientClass.cpp
Invoking: GCC C++ Compiler
g++ -I/usr/include/c++/4.5.2 -I/usr/local/include/botan-1.10 -O3 -g3 -Wall -c -fmessage-length=0 -std=c++0x -v -MMD -MP -MF"oobClientClass.d" -MT"oobClientClass.d" -o "oobClientClass.o" "../oobClientClass.cpp"
COLLECT_GCC_OPTIONS='-I/usr/include/c++/4.5.2' '-I/usr/local/include/botan-1.10' '-O3' '-g3' '-Wall' '-c' '-fmessage-length=0' '-std=c++0x' '-v' '-MMD' '-MP' '-MFmainOobClient.d' '-MTmainOobClient.d' '-o' 'mainOobClient.o' '-shared-libgcc' '-mtune=generic' '-march=i686'
/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/cc1plus -quiet -v -I/usr/include/c++/4.5.2 -I/usr/local/include/botan-1.10 -MMD mainOobClient.d -MFmainOobClient.d -MP -MTmainOobClient.d -MQ mainOobClient.o -dD -D_GNU_SOURCE ../mainOobClient.cpp -D_FORTIFY_SOURCE=2 -quiet -dumpbase mainOobClient.cpp -mtune=generic -march=i686 -auxbase-strip mainOobClient.o -g3 -O3 -Wall -std=c++0x -version -fmessage-length=0 -fstack-protector -o /tmp/ccLIYQkV.s
Finished building: ../oobClientClass.cpp
GNU C++ (Ubuntu/Linaro 4.5.2-8ubuntu4) version 4.5.2 (i686-linux-gnu)
Building target: MTVS_oobClient
Invoking: GCC C++ Linker
g++ ./mainOobClient.o ./oobClientClass.o -lbotan-1.10 -L/usr/local/lib -o "MTVS_oobClient"
compiled by GNU C version 4.5.2, GMP version 4.3.2, MPFR version 3.0.0-p8, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include/i386-linux-gnu"
ignoring nonexistent directory "/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/../../../../../i686-linux-gnu/include"
ignoring duplicate directory "/usr/include/c++/4.5.2"
as it is a non-system directory that duplicates a system directory
Finished building target: MTVS_oobClient
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include/botan-1.10
/usr/include/c++/4.5
/usr/include/c++/4.5/i686-linux-gnu
/usr/include/c++/4.5/backward
/usr/local/include
/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/include
/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/include-fixed
/usr/include/i386-linux-gnu
/usr/include
End of search list.
GNU C++ (Ubuntu/Linaro 4.5.2-8ubuntu4) version 4.5.2 (i686-linux-gnu)
compiled by GNU C version 4.5.2, GMP version 4.3.2, MPFR version 3.0.0-p8, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 0c5cb630517b5952f4898dfa56d7e8e5
COLLECT_GCC_OPTIONS='-I/usr/include/c++/4.5.2' '-I/usr/local/include/botan-1.10' '-O3' '-g3' '-Wall' '-c' '-fmessage-length=0' '-std=c++0x' '-v' '-MMD' '-MP' '-MFmainOobClient.d' '-MTmainOobClient.d' '-o' 'mainOobClient.o' '-shared-libgcc' '-mtune=generic' '-march=i686'
as -V -Qy --32 -o mainOobClient.o /tmp/ccLIYQkV.s
GNU assembler version 2.21.0 (i686-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.21.0.20110327
COMPILER_PATH=/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/:/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/:/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/:/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/:/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/
LIBRARY_PATH=/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/:/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/../../../:/lib/:/usr/lib/:/usr/lib/i386-linux-gnu/
COLLECT_GCC_OPTIONS='-I/usr/include/c++/4.5.2' '-I/usr/local/include/botan-1.10' '-O3' '-g3' '-Wall' '-c' '-fmessage-length=0' '-std=c++0x' '-v' '-MMD' '-MP' '-MFmainOobClient.d' '-MTmainOobClient.d' '-o' 'mainOobClient.o' '-shared-libgcc' '-mtune=generic' '-march=i686'
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/lto-wrapper
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.5.2-8ubuntu4' --with-bugurl=file:///usr/share/doc/gcc-4.5/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.5 --enable-shared --enable-multiarch --with-multiarch-defaults=i386-linux-gnu --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib/i386-linux-gnu --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.5 --libdir=/usr/lib/i386-linux-gnu --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-gold --enable-ld=default --with-plugin-ld=ld.gold --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4)
COLLECT_GCC_OPTIONS='-I/usr/include/c++/4.5.2' '-I/usr/local/include/botan-1.10' '-O3' '-g3' '-Wall' '-c' '-fmessage-length=0' '-std=c++0x' '-v' '-MMD' '-MP' '-MFoobClientClass.d' '-MToobClientClass.d' '-o' 'oobClientClass.o' '-shared-libgcc' '-mtune=generic' '-march=i686'
/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/cc1plus -quiet -v -I/usr/include/c++/4.5.2 -I/usr/local/include/botan-1.10 -MMD oobClientClass.d -MFoobClientClass.d -MP -MToobClientClass.d -MQ oobClientClass.o -dD -D_GNU_SOURCE ../oobClientClass.cpp -D_FORTIFY_SOURCE=2 -quiet -dumpbase oobClientClass.cpp -mtune=generic -march=i686 -auxbase-strip oobClientClass.o -g3 -O3 -Wall -std=c++0x -version -fmessage-length=0 -fstack-protector -o /tmp/ccTuqeWw.s
GNU C++ (Ubuntu/Linaro 4.5.2-8ubuntu4) version 4.5.2 (i686-linux-gnu)
compiled by GNU C version 4.5.2, GMP version 4.3.2, MPFR version 3.0.0-p8, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include/i386-linux-gnu"
ignoring nonexistent directory "/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/../../../../../i686-linux-gnu/include"
ignoring duplicate directory "/usr/include/c++/4.5.2"
as it is a non-system directory that duplicates a system directory
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include/botan-1.10
/usr/include/c++/4.5
/usr/include/c++/4.5/i686-linux-gnu
/usr/include/c++/4.5/backward
/usr/local/include
/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/include
/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/include-fixed
/usr/include/i386-linux-gnu
/usr/include
End of search list.
GNU C++ (Ubuntu/Linaro 4.5.2-8ubuntu4) version 4.5.2 (i686-linux-gnu)
compiled by GNU C version 4.5.2, GMP version 4.3.2, MPFR version 3.0.0-p8, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 0c5cb630517b5952f4898dfa56d7e8e5
../oobClientClass.cpp: In member function ‘void oobClientClass::authenticateTransaction()’:
../oobClientClass.cpp:126:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
../oobClientClass.cpp:164:63: warning: ignoring return value of ‘ssize_t write(int, const void*, size_t)’, declared with attribute warn_unused_result
../oobClientClass.cpp:59:6: warning: ‘confirmationChoice’ may be used uninitialized in this function
COLLECT_GCC_OPTIONS='-I/usr/include/c++/4.5.2' '-I/usr/local/include/botan-1.10' '-O3' '-g3' '-Wall' '-c' '-fmessage-length=0' '-std=c++0x' '-v' '-MMD' '-MP' '-MFoobClientClass.d' '-MToobClientClass.d' '-o' 'oobClientClass.o' '-shared-libgcc' '-mtune=generic' '-march=i686'
as -V -Qy --32 -o oobClientClass.o /tmp/ccTuqeWw.s
GNU assembler version 2.21.0 (i686-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.21.0.20110327
COMPILER_PATH=/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/:/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/:/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/:/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/:/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/
LIBRARY_PATH=/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/:/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/../../../:/lib/:/usr/lib/:/usr/lib/i386-linux-gnu/
COLLECT_GCC_OPTIONS='-I/usr/include/c++/4.5.2' '-I/usr/local/include/botan-1.10' '-O3' '-g3' '-Wall' '-c' '-fmessage-length=0' '-std=c++0x' '-v' '-MMD' '-MP' '-MFoobClientClass.d' '-MToobClientClass.d' '-o' 'oobClientClass.o' '-shared-libgcc' '-mtune=generic' '-march=i686'
**** Build Finished ****
The error is coming at run-time. You need to specify the rpath for the binary at build time - Where you have the:
-L/usr/local/lib
You also need:
-Wl,-rpath=/usr/local/lib
This instructs ld to use this path when trying to find the library at run-time. Your LD_LIBRARY_PATH is probably being overridden by the launcher of eclipse, which is why the variable is not being used.
Alternatives:
Make sure that /usr/local/lib is in the /etc/ld.so.conf, and that ldconfig has been run after installing the library.
Link to the .a, using the command line:
g++ -o "MTVS_oobClient" ./mainOobClient.o ./oobClientClass.o -L/usr/local/lib -Wl,-Bstatic -lbotan-1.10 -Wl,-Bdynamic
or using:
g++ -o "MTVS_oobClient" ./mainOobClient.o ./oobClientClass.o /usr/local/lib/libbotan-1.10.a
... both should have the same effect
Since the program build ends correctly, it is clear that it's a run-time problem due to the fact that the program can't find the Shared Library.
I looked for other people with same run-time issue and found out the solution (that I'll briefly sum up) thanks to another SO question.
What I did was to build the dynamically-linked executable, that wishes to be linked against libbotan-1.10.so.0 at execution time. The linking during the build phase was done with command line option -L/usr/local/lib.
There are a few options to make botan (or any other library) available at run-time:
Create a symlink to botan in a directory listed in /etc/ld.so.conf (or /lib or /usr/lib)
Copy botan to a directory listed in /etc/ld.so.conf (or /lib or /usr/lib) (defaults)
Add the directory containing botan to /etc/ld.so.conf
Set LD_LIBRARY_PATH=/usr/local/lib before running your executable.
Recompile the program statically. (It will work, but don't bother.)
After any of the first 3, rerun ldconfig so the linker cache is updated. (You can then run ldconfig -v to verify it's resolvable.)
Note those aren't steps, they're options. You only need to do 1 of them.
Updating the linker cache with ldconfig made it work for me.