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.
Related
I am having a problem compiling C/C++ code on an alpine (and ubuntu) container with MUSL toolchain (http://musl.cc/x86_64-linux-musl-cross.tgz )
The error is seen when the container is run on a CentOS workstation (and also Ubuntu)
[user#centoshost ~]# uname -a
Linux centoshost 3.10.0-957.12.1.el7.x86_64 #1 SMP Mon Apr 29 14:59:59 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
[user#centoshost ~]# lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.6.1810 (Core)
Release: 7.6.1810
Codename: Core
[user#centoshost ~]#
The same container image when run on an Ubuntu 18.04/CentOS 7 VM (Oracle VirtualBox) is able to compile. The docker version is same (18.09.5) on VM and the workstation.
The error:
bash-5.1# /x86_64-linux-musl-cross/bin/x86_64-linux-musl-g++ -v test.cpp
Using built-in specs.
COLLECT_GCC=/x86_64-linux-musl-cross/bin/x86_64-linux-musl-g++
Target: x86_64-linux-musl
Configured with: ../src_gcc/configure --enable-languages=c,c++,fortran CC='gcc -static --static' CXX='g++ -static --static' FC='gfortran -static --static' CFLAGS='-g0 -O2 -fno-align-functions -fno-align-jumps -fno-align-loops -fno-align-labels' CXXFLAGS='-g0 -O2 -fno-align-functions -fno-align-jumps -fno-align-loops -fno-align-labels' FFLAGS='-g0 -O2 -fno-align-functions -fno-align-jumps -fno-align-loops -fno-align-labels' LDFLAGS='-s -static --static' --enable-default-pie --enable-static-pie --disable-bootstrap --disable-assembly --disable-werror --target=x86_64-linux-musl --prefix= --libdir=/lib --disable-multilib --with-sysroot=/x86_64-linux-musl --enable-tls --disable-libmudflap --disable-libsanitizer --disable-gnu-indirect-function --disable-libmpx --enable-libstdcxx-time=rt --enable-deterministic-archives --enable-libstdcxx-time --enable-libquadmath --enable-libquadmath-support --disable-decimal-float --with-build-sysroot=/tmp/m1032/build/local/x86_64-linux-musl/obj_sysroot AR_FOR_TARGET=/tmp/m1032/build/local/x86_64-linux-musl/obj_binutils/binutils/ar AS_FOR_TARGET=/tmp/m1032/build/local/x86_64-linux-musl/obj_binutils/gas/as-new LD_FOR_TARGET=/tmp/m1032/build/local/x86_64-linux-musl/obj_binutils/ld/ld-new NM_FOR_TARGET=/tmp/m1032/build/local/x86_64-linux-musl/obj_binutils/binutils/nm-new OBJCOPY_FOR_TARGET=/tmp/m1032/build/local/x86_64-linux-musl/obj_binutils/binutils/objcopy OBJDUMP_FOR_TARGET=/tmp/m1032/build/local/x86_64-linux-musl/obj_binutils/binutils/objdump RANLIB_FOR_TARGET=/tmp/m1032/build/local/x86_64-linux-musl/obj_binutils/binutils/ranlib READELF_FOR_TARGET=/tmp/m1032/build/local/x86_64-linux-musl/obj_binutils/binutils/readelf STRIP_FOR_TARGET=/tmp/m1032/build/local/x86_64-linux-musl/obj_binutils/binutils/strip-new --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu 'CC_FOR_BUILD=cc -static --static' 'CXX_FOR_BUILD=g++ -static --static'
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.2.1 20210116 (GCC)
COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
cc1plus -quiet -v -iprefix /x86_64-linux-musl-cross/bin/../lib/gcc/x86_64-linux-musl/10.2.1/ -isysroot /x86_64-linux-musl-cross/bin/../x86_64-linux-musl -D_GNU_SOURCE test.cpp -quiet -dumpbase test.cpp -mtune=generic -march=x86-64 -auxbase test -version -o /tmp/ccDckJiL.s
x86_64-linux-musl-g++: fatal error: cannot execute ‘cc1plus’: execvp: No such file or directory
compilation terminated.
I also tried adding the path to cc1plus to PATH env variable. For this i got a different error:
bash-5.1# PATH=$PATH:/x86_64-linux-musl-cross/libexec/gcc/x86_64-linux-musl/10.2.1/
bash-5.1# /x86_64-linux-musl-cross/bin/x86_64-linux-musl-g++ -v test.cpp
Using built-in specs.
COLLECT_GCC=/x86_64-linux-musl-cross/bin/x86_64-linux-musl-g++
Target: x86_64-linux-musl
Configured with: ../src_gcc/configure --enable-languages=c,c++,fortran CC='gcc -static --static' CXX='g++ -static --static' FC='gfortran -static --static' CFLAGS='-g0 -O2 -fno-align-functions -fno-align-jumps -fno-align-loops -fno-align-labels' CXXFLAGS='-g0 -O2 -fno-align-functions -fno-align-jumps -fno-align-loops -fno-align-labels' FFLAGS='-g0 -O2 -fno-align-functions -fno-align-jumps -fno-align-loops -fno-align-labels' LDFLAGS='-s -static --static' --enable-default-pie --enable-static-pie --disable-bootstrap --disable-assembly --disable-werror --target=x86_64-linux-musl --prefix= --libdir=/lib --disable-multilib --with-sysroot=/x86_64-linux-musl --enable-tls --disable-libmudflap --disable-libsanitizer --disable-gnu-indirect-function --disable-libmpx --enable-libstdcxx-time=rt --enable-deterministic-archives --enable-libstdcxx-time --enable-libquadmath --enable-libquadmath-support --disable-decimal-float --with-build-sysroot=/tmp/m1032/build/local/x86_64-linux-musl/obj_sysroot AR_FOR_TARGET=/tmp/m1032/build/local/x86_64-linux-musl/obj_binutils/binutils/ar AS_FOR_TARGET=/tmp/m1032/build/local/x86_64-linux-musl/obj_binutils/gas/as-new LD_FOR_TARGET=/tmp/m1032/build/local/x86_64-linux-musl/obj_binutils/ld/ld-new NM_FOR_TARGET=/tmp/m1032/build/local/x86_64-linux-musl/obj_binutils/binutils/nm-new OBJCOPY_FOR_TARGET=/tmp/m1032/build/local/x86_64-linux-musl/obj_binutils/binutils/objcopy OBJDUMP_FOR_TARGET=/tmp/m1032/build/local/x86_64-linux-musl/obj_binutils/binutils/objdump RANLIB_FOR_TARGET=/tmp/m1032/build/local/x86_64-linux-musl/obj_binutils/binutils/ranlib READELF_FOR_TARGET=/tmp/m1032/build/local/x86_64-linux-musl/obj_binutils/binutils/readelf STRIP_FOR_TARGET=/tmp/m1032/build/local/x86_64-linux-musl/obj_binutils/binutils/strip-new --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu 'CC_FOR_BUILD=cc -static --static' 'CXX_FOR_BUILD=g++ -static --static'
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.2.1 20210116 (GCC)
COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
cc1plus -quiet -v -iprefix /x86_64-linux-musl-cross/bin/../lib/gcc/x86_64-linux-musl/10.2.1/ -isysroot /x86_64-linux-musl-cross/bin/../x86_64-linux-musl -D_GNU_SOURCE test.cpp -quiet -dumpbase test.cpp -mtune=generic -march=x86-64 -auxbase test -version -o /tmp/ccogMFKi.s
GNU C++14 (GCC) version 10.2.1 20210116 (x86_64-linux-musl)
compiled by GNU C version 10.2.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.1, isl version none
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/x86_64-linux-musl-cross/bin/../lib/gcc/x86_64-linux-musl/10.2.1/../../../../x86_64-linux-musl/include/c++/10.2.1"
ignoring nonexistent directory "/x86_64-linux-musl-cross/bin/../lib/gcc/x86_64-linux-musl/10.2.1/../../../../x86_64-linux-musl/include/c++/10.2.1/x86_64-linux-musl"
ignoring nonexistent directory "/x86_64-linux-musl-cross/bin/../lib/gcc/x86_64-linux-musl/10.2.1/../../../../x86_64-linux-musl/include/c++/10.2.1/backward"
ignoring nonexistent directory "/x86_64-linux-musl-cross/bin/../lib/gcc/x86_64-linux-musl/10.2.1/../../../../x86_64-linux-musl/include"
ignoring nonexistent directory "/x86_64-linux-musl-cross/bin/../lib/gcc/x86_64-linux-musl/10.2.1/include"
ignoring nonexistent directory "/x86_64-linux-musl-cross/bin/../lib/gcc/../../lib/gcc/x86_64-linux-musl/10.2.1/../../../../x86_64-linux-musl/include/c++/10.2.1"
ignoring nonexistent directory "/x86_64-linux-musl-cross/bin/../lib/gcc/../../lib/gcc/x86_64-linux-musl/10.2.1/../../../../x86_64-linux-musl/include/c++/10.2.1/x86_64-linux-musl"
ignoring nonexistent directory "/x86_64-linux-musl-cross/bin/../lib/gcc/../../lib/gcc/x86_64-linux-musl/10.2.1/../../../../x86_64-linux-musl/include/c++/10.2.1/backward"
ignoring nonexistent directory "/x86_64-linux-musl-cross/bin/../x86_64-linux-musl/usr/local/include"
ignoring nonexistent directory "/x86_64-linux-musl-cross/bin/../lib/gcc/../../lib/gcc/x86_64-linux-musl/10.2.1/../../../../x86_64-linux-musl/include"
ignoring nonexistent directory "/x86_64-linux-musl-cross/bin/../x86_64-linux-musl/usr/include"
ignoring nonexistent directory "/x86_64-linux-musl-cross/bin/../lib/gcc/../../lib/gcc/x86_64-linux-musl/10.2.1/include"
#include "..." search starts here:
#include <...> search starts here:
End of search list.
cc1plus: fatal error: test.cpp: Operation not permitted
compilation terminated.
I am running as root and 'test.cpp' has 644 permissions.
Found some solutions for the issue.
Running the Alpine Container as "privileged" solved the issue with the musl toolchain.
Also the previous version of the musl toolchain (Released in January 2021), did not give me the issue.
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).
I used cmake to generate MinGW makefiles to compile wxWidgets. An error was occurred during the process of make (with VERBOSE=1):
[ 12%] Building CXX object libs/base/CMakeFiles/base.dir/__/__/__/src/common/appbase.cpp.obj
cd /d C:\Users\frank\Documents\Codes\wxWidgets\cmakebuild\libs\base && C:\PROGRA~1\MinGW\bin\G__~1.EXE -DDLL_EXPORTS -DUNICODE -DWXBUILDING -DWXDLLNAME=wxbase311u_gcc_custom -DWXMAKINGDLL_BASE -DWX_PRECOMP -D_LIB -D_UNICODE -D__WXMSW__ -Dbase_EXPORTS -DwxUSE_BASE=1 -DwxUSE_GUI=0 #CMakeFiles/base.dir/includes_CXX.rsp -Winvalid-pch -include "C:/.../cmakebuild/libs/base/cotire/base_CXX_prefix.hxx" -o CMakeFiles\base.dir\__\__\__\src\common\appbase.cpp.obj -c C:\Users\frank\Documents\Codes\wxWidgets\src\common\appbase.cpp
make[2]: *** [libs\base\CMakeFiles\base.dir\build.make:93: libs/base/CMakeFiles/base.dir/__/__/__/src/common/appbase.cpp.obj] Error 1
make[2]: Leaving directory 'C:/.../cmakebuild'
make[1]: *** [CMakeFiles\Makefile2:469: libs/base/CMakeFiles/base.dir/all] Error 2
make[1]: Leaving directory 'C:/.../cmakebuild'
make: *** [Makefile:129: all] Error 2
(I've replaced the wxWidgets source path to ...)
I re-ran the the command:
C:\PROGRA~1\MinGW\bin\G__~1.EXE -DDLL_EXPORTS -DUNICODE -DWXBUILDING -DWXDLLNAME=wxbase311u_gcc_custom -DWXMAKINGDLL_BASE -DWX_PRECOMP -D_LIB -D_UNICODE -D__WXMSW__ -Dbase_EXPORTS -DwxUSE_BASE=1 -DwxUSE_GUI=0 #CMakeFiles/base.dir/includes_CXX.rsp -Winvalid-pch -include "C:/.../cmakebuild/libs/base/cotire/base_CXX_prefix.hxx" -o CMakeFiles\base.dir\__\__\__\src\common\appbase.cpp.obj -c C:\...\src\common\appbase.cpp
But I received no output. I appended -v after the command, and here is the output:
Using built-in specs.
COLLECT_GCC=C:\PROGRA~1\MinGW\bin\G__~1.EXE
Target: x86_64-w64-mingw32
Configured with: ../src/configure --enable-languages=c,c++ --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --disable-multilib --prefix=/c/temp/gcc/dest --with-sysroot=/c/temp/gcc/dest --disable-libstdcxx-pch --disable-libstdcxx-verbose --disable-nls --disable-shared --disable-win32-registry --with-tune=haswell --enable-threads=posix --enable-libgomp
Thread model: posix
gcc version 7.3.0 (GCC)
COLLECT_GCC_OPTIONS='-D' 'DLL_EXPORTS' '-D' 'UNICODE' '-D' 'WXBUILDING' '-D' 'WXDLLNAME=wxbase311u_gcc_custom' '-D' 'WXMAKINGDLL_BASE' '-D' 'WX_PRECOMP' '-D' '_LIB' '-D' '_UNICODE' '-D' '__WXMSW__' '-D' 'base_EXPORTS' '-D' 'wxUSE_BASE=1' '-D' 'wxUSE_GUI=0' '-I' 'C:/.../cmakebuild/lib/gcc_dll/mswu' '-I' 'C:/.../include' '-I' 'C:/.../src/zlib' '-I' 'C:/.../src/regex' '-Winvalid-pch' '-include' 'C:/.../cmakebuild/libs/base/cotire/base_CXX_prefix.hxx' '-o' 'CMakeFiles\base.dir\__\__\__\src\common\appbase.cpp.obj' '-c' '-v' '-mtune=haswell' '-march=x86-64'
c:/progra~1/mingw/bin/../libexec/gcc/x86_64-w64-mingw32/7.3.0/cc1plus.exe -quiet -v -I C:/.../cmakebuild/lib/gcc_dll/mswu -I C:/.../include -I C:/.../src/zlib -I C:/.../src/regex -iprefix c:\progra~1\mingw\bin\../lib/gcc/x86_64-w64-mingw32/7.3.0/ -D_REENTRANT -D DLL_EXPORTS -D UNICODE -D WXBUILDING -D WXDLLNAME=wxbase311u_gcc_custom -D WXMAKINGDLL_BASE -D WX_PRECOMP -D _LIB -D _UNICODE -D __WXMSW__ -D base_EXPORTS -D wxUSE_BASE=1 -D wxUSE_GUI=0 -include C:/.../cmakebuild/libs/base/cotire/base_CXX_prefix.hxx C:\Users\frank\Documents\Codes\wxWidgets\src\common\appbase.cpp -quiet -dumpbase appbase.cpp -mtune=haswell -march=x86-64 -auxbase-strip CMakeFiles\base.dir\__\__\__\src\common\appbase.cpp.obj -Winvalid-pch -version -o C:\Users\frank\AppData\Local\Temp\ccF9vVx8.s
GNU C++14 (GCC) version 7.3.0 (x86_64-w64-mingw32)
compiled by GNU C version 7.3.0, GMP version 6.1.2, MPFR version 3.1.6-p2, MPC version 1.1.0, isl version isl-0.18-GMP
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "c:/progra~1/mingw/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../include/c++/7.3.0"
ignoring duplicate directory "c:/progra~1/mingw/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../include/c++/7.3.0/x86_64-w64-mingw32"
ignoring duplicate directory "c:/progra~1/mingw/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../include/c++/7.3.0/backward"
ignoring duplicate directory "c:/progra~1/mingw/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/7.3.0/include"
ignoring nonexistent directory "C:/temp/gcc/destC:/temp/gcc/dest/lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../include"
ignoring duplicate directory "c:/progra~1/mingw/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/7.3.0/include-fixed"
ignoring duplicate directory "c:/progra~1/mingw/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/include"
ignoring nonexistent directory "C:/temp/gcc/dest/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
C:/.../cmakebuild/lib/gcc_dll/mswu
C:/.../include
C:/.../src/zlib
C:/.../src/regex
c:\progra~1\mingw\bin\../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../include/c++/7.3.0
c:\progra~1\mingw\bin\../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../include/c++/7.3.0/x86_64-w64-mingw32
c:\progra~1\mingw\bin\../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../include/c++/7.3.0/backward
c:\progra~1\mingw\bin\../lib/gcc/x86_64-w64-mingw32/7.3.0/include
c:\progra~1\mingw\bin\../lib/gcc/x86_64-w64-mingw32/7.3.0/include-fixed
c:\progra~1\mingw\bin\../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/include
End of search list.
GNU C++14 (GCC) version 7.3.0 (x86_64-w64-mingw32)
compiled by GNU C version 7.3.0, GMP version 6.1.2, MPFR version 3.1.6-p2, MPC version 1.1.0, isl version isl-0.18-GMP
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 00ba9da796d75deb4f2564304e4a9551
I have no idea what the output above indicates, but if I replace -E instead of -c in the original command, it runs successfully. And if I compile the precompiled source file, it also runs successfully and produces the object file I want.
With this method I can produce the object files and make recognize them, but I can't do this manually for every single object file wxWidgets needs. What problem is this? Is there a way to fix it?
CMake version is 3.13.0-rc3
GNU Make version is 4.2.1
MinGW-W64 G++ version is 7.3.0
I just installed gdb 7.7.1 and gcc 4.8.3 by brew on my mac 10.9.4, it does well when I use gcc to compile a test.cpp and use gdb to debug it; but I cannot configure my IDE eclipse cdt to do it? The following is the output and my configure on eclipse?
gcc ouptput when compile in terminal:
wens#mac-pro:test$ g++ -g -std=c++11 -v test.cpp
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc48/4.8.3/libexec/gcc/x86_64-apple- darwin13.3.0/4.8.3/lto-wrapper
Target: x86_64-apple-darwin13.3.0
Configured with: ../configure --build=x86_64-apple-darwin13.3.0 -- prefix=/usr/local/Cellar/gcc48/4.8.3 --enable-languages=c,c++,objc,obj-c++ --program-suffix=-4.8 --with-gmp=/usr/local/opt/gmp4 --with-mpfr=/usr/local/opt/mpfr2 --with-mpc=/usr/local/opt/libmpc08 --with-cloog=/usr/local/opt/cloog018 --with-isl=/usr/local/opt/isl011 --with-system-zlib --enable-version-specific-runtime-libs --enable-libstdcxx-time=yes --enable-stage1-checking --enable-checking=release --enable-lto --disable-werror --with-pkgversion='Homebrew gcc48 4.8.3' --with-bugurl=https://github.com/Homebrew/homebrew-versions/issues --enable-plugin --disable-nls --enable-multilib
Thread model: posix
gcc version 4.8.3 (Homebrew gcc48 4.8.3)
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.9.3' '-g' '-std=c++11' '-v' '-shared-libgcc' '-mtune=core2'
/usr/local/Cellar/gcc48/4.8.3/libexec/gcc/x86_64-apple-darwin13.3.0/4.8.3/cc1plus -quiet -v -D__DYNAMIC__ test.cpp -fPIC -feliminate-unused-debug-symbols -quiet -dumpbase test.cpp -mmacosx-version-min=10.9.3 -mtune=core2 -auxbase test -g -std=c++11 -version -o /var/folders/8j/2cdrpyn133v4mvc7x65b6c040000gn/T//ccnjAUQK.s
GNU C++ (Homebrew gcc48 4.8.3) version 4.8.3 (x86_64-apple-darwin13.3.0)
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=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/Cellar/gcc48/4.8.3/include"
ignoring nonexistent directory "/usr/local/Cellar/gcc48/4.8.3/lib/gcc/x86_64-apple- darwin13.3.0/4.8.3/../../../../x86_64-apple-darwin13.3.0/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/Cellar/gcc48/4.8.3/lib/gcc/x86_64-apple-darwin13.3.0/4.8.3/include/c++
/usr/local/Cellar/gcc48/4.8.3/lib/gcc/x86_64-apple-darwin13.3.0/4.8.3/include/c++/x86_64-apple-darwin13.3.0
/usr/local/Cellar/gcc48/4.8.3/lib/gcc/x86_64-apple-darwin13.3.0/4.8.3/include/c++/backward
/usr/local/Cellar/gcc48/4.8.3/lib/gcc/x86_64-apple-darwin13.3.0/4.8.3/include
/usr/local/include
/usr/local/Cellar/gcc48/4.8.3/lib/gcc/x86_64-apple-darwin13.3.0/4.8.3/include-fixed
/usr/include
/System/Library/Frameworks
/Library/Frameworks
End of search list.
GNU C++ (Homebrew gcc48 4.8.3) version 4.8.3 (x86_64-apple-darwin13.3.0)
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=100 --param ggc-min-heapsize=131072
Compiler executable checksum: ef96a7cbf8b02312d9306455464399f1
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.9.3' '-g' '-std=c++11' '-v' '-shared-libgcc' '-mtune=core2'
as -arch x86_64 -force_cpusubtype_ALL -o /var/folders/8j/2cdrpyn133v4mvc7x65b6c040000gn/T//ccvxLrmP.o /var/folders/8j/2cdrpyn133v4mvc7x65b6c040000gn/T//ccnjAUQK.s
COMPILER_PATH=/usr/local/Cellar/gcc48/4.8.3/libexec/gcc/x86_64-apple-darwin13.3.0/4.8.3/:/usr/local/Cellar/gcc48/4.8.3/libexec/gcc/x86_64-apple- darwin13.3.0/4.8.3/:/usr/local/Cellar/gcc48/4.8.3/libexec/gcc/x86_64-apple-darwin13.3.0/:/usr/local/Cellar/gcc48/4.8.3/lib/gcc/x86_64-apple-darwin13.3.0/4.8.3/:/usr/local/Cellar/gcc48/4.8.3/lib/gcc/x86_64-apple-darwin13.3.0/
LIBRARY_PATH=/usr/local/Cellar/gcc48/4.8.3/lib/gcc/x86_64-apple-darwin13.3.0/4.8.3/:/usr/local/Cellar/gcc48/4.8.3/lib/gcc/x86_64-apple-darwin13.3.0/4.8.3/../../../:/usr/lib/
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.9.3' '-g' '-std=c++11' '-v' '-shared-libgcc' '-mtune=core2' /usr/local/Cellar/gcc48/4.8.3/libexec/gcc/x86_64-apple darwin13.3.0/4.8.3/collect2 -dynamic -arch x86_64 -macosx_version_min 10.9.3 -weak_reference_mismatches non-weak -o a.out -L/usr/local/Cellar/gcc48/4.8.3/lib/gcc/x86_64-apple-darwin13.3.0/4.8.3 -L/usr/local/Cellar/gcc48/4.8.3/lib/gcc/x86_64-apple-darwin13.3.0/4.8.3/../../.. /var/folders/8j/2cdrpyn133v4mvc7x65b6c040000gn/T//ccvxLrmP.o -lstdc++ -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lSystem -v -idsym -dsym
collect2 version 4.8.3
/usr/bin/ld -dynamic -arch x86_64 -macosx_version_min 10.9.3 -weak_reference_mismatches non-weak -o a.out -L/usr/local/Cellar/gcc48/4.8.3/lib/gcc/x86_64-apple-darwin13.3.0/4.8.3 -L/usr/local/Cellar/gcc48/4.8.3/lib/gcc/x86_64-apple-darwin13.3.0/4.8.3/../../.. /var/folders/8j/2cdrpyn133v4mvc7x65b6c040000gn/T//ccvxLrmP.o -lstdc++ -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lSystem -v
#(#)PROGRAM:ld PROJECT:ld64-236.4
configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 armv6m armv7m armv7em
Library search paths:
/usr/local/Cellar/gcc48/4.8.3/lib/gcc/x86_64-apple-darwin13.3.0/4.8.3
/usr/local/Cellar/gcc48/4.8.3/lib
/usr/lib
/usr/local/lib
Framework search paths:
/Library/Frameworks/
/System/Library/Frameworks/
dsymutil a.out
This output "a.out" and " a.out.dSYM" is just like native clang, and I can use gdb debug it correctly.
The following is the output from eclipse:
18:02:32 **** Build of configuration Default for project test ****
make all
/usr/local/bin/g++ -g -std=c++11 -v -c -o test.o test.cpp
Using built-in specs.
COLLECT_GCC=/usr/local/bin/g++
Target: x86_64-apple-darwin13.3.0
Configured with: ../configure --build=x86_64-apple-darwin13.3.0 -- prefix=/usr/local/Cellar/gcc48/4.8.3 --enable-languages=c,c++,objc,obj-c++ --program-suffix=-4.8 --with-gmp=/usr/local/opt/gmp4 --with-mpfr=/usr/local/opt/mpfr2 --with-mpc=/usr/local/opt/libmpc08 --with-cloog=/usr/local/opt/cloog018 --with-isl=/usr/local/opt/isl011 --with-system-zlib --enable-version-specific-runtime-libs --enable-libstdcxx-time=yes --enable-stage1-checking --enable-checking=release --enable-lto --disable-werror --with-pkgversion='Homebrew gcc48 4.8.3' --with-bugurl=https://github.com/Homebrew/homebrew-versions/issues --enable-plugin --disable-nls --enable-multilib
Thread model: posix
gcc version 4.8.3 (Homebrew gcc48 4.8.3)
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.9.3' '-g' '-std=c++11' '-v' '-c' '-o' 'test.o' '-shared-libgcc' '-mtune=core2'
/usr/local/Cellar/gcc48/4.8.3/libexec/gcc/x86_64-apple-darwin13.3.0/4.8.3/cc1plus -quiet -v -D__DYNAMIC__ test.cpp -fPIC -feliminate-unused-debug-symbols -quiet -dumpbase test.cpp -mmacosx-version-min=10.9.3 -mtune=core2 -auxbase-strip test.o -g -std=c++11 -version -o /var/folders/8j/2cdrpyn133v4mvc7x65b6c040000gn/T//ccJWTQT8.s
GNU C++ (Homebrew gcc48 4.8.3) version 4.8.3 (x86_64-apple-darwin13.3.0)
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=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/Cellar/gcc48/4.8.3/include"
ignoring nonexistent directory "/usr/local/Cellar/gcc48/4.8.3/lib/gcc/x86_64-apple- darwin13.3.0/4.8.3/../../../../x86_64-apple-darwin13.3.0/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/Cellar/gcc48/4.8.3/lib/gcc/x86_64-apple-darwin13.3.0/4.8.3/include/c++
/usr/local/Cellar/gcc48/4.8.3/lib/gcc/x86_64-apple-darwin13.3.0/4.8.3/include/c++/x86_64-apple-darwin13.3.0
/usr/local/Cellar/gcc48/4.8.3/lib/gcc/x86_64-apple-darwin13.3.0/4.8.3/include/c++/backward
/usr/local/Cellar/gcc48/4.8.3/lib/gcc/x86_64-apple-darwin13.3.0/4.8.3/include
/usr/local/include
/usr/local/Cellar/gcc48/4.8.3/lib/gcc/x86_64-apple-darwin13.3.0/4.8.3/include-fixed
/usr/include
/System/Library/Frameworks
/Library/Frameworks
End of search list.
GNU C++ (Homebrew gcc48 4.8.3) version 4.8.3 (x86_64-apple-darwin13.3.0)
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=100 --param ggc-min-heapsize=131072
Compiler executable checksum: ef96a7cbf8b02312d9306455464399f1
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.9.3' '-g' '-std=c++11' '-v' '-c' '-o' 'test.o' '-shared-libgcc' '-mtune=core2'
as -arch x86_64 -force_cpusubtype_ALL -o test.o /var/folders/8j/2cdrpyn133v4mvc7x65b6c040000gn/T//ccJWTQT8.s
COMPILER_PATH=/usr/local/Cellar/gcc48/4.8.3/libexec/gcc/x86_64-apple-darwin13.3.0/4.8.3/:/usr/local/Cellar/gcc48/4.8.3/libexec/gcc/x86_64-apple-darwin13.3.0/4.8.3/:/usr/local/Cellar/gcc48/4.8.3/libexec/gcc/x86_64-apple-darwin13.3.0/:/usr/local/Cellar/gcc48/4.8.3/lib/gcc/x86_64-apple-darwin13.3.0/4.8.3/:/usr/local/Cellar/gcc48/4.8.3/lib/gcc/x86_64-apple-darwin13.3.0/
/usr/local/bin/g++ -o test test.o
LIBRARY_PATH=/usr/local/Cellar/gcc48/4.8.3/lib/gcc/x86_64-apple-darwin13.3.0/4.8.3/:/usr/local/Cellar/gcc48/4.8.3/lib/gcc/x86_64-apple-darwin13.3.0/4.8.3/../../../:/usr/lib/
COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.9.3' '-g' '-std=c++11' '-v' '-c' '-o' 'test.o' '-shared-libgcc' '-mtune=core2'
18:02:32 Build Finished (took 415ms)
The config in the tiny test makefile c++ project
CXX = /usr/local/bin/g++
CXXFLAGS = -mmacosx-version-min=10.9.3 -g -std=c++11 -v -shared-libgcc -mtune=core2
OBJS = test.o
LIBS =
TARGET = test
$(TARGET): $(OBJS)
$(CXX) -o $(TARGET) $(OBJS) $(LIBS)
all: $(TARGET)
clean:
rm -f $(OBJS) $(TARGET)
when i use gdb print a local value in main(), it give following:
(gdb) r
(gdb) file test
Reading symbols from test...done.
(gdb) list
8 #include <iostream>
9 #include <vector>
10
11 using namespace std;
12
13 //extern vector<int> spiral_output_matrix(vector<vector<int> > const &v);
14
15 int main()
16 {
17 vector<int> origin = {1, 3, 5};
(gdb) break 20
Breakpoint 1 at 0x100000810: file test.cpp, line 20.
(gdb) run
Starting program: /Users/wens/Desktop/code_study/eclipse/test/test
Breakpoint 1, main () at test.cpp:21
21 for (auto i : origin)
(gdb) print i
Could not find the frame base for "main()".
(gdb)
I have used the same gcc-4.8 and gdb 7.7.1 for eclipse, from the above output I can know it's something about ld and dsymutil? It cause the different, right? anyone can tell me is there some way to configure eclipse to do this?
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.