I'm trying to install gcc-5.0
from source on my OS X 10.7.5
using the (Apple built) /usr/bin/gcc-4.2
and the appropriate versions of gcc dependencies (gmp
,mpfr
,mpc
) which are installed at /usr/local
.
The reason I'm trying to (re)install gcc-5.0
is because I want to install it into a separate folder like /usr/local/gcc-5.0
so that I can choose to use or not us it easily by setting it into the PATH
environment variable. The /configure
script is (initiated from an empty gcc-5.0-build
folder)
../gcc-5.0.0/configure --prefix=/usr/local/gcc-5.0.0 --with-gmp=/usr/local/lib --with-mpfr=/usr/local/lib --with-mpc=/usr/local/lib --enable-languages=c,c++
After make
and about 1GB of compiled files I get this error (truncated)
dyld: Symbol not found: __ZNKSt11logic_error4whatEv
Referenced from: <my-build-dir>/x86_64-apple-darwin11.4.0/libstdc++-v3/src/.libs/libstdc++.6.dylib
Expected in: flat namespace
After browsing many webpages and posts in Stackoverflow, I've tried various things like:
adding LDFLAGS="-flat_namespace"
before ./configure
compiling with Apple built gcc-4.2
instead of gcc-5.0
but no luck I still end up with this error.
When I check the libstdc++.6.dylib
on the presence of __ZNKSt11logic_error4whatEv
nm -g x86_64-apple-darwin11.4.0/libstdc++-v3/src/.libs/libstdc++.6.dylib | grep __ZNKSt11logic_error4whatEv
It returns:
U __ZNKSt11logic_error4whatEv
so itcontains the symbol in question It doesn't contain the symbol in question (The U means Undefined)
otool -hv x86_64-apple-darwin11.4.0/libstdc++-v3/src/.libs/libstdc++.6.dylib
returns
Mach header
magic cputype cpusubtype caps filetype ncmds sizeofcmds flags
MH_MAGIC_64 X86_64 ALL 0x00 DYLIB 13 2560 NOUNDEFS DYLDLINK TWOLEVEL WEAK_DEFINES BINDS_TO_WEAK NO_REEXPORTED_DYLIBS
The DYLDLINK TWOLEVEL
means that it's two-level namespace lib.
Questions :
1- In the message After a comment by @G.M. the symbol is not defined in the library in question and that makes the absence or presence of Expected in: flat namespace
does it mean that the compiler wants absolutely only the flat namespace library? I mean is it absolutely not possible to use this two-level namespace lib?flat namespace
irrelevant because it is the content of the library which causes the problem, not its type.
2- What should I do compile the gcc-5.0
?
Update 23.March.2021
Upon the answer suggesting hiding the symbols, I've added
export CFLAGS="-fvisibility=hidden"
onto the ~/.bash_profile
deleted the build folder all over, configured again using
../gcc-5.0.0-20150224/configure --prefix=/usr/local/gcc-5.0.0 --enable-languages=c,c++
and after make
has created 532MB of compiled files, it stopped by the strip: symbols names listed in:libgcc-darwin.10.4.ver
not in libgcc_s.dylib
type of error. Here is how it stopped:
/Users/thompson/Downloads/gcc-5.0.0-20150224-mybuild/./gcc/xgcc -B/Users/thompson/Downloads/gcc-5.0.0-20150224-mybuild/./gcc/ -B/usr/local/gcc-5.0.0/x86_64-apple-darwin11.4.2/bin/ -B/usr/local/gcc-5.0.0/x86_64-apple-darwin11.4.2/lib/ -isystem /usr/local/gcc-5.0.0/x86_64-apple-darwin11.4.2/include -isystem /usr/local/gcc-5.0.0/x86_64-apple-darwin11.4.2/sys-include -O2 -g -O2 -fvisibility=hidden -DIN_GCC -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -pipe -fno-common -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -dynamiclib -nodefaultlibs -install_name /usr/local/gcc-5.0.0/lib/libgcc_s.1.dylib -single_module -o ./libgcc_s.dylib -Wl,-exported_symbols_list,libgcc.map -compatibility_version 1 -current_version 1.0 -g -O2 -fvisibility=hidden -B./ _muldi3_s.o _negdi2_s.o _lshrdi3_s.o _ashldi3_s.o _ashrdi3_s.o _cmpdi2_s.o _ucmpdi2_s.o _clear_cache_s.o _trampoline_s.o __main_s.o _absvsi2_s.o _absvdi2_s.o _addvsi3_s.o _addvdi3_s.o _subvsi3_s.o _subvdi3_s.o _mulvsi3_s.o _mulvdi3_s.o _negvsi2_s.o _negvdi2_s.o _ctors_s.o _ffssi2_s.o _ffsdi2_s.o _clz_s.o _clzsi2_s.o _clzdi2_s.o _ctzsi2_s.o _ctzdi2_s.o _popcount_tab_s.o _popcountsi2_s.o _popcountdi2_s.o _paritysi2_s.o _paritydi2_s.o _powisf2_s.o _powidf2_s.o _powixf2_s.o _powitf2_s.o _mulsc3_s.o _muldc3_s.o _mulxc3_s.o _multc3_s.o _divsc3_s.o _divdc3_s.o _divxc3_s.o _divtc3_s.o _bswapsi2_s.o _bswapdi2_s.o _clrsbsi2_s.o _clrsbdi2_s.o _fixunssfsi_s.o _fixunsdfsi_s.o _fixunsxfsi_s.o _fixsfdi_s.o _fixdfdi_s.o _fixxfdi_s.o _fixunssfdi_s.o _fixunsdfdi_s.o _fixunsxfdi_s.o _floatdisf_s.o _floatdidf_s.o _floatdixf_s.o _floatundisf_s.o _floatundidf_s.o _floatundixf_s.o _fixsfti_s.o _fixdfti_s.o _fixxfti_s.o _fixtfti_s.o _fixunssfti_s.o _fixunsdfti_s.o _fixunsxfti_s.o _fixunstfti_s.o _floattisf_s.o _floattidf_s.o _floattixf_s.o _floattitf_s.o _floatuntisf_s.o _floatuntidf_s.o _floatuntixf_s.o _floatuntitf_s.o _divdi3_s.o _moddi3_s.o _udivdi3_s.o _umoddi3_s.o _udiv_w_sdiv_s.o _udivmoddi4_s.o darwin-64_s.o cpuinfo_s.o sfp-exceptions_s.o addtf3_s.o divtf3_s.o eqtf2_s.o getf2_s.o letf2_s.o multf3_s.o negtf2_s.o subtf3_s.o unordtf2_s.o fixtfsi_s.o fixunstfsi_s.o floatsitf_s.o floatunsitf_s.o fixtfdi_s.o fixunstfdi_s.o floatditf_s.o floatunditf_s.o fixtfti_s.o fixunstfti_s.o floattitf_s.o floatuntitf_s.o extendsftf2_s.o extenddftf2_s.o extendxftf2_s.o trunctfsf2_s.o trunctfdf2_s.o trunctfxf2_s.o enable-execute-stack_s.o unwind-dw2_s.o unwind-dw2-fde-darwin_s.o unwind-sjlj_s.o unwind-c_s.o emutls_s.o libgcc.a -lc
ld: warning: cannot export hidden symbol ___ashldi3 from darwin-64_s.o
ld: warning: cannot export hidden symbol ___ashrdi3 from darwin-64_s.o
ld: warning: cannot export hidden symbol ___clzsi2 from darwin-64_s.o
ld: warning: cannot export hidden symbol ___cmpdi2 from darwin-64_s.o
<truncated>
ld: warning: cannot export hidden symbol ___fixunstfsi from fixunstfsi_s.o
ld: warning: cannot export hidden symbol ___floatsitf from floatsitf_s.o
<truncated>
ld: warning: cannot export hidden symbol ___enable_execute_stack from enable-execute-stack_s.o
<truncated>
ld: warning: cannot export hidden symbol ___emutls_register_common from emutls_s.o
MLIBS=`/Users/thompson/Downloads/gcc-5.0.0-20150224-mybuild/./gcc/xgcc -B/Users/thompson/Downloads/gcc-5.0.0-20150224-mybuild/./gcc/ -B/usr/local/gcc-5.0.0/x86_64-apple-darwin11.4.2/bin/ -B/usr/local/gcc-5.0.0/x86_64-apple-darwin11.4.2/lib/ -isystem /usr/local/gcc-5.0.0/x86_64-apple-darwin11.4.2/include -isystem /usr/local/gcc-5.0.0/x86_64-apple-darwin11.4.2/sys-include --print-multi-lib | sed -e 's/;.*$//'` ; \
for mlib in $MLIBS ; do \
cp ../${mlib}/libgcc/${mlib}/libgcc_s.dylib \
./libgcc_s.1.dylib_T_${mlib} || exit 1 ; \
done
lipo -output libgcc_s.1.dylib \
-create libgcc_s.1.dylib_T*
rm libgcc_s.1.dylib_T*
<truncated>
strip: symbols names listed in: <source-folder>/libgcc/config/i386/libgcc-darwin.10.4.ver not in: </Users/thompson/Downloads/gcc-5.0.0-20150224-mybuild>/x86_64-apple-darwin11.4.2/libgcc/libgcc_s.dylib
___ashldi3
___ashrdi3
___clzsi2
___cmpdi2
___ctzsi2
___divdi3
___enable_execute_stack
___gcc_personality_v0
___lshrdi3
___moddi3
___muldi3
___negdi2
___paritysi2
___popcountsi2
___ucmpdi2
___udivdi3
___udivmoddi4
___umoddi3
make[3]: *** [libgcc_ext.10.4.dylib] Error 1
make[2]: *** [all-stage1-target-libgcc] Error 2