* C++11 program link failure under GCC 4.8.2-1 @ 2013-11-11 21:17 Yucong Sun [not found] ` <52815780.2010006@gmail.com> 0 siblings, 1 reply; 16+ messages in thread From: Yucong Sun @ 2013-11-11 21:17 UTC (permalink / raw) To: cygwin Hi, I'm trying to compile a program under cygwin with latest gcc 4.8.2, the program compiles fine, but link failed. I'm suspecting this has something todo with libstdc++ but I couldn't find any document on how to check libstdc++ version (cygwin setup claim it is version 4.8.2 already). Your help is very appericated! make[1]: [driver.exe] Error 1 (ignored) g++ -rdynamic -fno-omit-frame-pointer -D_GNU_SOURCE -march=native -O3 -g -gdwar f-2 -std=gnu++0x -flto grammar.tab.o lex.o main.o rc.o interpret.o simulate.o fi le.o object.o backend.o array.o mapping.o comm.o ed.o regexp.o buffer.o crc32.o malloc.o mallocwrapper.o class.o efuns_main.o efuns_port.o call_out.o otable.o d umpstat.o stralloc.o hash.o port.o reclaim.o parse.o simul_efun.o sprintf.o prog ram.o compiler.o avltree.o icode.o trees.o generate.o scratchpad.o socket_efuns. o socket_ctrl.o eoperators.o socket_err.o md.o disassembler.o uvalarm.o replace_ program.o master.o function.o debug.o crypt.o applies_table.o add_action.o eval. o fliconv.o console.o posix_timers.o event.o dns.o packages/*.o `./dtrace_compil e` -o driver.exe -lcrypt -levent -L/usr/local/lib Cannot export _ZNSt10_HashtableIP8object_sSt4pairIKS1_xESaIS4_ENSt8__detail10_Se lect1stESt8equal_toIS1_ESt4hashIS1_ENS6_18_Mod_range_hashingENS6_20_Default_rang ed_hashENS6_20_Prime_rehash_policyENS6_17_Hashtable_traitsILb0ELb0ELb0EEEE10_M_e mplaceIJS2_IS1_xEEEENS6_14_Node_iteratorIS4_Lb0ELb0EEESt17integral_constantIbLb0 EEDpOT_: symbol wrong type (4 vs 3) Cannot export _ZNSt10_HashtableIP8object_sSt4pairIKS1_xESaIS4_ENSt8__detail10_Se lect1stESt8equal_toIS1_ESt4hashIS1_ENS6_18_Mod_range_hashingENS6_20_Default_rang ed_hashENS6_20_Prime_rehash_policyENS6_17_Hashtable_traitsILb0ELb0ELb0EEEE16_M_a llocate_nodeIJS2_IS1_xEEEEPNS6_10_Hash_nodeIS4_Lb0EEEDpOT_: symbol wrong type (4 vs 3) Cannot export _ZNSt10_HashtableIxSt4pairIKxP14pending_call_sESaIS4_ENSt8__detail 10_Select1stESt8equal_toIxESt4hashIxENS6_18_Mod_range_hashingENS6_20_Default_ran ged_hashENS6_20_Prime_rehash_policyENS6_17_Hashtable_traitsILb0ELb0ELb1EEEE10_M_ emplaceIJS0_IxS3_EEEES0_INS6_14_Node_iteratorIS4_Lb0ELb0EEEbESt17integral_consta ntIbLb1EEDpOT_: symbol wrong type (4 vs 3) Cannot export _ZNSt10_HashtableIxSt4pairIKxP14pending_call_sESaIS4_ENSt8__detail 10_Select1stESt8equal_toIxESt4hashIxENS6_18_Mod_range_hashingENS6_20_Default_ran ged_hashENS6_20_Prime_rehash_policyENS6_17_Hashtable_traitsILb0ELb0ELb1EEEE16_M_ allocate_nodeIJS0_IxS3_EEEEPNS6_10_Hash_nodeIS4_Lb0EEEDpOT_: symbol wrong type ( 4 vs 3) Cannot export _ZNSt13_Rb_tree_nodeISt4pairIK8svalue_sSt5dequeIPS1_SaIS4_EEEEC1IJ S7_EEEDpOT_: symbol wrong type (4 vs 3) Cannot export _ZNSt5dequeIP10tick_eventSaIS1_EE16_M_push_back_auxIJRKS1_EEEvDpOT _: symbol wrong type (4 vs 3) Cannot export _ZNSt5dequeIP8svalue_sSaIS1_EE12emplace_backIJS1_EEEvDpOT_: symbol wrong type (4 vs 3) Cannot export _ZNSt5dequeIP8svalue_sSaIS1_EE16_M_push_back_auxIJS1_EEEvDpOT_: sy mbol wrong type (4 vs 3) Cannot export _ZNSt8_Rb_treeI8svalue_sSt4pairIKS0_St5dequeIPS0_SaIS4_EEESt10_Sel ect1stIS7_E21unique_svalue_compareSaIS7_EE14_M_create_nodeIJS7_EEEPSt13_Rb_tree_ nodeIS7_EDpOT_: symbol wrong type (4 vs 3) Cannot export _ZNSt8_Rb_treeIlSt4pairIKlP10tick_eventESt10_Select1stIS4_ESt4less IlESaIS4_EE14_M_create_nodeIJS0_IlS3_EEEEPSt13_Rb_tree_nodeIS4_EDpOT_: symbol wr ong type (4 vs 3) collect2: error: ld returned 1 exit status Makefile:103: recipe for target 'driver.exe' failed make[1]: *** [driver.exe] Error 1 make[1]: Leaving directory '/home/sunyc/fluffos/src' Makefile:77: recipe for target 'all' failed make: *** [all] Error 2 -- Cheers -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple ^ permalink raw reply [flat|nested] 16+ messages in thread
[parent not found: <52815780.2010006@gmail.com>]
* Re: C++11 program link failure under GCC 4.8.2-1 [not found] ` <52815780.2010006@gmail.com> @ 2013-11-11 22:28 ` JonY 2013-11-11 23:38 ` Yucong Sun 0 siblings, 1 reply; 16+ messages in thread From: JonY @ 2013-11-11 22:28 UTC (permalink / raw) To: The Cygwin Mailing List [-- Attachment #1: Type: text/plain, Size: 627 bytes --] On 11/12/2013 06:17, JonY wrote: > On 11/12/2013 05:17, Yucong Sun wrote: >> Hi, >> >> I'm trying to compile a program under cygwin with latest gcc 4.8.2, >> the program compiles fine, but link failed. I'm suspecting this has >> something todo with libstdc++ but I couldn't find any document on how >> to check libstdc++ version (cygwin setup claim it is version 4.8.2 >> already). >> > > I'm not sure either, could you ask gcc-help instead? > > 963e2a697c3a1a7d036d975b07f4c408bbd1cb2d *libstdc++.dll.a f4dfadfddade3aceaf4852cd5db31372ab7ef0d1 *libstdc++.a Is your sha1sum matching mine for 4.8.2? [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 834 bytes --] ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: C++11 program link failure under GCC 4.8.2-1 2013-11-11 22:28 ` JonY @ 2013-11-11 23:38 ` Yucong Sun 2013-11-12 2:34 ` Yucong Sun 2013-11-12 9:44 ` JonY 0 siblings, 2 replies; 16+ messages in thread From: Yucong Sun @ 2013-11-11 23:38 UTC (permalink / raw) To: cygwin Yes, the sha1 matches. sunyc@sunyc-wks /lib/gcc/i686-pc-cygwin/4.8.2 $ sha1sum.exe libstdc++.* f4dfadfddade3aceaf4852cd5db31372ab7ef0d1 *libstdc++.a 963e2a697c3a1a7d036d975b07f4c408bbd1cb2d *libstdc++.dll.a Also I couldn't find GLIB_xxx version number in libstdc++.a sunyc@sunyc-wks /lib/gcc/i686-pc-cygwin/4.8.2 $ strings.exe libstdc++.a | grep GLIB GLIBCXX_FORCE_NEW GLIBCXX_FORCE_NEW GLIBCXX_DEBUG_MESSAGE_LENGTH Cheers. On Mon, Nov 11, 2013 at 2:28 PM, JonY <10walls@gmail.com> wrote: > On 11/12/2013 06:17, JonY wrote: >> On 11/12/2013 05:17, Yucong Sun wrote: >>> Hi, >>> >>> I'm trying to compile a program under cygwin with latest gcc 4.8.2, >>> the program compiles fine, but link failed. I'm suspecting this has >>> something todo with libstdc++ but I couldn't find any document on how >>> to check libstdc++ version (cygwin setup claim it is version 4.8.2 >>> already). >>> >> >> I'm not sure either, could you ask gcc-help instead? >> >> > > 963e2a697c3a1a7d036d975b07f4c408bbd1cb2d *libstdc++.dll.a > f4dfadfddade3aceaf4852cd5db31372ab7ef0d1 *libstdc++.a > > Is your sha1sum matching mine for 4.8.2? > > -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: C++11 program link failure under GCC 4.8.2-1 2013-11-11 23:38 ` Yucong Sun @ 2013-11-12 2:34 ` Yucong Sun 2013-11-12 2:38 ` Yucong Sun 2013-11-12 9:46 ` JonY 2013-11-12 9:44 ` JonY 1 sibling, 2 replies; 16+ messages in thread From: Yucong Sun @ 2013-11-12 2:34 UTC (permalink / raw) To: cygwin I've tried on both 32bit and 64bit clean cygwin install, the result is same. Something is wrong with cygwin's gcc. my configure script by default uses g++ --std=c++11, this still have problem of " no snprintf " , after I replace all snprintf() with sprintf() , I've met the same linkage problem again. g++ --std=gnu++0x "fixes" the snprintf problem, but it still have same linkage problem. Any help will be much appreciated. Cheers. On Mon, Nov 11, 2013 at 3:37 PM, Yucong Sun <sunyucong@gmail.com> wrote: > Yes, the sha1 matches. > > sunyc@sunyc-wks /lib/gcc/i686-pc-cygwin/4.8.2 > $ sha1sum.exe libstdc++.* > f4dfadfddade3aceaf4852cd5db31372ab7ef0d1 *libstdc++.a > 963e2a697c3a1a7d036d975b07f4c408bbd1cb2d *libstdc++.dll.a > > Also I couldn't find GLIB_xxx version number in libstdc++.a > > sunyc@sunyc-wks /lib/gcc/i686-pc-cygwin/4.8.2 > $ strings.exe libstdc++.a | grep GLIB > GLIBCXX_FORCE_NEW > GLIBCXX_FORCE_NEW > GLIBCXX_DEBUG_MESSAGE_LENGTH > > Cheers. > > On Mon, Nov 11, 2013 at 2:28 PM, JonY <10walls@gmail.com> wrote: >> On 11/12/2013 06:17, JonY wrote: >>> On 11/12/2013 05:17, Yucong Sun wrote: >>>> Hi, >>>> >>>> I'm trying to compile a program under cygwin with latest gcc 4.8.2, >>>> the program compiles fine, but link failed. I'm suspecting this has >>>> something todo with libstdc++ but I couldn't find any document on how >>>> to check libstdc++ version (cygwin setup claim it is version 4.8.2 >>>> already). >>>> >>> >>> I'm not sure either, could you ask gcc-help instead? >>> >>> >> >> 963e2a697c3a1a7d036d975b07f4c408bbd1cb2d *libstdc++.dll.a >> f4dfadfddade3aceaf4852cd5db31372ab7ef0d1 *libstdc++.a >> >> Is your sha1sum matching mine for 4.8.2? >> >> -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: C++11 program link failure under GCC 4.8.2-1 2013-11-12 2:34 ` Yucong Sun @ 2013-11-12 2:38 ` Yucong Sun 2013-11-12 9:46 ` JonY 1 sibling, 0 replies; 16+ messages in thread From: Yucong Sun @ 2013-11-12 2:38 UTC (permalink / raw) To: cygwin (forgot to say) this program compile and links fine on g++ 4.6 ,4.7, 4.8 on ubuntu ,centos, freebsd etc without modification. Cheers. On Mon, Nov 11, 2013 at 6:33 PM, Yucong Sun <sunyucong@gmail.com> wrote: > I've tried on both 32bit and 64bit clean cygwin install, the result is > same. Something is wrong with cygwin's gcc. > > my configure script by default uses g++ --std=c++11, this still have > problem of " no snprintf " , after I replace all snprintf() with > sprintf() , I've met the same linkage problem again. > > g++ --std=gnu++0x "fixes" the snprintf problem, but it still have same > linkage problem. > > Any help will be much appreciated. > > Cheers. > > On Mon, Nov 11, 2013 at 3:37 PM, Yucong Sun <sunyucong@gmail.com> wrote: >> Yes, the sha1 matches. >> >> sunyc@sunyc-wks /lib/gcc/i686-pc-cygwin/4.8.2 >> $ sha1sum.exe libstdc++.* >> f4dfadfddade3aceaf4852cd5db31372ab7ef0d1 *libstdc++.a >> 963e2a697c3a1a7d036d975b07f4c408bbd1cb2d *libstdc++.dll.a >> >> Also I couldn't find GLIB_xxx version number in libstdc++.a >> >> sunyc@sunyc-wks /lib/gcc/i686-pc-cygwin/4.8.2 >> $ strings.exe libstdc++.a | grep GLIB >> GLIBCXX_FORCE_NEW >> GLIBCXX_FORCE_NEW >> GLIBCXX_DEBUG_MESSAGE_LENGTH >> >> Cheers. >> >> On Mon, Nov 11, 2013 at 2:28 PM, JonY <10walls@gmail.com> wrote: >>> On 11/12/2013 06:17, JonY wrote: >>>> On 11/12/2013 05:17, Yucong Sun wrote: >>>>> Hi, >>>>> >>>>> I'm trying to compile a program under cygwin with latest gcc 4.8.2, >>>>> the program compiles fine, but link failed. I'm suspecting this has >>>>> something todo with libstdc++ but I couldn't find any document on how >>>>> to check libstdc++ version (cygwin setup claim it is version 4.8.2 >>>>> already). >>>>> >>>> >>>> I'm not sure either, could you ask gcc-help instead? >>>> >>>> >>> >>> 963e2a697c3a1a7d036d975b07f4c408bbd1cb2d *libstdc++.dll.a >>> f4dfadfddade3aceaf4852cd5db31372ab7ef0d1 *libstdc++.a >>> >>> Is your sha1sum matching mine for 4.8.2? >>> >>> -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: C++11 program link failure under GCC 4.8.2-1 2013-11-12 2:34 ` Yucong Sun 2013-11-12 2:38 ` Yucong Sun @ 2013-11-12 9:46 ` JonY 2013-11-12 18:35 ` Yucong Sun 1 sibling, 1 reply; 16+ messages in thread From: JonY @ 2013-11-12 9:46 UTC (permalink / raw) To: cygwin [-- Attachment #1: Type: text/plain, Size: 603 bytes --] On 11/12/2013 10:33, Yucong Sun wrote: > I've tried on both 32bit and 64bit clean cygwin install, the result is > same. Something is wrong with cygwin's gcc. > > my configure script by default uses g++ --std=c++11, this still have > problem of " no snprintf " , after I replace all snprintf() with > sprintf() , I've met the same linkage problem again. > Something else is very wrong. > g++ --std=gnu++0x "fixes" the snprintf problem, but it still have same > linkage problem. > Please make a minimalist case, I've tried some basic C++11 features but I don't get such errors. [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 834 bytes --] ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: C++11 program link failure under GCC 4.8.2-1 2013-11-12 9:46 ` JonY @ 2013-11-12 18:35 ` Yucong Sun 2013-11-12 22:30 ` JonY 2014-03-12 21:05 ` zosrothko 0 siblings, 2 replies; 16+ messages in thread From: Yucong Sun @ 2013-11-12 18:35 UTC (permalink / raw) To: cygwin Good new! I've found the link failure issue, it is caused by "-rdynamic" sunyc@sunyc-wks ~ $ cat 2.cc #include <deque> struct tick_event { int i; }; int main() { std::deque<tick_event *> list; tick_event *a = new tick_event; list.push_back(a); return 0; } sunyc@sunyc-wks ~ $ g++ -c --std=c++11 -O3 -flto 2.cc -o 2.o sunyc@sunyc-wks ~ $ g++ --std=c++11 -flto -D_GNU_SOURCE -rdynamic -fno-omit-frame-pointer -D_GNU_ SOURCE -march=native -O3 2.o -o a Cannot export _ZNSt5dequeIP10tick_eventSaIS1_EE16_M_push_back_auxIJRKS1_EEEvDpOT _: symbol wrong type (4 vs 3) collect2: error: ld returned 1 exit status sunyc@sunyc-wks ~ $ g++ --std=c++11 -flto -D_GNU_SOURCE -fno-omit-frame-pointer -D_GNU_SOURCE -ma rch=native -O3 2.o -o a sunyc@sunyc-wks ~ $ Hope it would help you nail the problem. And Here's the test case for snprintf & c++11 $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-cygwin/4.8.2/lto-wrapper.exe Target: x86_64-pc-cygwin Configured with: /cygdrive/i/szsz/tmpp/cygwin64/gcc/gcc-4.8.2-1/src/gcc-4.8.2/co nfigure --srcdir=/cygdrive/i/szsz/tmpp/cygwin64/gcc/gcc-4.8.2-1/src/gcc-4.8.2 -- prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdi r=/usr/libexec --datadir=/usr/share --localstatedir=/var --sysconfdir=/etc --lib dir=/usr/lib --datarootdir=/usr/share --docdir=/usr/share/doc/gcc -C --build=x86 _64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-pc-cygwin --without-libico nv-prefix --without-libintl-prefix --enable-shared --enable-shared-libgcc --enab le-static --enable-version-specific-runtime-libs --enable-bootstrap --disable-__ cxa_atexit --with-dwarf2 --with-tune=generic --enable-languages=c,c++,fortran,lt o,objc,obj-c++ --enable-graphite --enable-threads=posix --enable-libatomic --ena ble-libgomp --disable-libitm --enable-libquadmath --enable-libquadmath-support - -enable-libssp --enable-libgcj-sublibs --disable-java-awt --disable-symvers --wi th-ecj-jar=/usr/share/java/ecj.jar --with-gnu-ld --with-gnu-as --with-cloog-incl ude=/usr/include/cloog-isl --without-libiconv-prefix --without-libintl-prefix -- with-system-zlib Thread model: posix gcc version 4.8.2 (GCC) sunyc@sunyc-wks ~ $ cat 1.cc #include <stdio.h> int main() { char out[255]; snprintf(out, sizeof(out), "%d", 1); return 1; } sunyc@sunyc-wks ~ $ g++ --std=c++11 1.cc 1.cc: In function ‘int main()’: 1.cc:5:36: error: ‘snprintf’ was not declared in this scope snprintf(out, sizeof(out), "%d", 1); ^ sunyc@sunyc-wks ~ $ g++ --std=gnu++0x 1.cc sunyc@sunyc-wks ~ $ ls -lah a.exe -rwxr-xr-x 1 sunyc None 62K Nov 12 10:21 a.exe Cheers. On Tue, Nov 12, 2013 at 1:45 AM, JonY <10walls@gmail.com> wrote: > On 11/12/2013 10:33, Yucong Sun wrote: >> I've tried on both 32bit and 64bit clean cygwin install, the result is >> same. Something is wrong with cygwin's gcc. >> >> my configure script by default uses g++ --std=c++11, this still have >> problem of " no snprintf " , after I replace all snprintf() with >> sprintf() , I've met the same linkage problem again. >> > > Something else is very wrong. > >> g++ --std=gnu++0x "fixes" the snprintf problem, but it still have same >> linkage problem. >> > > Please make a minimalist case, I've tried some basic C++11 features but > I don't get such errors. > > -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: C++11 program link failure under GCC 4.8.2-1 2013-11-12 18:35 ` Yucong Sun @ 2013-11-12 22:30 ` JonY 2013-11-12 23:38 ` Ryan Johnson 2014-03-12 21:05 ` zosrothko 1 sibling, 1 reply; 16+ messages in thread From: JonY @ 2013-11-12 22:30 UTC (permalink / raw) To: cygwin [-- Attachment #1: Type: text/plain, Size: 3353 bytes --] On 11/13/2013 02:35, Yucong Sun wrote: > Good new! I've found the link failure issue, it is caused by "-rdynamic" > > sunyc@sunyc-wks ~ > $ cat 2.cc > #include <deque> > > struct tick_event { > int i; > }; > > int main() { > std::deque<tick_event *> list; > > tick_event *a = new tick_event; > list.push_back(a); > return 0; > } > > sunyc@sunyc-wks ~ > $ g++ -c --std=c++11 -O3 -flto 2.cc -o 2.o > > sunyc@sunyc-wks ~ > $ g++ --std=c++11 -flto -D_GNU_SOURCE -rdynamic -fno-omit-frame-pointer -D_GNU_ > SOURCE -march=native -O3 2.o -o a > Cannot export _ZNSt5dequeIP10tick_eventSaIS1_EE16_M_push_back_auxIJRKS1_EEEvDpOT > _: symbol wrong type (4 vs 3) > collect2: error: ld returned 1 exit status > > > sunyc@sunyc-wks ~ > $ g++ --std=c++11 -flto -D_GNU_SOURCE -fno-omit-frame-pointer -D_GNU_SOURCE -ma > rch=native -O3 2.o -o a > > sunyc@sunyc-wks ~ > $ > > Hope it would help you nail the problem. > -rdynamic shouldn't do anything on Windows, I guess using ELF specific arguments can break things. > > And Here's the test case for snprintf & c++11 > > $ gcc -v > Using built-in specs. > COLLECT_GCC=gcc > COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-cygwin/4.8.2/lto-wrapper.exe > Target: x86_64-pc-cygwin > Configured with: /cygdrive/i/szsz/tmpp/cygwin64/gcc/gcc-4.8.2-1/src/gcc-4.8.2/co > nfigure --srcdir=/cygdrive/i/szsz/tmpp/cygwin64/gcc/gcc-4.8.2-1/src/gcc-4.8.2 -- > prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdi > r=/usr/libexec --datadir=/usr/share --localstatedir=/var --sysconfdir=/etc --lib > dir=/usr/lib --datarootdir=/usr/share --docdir=/usr/share/doc/gcc -C --build=x86 > _64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-pc-cygwin --without-libico > nv-prefix --without-libintl-prefix --enable-shared --enable-shared-libgcc --enab > le-static --enable-version-specific-runtime-libs --enable-bootstrap --disable-__ > cxa_atexit --with-dwarf2 --with-tune=generic --enable-languages=c,c++,fortran,lt > o,objc,obj-c++ --enable-graphite --enable-threads=posix --enable-libatomic --ena > ble-libgomp --disable-libitm --enable-libquadmath --enable-libquadmath-support - > -enable-libssp --enable-libgcj-sublibs --disable-java-awt --disable-symvers --wi > th-ecj-jar=/usr/share/java/ecj.jar --with-gnu-ld --with-gnu-as --with-cloog-incl > ude=/usr/include/cloog-isl --without-libiconv-prefix --without-libintl-prefix -- > with-system-zlib > Thread model: posix > gcc version 4.8.2 (GCC) > > > sunyc@sunyc-wks ~ > $ cat 1.cc > #include <stdio.h> > > int main() { > char out[255]; > snprintf(out, sizeof(out), "%d", 1); > return 1; > } > > sunyc@sunyc-wks ~ > $ g++ --std=c++11 1.cc > 1.cc: In function ‘int main()’: > 1.cc:5:36: error: ‘snprintf’ was not declared in this scope > snprintf(out, sizeof(out), "%d", 1); > ^ > > sunyc@sunyc-wks ~ > $ g++ --std=gnu++0x 1.cc > > sunyc@sunyc-wks ~ > $ ls -lah a.exe > -rwxr-xr-x 1 sunyc None 62K Nov 12 10:21 a.exe > > Cheers. > Right now, it is guarded by: #if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L) Which means non-strict mode and C99 mode, snprintf was not part of C++03. I guess (__cplusplus >= 201103L) needs to be added to newlib. [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 834 bytes --] ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: C++11 program link failure under GCC 4.8.2-1 2013-11-12 22:30 ` JonY @ 2013-11-12 23:38 ` Ryan Johnson 2013-11-12 23:51 ` Yucong Sun 2013-11-13 9:15 ` Corinna Vinschen 0 siblings, 2 replies; 16+ messages in thread From: Ryan Johnson @ 2013-11-12 23:38 UTC (permalink / raw) To: cygwin On 12/11/2013 5:30 PM, JonY wrote: > On 11/13/2013 02:35, Yucong Sun wrote: >> Good new! I've found the link failure issue, it is caused by "-rdynamic" >> >> sunyc@sunyc-wks ~ >> $ cat 2.cc >> #include <deque> >> >> struct tick_event { >> int i; >> }; >> >> int main() { >> std::deque<tick_event *> list; >> >> tick_event *a = new tick_event; >> list.push_back(a); >> return 0; >> } >> >> sunyc@sunyc-wks ~ >> $ g++ -c --std=c++11 -O3 -flto 2.cc -o 2.o >> >> sunyc@sunyc-wks ~ >> $ g++ --std=c++11 -flto -D_GNU_SOURCE -rdynamic -fno-omit-frame-pointer -D_GNU_ >> SOURCE -march=native -O3 2.o -o a >> Cannot export _ZNSt5dequeIP10tick_eventSaIS1_EE16_M_push_back_auxIJRKS1_EEEvDpOT >> _: symbol wrong type (4 vs 3) >> collect2: error: ld returned 1 exit status >> >> >> sunyc@sunyc-wks ~ >> $ g++ --std=c++11 -flto -D_GNU_SOURCE -fno-omit-frame-pointer -D_GNU_SOURCE -ma >> rch=native -O3 2.o -o a >> >> sunyc@sunyc-wks ~ >> $ >> >> Hope it would help you nail the problem. >> > -rdynamic shouldn't do anything on Windows, I guess using ELF specific > arguments can break things. >> And Here's the test case for snprintf & c++11 >> >> $ gcc -v >> Using built-in specs. >> COLLECT_GCC=gcc >> COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-cygwin/4.8.2/lto-wrapper.exe >> Target: x86_64-pc-cygwin >> Configured with: /cygdrive/i/szsz/tmpp/cygwin64/gcc/gcc-4.8.2-1/src/gcc-4.8.2/co >> nfigure --srcdir=/cygdrive/i/szsz/tmpp/cygwin64/gcc/gcc-4.8.2-1/src/gcc-4.8.2 -- >> prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdi >> r=/usr/libexec --datadir=/usr/share --localstatedir=/var --sysconfdir=/etc --lib >> dir=/usr/lib --datarootdir=/usr/share --docdir=/usr/share/doc/gcc -C --build=x86 >> _64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-pc-cygwin --without-libico >> nv-prefix --without-libintl-prefix --enable-shared --enable-shared-libgcc --enab >> le-static --enable-version-specific-runtime-libs --enable-bootstrap --disable-__ >> cxa_atexit --with-dwarf2 --with-tune=generic --enable-languages=c,c++,fortran,lt >> o,objc,obj-c++ --enable-graphite --enable-threads=posix --enable-libatomic --ena >> ble-libgomp --disable-libitm --enable-libquadmath --enable-libquadmath-support - >> -enable-libssp --enable-libgcj-sublibs --disable-java-awt --disable-symvers --wi >> th-ecj-jar=/usr/share/java/ecj.jar --with-gnu-ld --with-gnu-as --with-cloog-incl >> ude=/usr/include/cloog-isl --without-libiconv-prefix --without-libintl-prefix -- >> with-system-zlib >> Thread model: posix >> gcc version 4.8.2 (GCC) >> >> >> sunyc@sunyc-wks ~ >> $ cat 1.cc >> #include <stdio.h> >> >> int main() { >> char out[255]; >> snprintf(out, sizeof(out), "%d", 1); >> return 1; >> } >> >> sunyc@sunyc-wks ~ >> $ g++ --std=c++11 1.cc >> 1.cc: In function âint main()â: >> 1.cc:5:36: error: âsnprintfâ was not declared in this scope >> snprintf(out, sizeof(out), "%d", 1); >> ^ >> >> sunyc@sunyc-wks ~ >> $ g++ --std=gnu++0x 1.cc >> >> sunyc@sunyc-wks ~ >> $ ls -lah a.exe >> -rwxr-xr-x 1 sunyc None 62K Nov 12 10:21 a.exe >> >> Cheers. >> > Right now, it is guarded by: > #if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L) > > Which means non-strict mode and C99 mode, snprintf was not part of > C++03. I guess (__cplusplus >= 201103L) needs to be added to newlib. Yes, this has come up before [1]. Several *printf variants are affected IIRC. [1] http://cygwin.com/ml/cygwin/2012-04/msg00140.html Ryan -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: C++11 program link failure under GCC 4.8.2-1 2013-11-12 23:38 ` Ryan Johnson @ 2013-11-12 23:51 ` Yucong Sun 2013-11-13 9:15 ` Corinna Vinschen 1 sibling, 0 replies; 16+ messages in thread From: Yucong Sun @ 2013-11-12 23:51 UTC (permalink / raw) To: cygwin That's what lead me to use gnu++0x instead. For -rdynamic, apparently it would work for some simple c++ program, just not those with new c++11 features. It would be nice to fix it. Cheers. On Tue, Nov 12, 2013 at 3:37 PM, Ryan Johnson <ryan.johnson@cs.utoronto.ca> wrote: > On 12/11/2013 5:30 PM, JonY wrote: >> >> On 11/13/2013 02:35, Yucong Sun wrote: >>> >>> Good new! I've found the link failure issue, it is caused by "-rdynamic" >>> >>> sunyc@sunyc-wks ~ >>> $ cat 2.cc >>> #include <deque> >>> >>> struct tick_event { >>> int i; >>> }; >>> >>> int main() { >>> std::deque<tick_event *> list; >>> >>> tick_event *a = new tick_event; >>> list.push_back(a); >>> return 0; >>> } >>> >>> sunyc@sunyc-wks ~ >>> $ g++ -c --std=c++11 -O3 -flto 2.cc -o 2.o >>> >>> sunyc@sunyc-wks ~ >>> $ g++ --std=c++11 -flto -D_GNU_SOURCE -rdynamic -fno-omit-frame-pointer >>> -D_GNU_ >>> SOURCE -march=native -O3 2.o -o a >>> Cannot export >>> _ZNSt5dequeIP10tick_eventSaIS1_EE16_M_push_back_auxIJRKS1_EEEvDpOT >>> _: symbol wrong type (4 vs 3) >>> collect2: error: ld returned 1 exit status >>> >>> >>> sunyc@sunyc-wks ~ >>> $ g++ --std=c++11 -flto -D_GNU_SOURCE -fno-omit-frame-pointer >>> -D_GNU_SOURCE -ma >>> rch=native -O3 2.o -o a >>> >>> sunyc@sunyc-wks ~ >>> $ >>> >>> Hope it would help you nail the problem. >>> >> -rdynamic shouldn't do anything on Windows, I guess using ELF specific >> arguments can break things. >>> >>> And Here's the test case for snprintf & c++11 >>> >>> $ gcc -v >>> Using built-in specs. >>> COLLECT_GCC=gcc >>> >>> COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-cygwin/4.8.2/lto-wrapper.exe >>> Target: x86_64-pc-cygwin >>> Configured with: >>> /cygdrive/i/szsz/tmpp/cygwin64/gcc/gcc-4.8.2-1/src/gcc-4.8.2/co >>> nfigure >>> --srcdir=/cygdrive/i/szsz/tmpp/cygwin64/gcc/gcc-4.8.2-1/src/gcc-4.8.2 -- >>> prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin >>> --libexecdi >>> r=/usr/libexec --datadir=/usr/share --localstatedir=/var >>> --sysconfdir=/etc --lib >>> dir=/usr/lib --datarootdir=/usr/share --docdir=/usr/share/doc/gcc -C >>> --build=x86 >>> _64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-pc-cygwin >>> --without-libico >>> nv-prefix --without-libintl-prefix --enable-shared --enable-shared-libgcc >>> --enab >>> le-static --enable-version-specific-runtime-libs --enable-bootstrap >>> --disable-__ >>> cxa_atexit --with-dwarf2 --with-tune=generic >>> --enable-languages=c,c++,fortran,lt >>> o,objc,obj-c++ --enable-graphite --enable-threads=posix >>> --enable-libatomic --ena >>> ble-libgomp --disable-libitm --enable-libquadmath >>> --enable-libquadmath-support - >>> -enable-libssp --enable-libgcj-sublibs --disable-java-awt >>> --disable-symvers --wi >>> th-ecj-jar=/usr/share/java/ecj.jar --with-gnu-ld --with-gnu-as >>> --with-cloog-incl >>> ude=/usr/include/cloog-isl --without-libiconv-prefix >>> --without-libintl-prefix -- >>> with-system-zlib >>> Thread model: posix >>> gcc version 4.8.2 (GCC) >>> >>> >>> sunyc@sunyc-wks ~ >>> $ cat 1.cc >>> #include <stdio.h> >>> >>> int main() { >>> char out[255]; >>> snprintf(out, sizeof(out), "%d", 1); >>> return 1; >>> } >>> >>> sunyc@sunyc-wks ~ >>> $ g++ --std=c++11 1.cc >>> 1.cc: In function ‘int main()’: >>> 1.cc:5:36: error: ‘snprintf’ was not declared in this scope >>> snprintf(out, sizeof(out), "%d", 1); >>> ^ >>> >>> sunyc@sunyc-wks ~ >>> $ g++ --std=gnu++0x 1.cc >>> >>> sunyc@sunyc-wks ~ >>> $ ls -lah a.exe >>> -rwxr-xr-x 1 sunyc None 62K Nov 12 10:21 a.exe >>> >>> Cheers. >>> >> Right now, it is guarded by: >> #if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L) >> >> Which means non-strict mode and C99 mode, snprintf was not part of >> C++03. I guess (__cplusplus >= 201103L) needs to be added to newlib. > > Yes, this has come up before [1]. Several *printf variants are affected > IIRC. > > [1] http://cygwin.com/ml/cygwin/2012-04/msg00140.html > > Ryan > > > -- > Problem reports: http://cygwin.com/problems.html > FAQ: http://cygwin.com/faq/ > Documentation: http://cygwin.com/docs.html > Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple > -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: C++11 program link failure under GCC 4.8.2-1 2013-11-12 23:38 ` Ryan Johnson 2013-11-12 23:51 ` Yucong Sun @ 2013-11-13 9:15 ` Corinna Vinschen 2013-11-13 14:01 ` Christopher Faylor 1 sibling, 1 reply; 16+ messages in thread From: Corinna Vinschen @ 2013-11-13 9:15 UTC (permalink / raw) To: cygwin [-- Attachment #1: Type: text/plain, Size: 742 bytes --] On Nov 12 18:37, Ryan Johnson wrote: > On 12/11/2013 5:30 PM, JonY wrote: > >Right now, it is guarded by: > >#if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L) > > > >Which means non-strict mode and C99 mode, snprintf was not part of > >C++03. I guess (__cplusplus >= 201103L) needs to be added to newlib. > Yes, this has come up before [1]. Several *printf variants are > affected IIRC. > > [1] http://cygwin.com/ml/cygwin/2012-04/msg00140.html I wouldn't mind to see patch submissions fixing stuff like that on the newlib mailing list. Not at all. Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat [-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: C++11 program link failure under GCC 4.8.2-1 2013-11-13 9:15 ` Corinna Vinschen @ 2013-11-13 14:01 ` Christopher Faylor 2013-11-13 15:19 ` Corinna Vinschen 0 siblings, 1 reply; 16+ messages in thread From: Christopher Faylor @ 2013-11-13 14:01 UTC (permalink / raw) To: cygwin On Wed, Nov 13, 2013 at 10:15:02AM +0100, Corinna Vinschen wrote: >On Nov 12 18:37, Ryan Johnson wrote: >> On 12/11/2013 5:30 PM, JonY wrote: >> >Right now, it is guarded by: >> >#if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L) >> > >> >Which means non-strict mode and C99 mode, snprintf was not part of >> >C++03. I guess (__cplusplus >= 201103L) needs to be added to newlib. >> Yes, this has come up before [1]. Several *printf variants are >> affected IIRC. >> >> [1] http://cygwin.com/ml/cygwin/2012-04/msg00140.html > >I wouldn't mind to see patch submissions fixing stuff like that on the >newlib mailing list. Not at all. What an odd notion. cgf -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: C++11 program link failure under GCC 4.8.2-1 2013-11-13 14:01 ` Christopher Faylor @ 2013-11-13 15:19 ` Corinna Vinschen 2013-11-13 15:51 ` Christopher Faylor 0 siblings, 1 reply; 16+ messages in thread From: Corinna Vinschen @ 2013-11-13 15:19 UTC (permalink / raw) To: cygwin [-- Attachment #1: Type: text/plain, Size: 959 bytes --] On Nov 13 09:01, Christopher Faylor wrote: > On Wed, Nov 13, 2013 at 10:15:02AM +0100, Corinna Vinschen wrote: > >On Nov 12 18:37, Ryan Johnson wrote: > >> On 12/11/2013 5:30 PM, JonY wrote: > >> >Right now, it is guarded by: > >> >#if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L) > >> > > >> >Which means non-strict mode and C99 mode, snprintf was not part of > >> >C++03. I guess (__cplusplus >= 201103L) needs to be added to newlib. > >> Yes, this has come up before [1]. Several *printf variants are > >> affected IIRC. > >> > >> [1] http://cygwin.com/ml/cygwin/2012-04/msg00140.html > > > >I wouldn't mind to see patch submissions fixing stuff like that on the > >newlib mailing list. Not at all. > > What an odd notion. Yeah, I'm that crazy sometimes. Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat [-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: C++11 program link failure under GCC 4.8.2-1 2013-11-13 15:19 ` Corinna Vinschen @ 2013-11-13 15:51 ` Christopher Faylor 0 siblings, 0 replies; 16+ messages in thread From: Christopher Faylor @ 2013-11-13 15:51 UTC (permalink / raw) To: cygwin On Wed, Nov 13, 2013 at 04:19:15PM +0100, Corinna Vinschen wrote: >On Nov 13 09:01, Christopher Faylor wrote: >> On Wed, Nov 13, 2013 at 10:15:02AM +0100, Corinna Vinschen wrote: >> >On Nov 12 18:37, Ryan Johnson wrote: >> >> On 12/11/2013 5:30 PM, JonY wrote: >> >> >Right now, it is guarded by: >> >> >#if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L) >> >> > >> >> >Which means non-strict mode and C99 mode, snprintf was not part of >> >> >C++03. I guess (__cplusplus >= 201103L) needs to be added to newlib. >> >> Yes, this has come up before [1]. Several *printf variants are >> >> affected IIRC. >> >> >> >> [1] http://cygwin.com/ml/cygwin/2012-04/msg00140.html >> > >> >I wouldn't mind to see patch submissions fixing stuff like that on the >> >newlib mailing list. Not at all. >> >> What an odd notion. > >Yeah, I'm that crazy sometimes. Yeah, I know. Crazy cat lady. cgf -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: C++11 program link failure under GCC 4.8.2-1 2013-11-12 18:35 ` Yucong Sun 2013-11-12 22:30 ` JonY @ 2014-03-12 21:05 ` zosrothko 1 sibling, 0 replies; 16+ messages in thread From: zosrothko @ 2014-03-12 21:05 UTC (permalink / raw) To: cygwin Hi Below are the compile time __STRICT_ANSI__ defines for various standards supported by g++ FrancisANDRE@idefix /usr/include $ gcc -xc++ -std=c++0x -dM -E - < /dev/null | grep ANSI #define __STRICT_ANSI__ 1 FrancisANDRE@idefix /usr/include $ gcc -xc++ -std=c++11 -dM -E - < /dev/null | grep ANSI #define __STRICT_ANSI__ 1 FrancisANDRE@idefix /usr/include $ gcc -xc++ -std=gnu++11 -dM -E - < /dev/null | grep ANSI FrancisANDRE@idefix /usr/include $ gcc -xc++ -std=c++98 -dM -E - < /dev/null | grep ANSI #define __STRICT_ANSI__ 1 All but c++11 define __STRICT_ANSI__. That's why your sample does not compile. This a issue with the cygwin includes that should provide snprintf for c++11 also not only for other standards. -- View this message in context: http://cygwin.1069669.n5.nabble.com/C-11-program-link-failure-under-GCC-4-8-2-1-tp104247p107069.html Sent from the Cygwin list mailing list archive at Nabble.com. -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: C++11 program link failure under GCC 4.8.2-1 2013-11-11 23:38 ` Yucong Sun 2013-11-12 2:34 ` Yucong Sun @ 2013-11-12 9:44 ` JonY 1 sibling, 0 replies; 16+ messages in thread From: JonY @ 2013-11-12 9:44 UTC (permalink / raw) To: cygwin [-- Attachment #1: Type: text/plain, Size: 392 bytes --] On 11/12/2013 07:37, Yucong Sun wrote: > Yes, the sha1 matches. > > sunyc@sunyc-wks /lib/gcc/i686-pc-cygwin/4.8.2 > $ sha1sum.exe libstdc++.* > f4dfadfddade3aceaf4852cd5db31372ab7ef0d1 *libstdc++.a > 963e2a697c3a1a7d036d975b07f4c408bbd1cb2d *libstdc++.dll.a > > Also I couldn't find GLIB_xxx version number in libstdc++.a Those are ELF versioning, Windows does not have it. [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 834 bytes --] ^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2014-03-12 19:12 UTC | newest] Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2013-11-11 21:17 C++11 program link failure under GCC 4.8.2-1 Yucong Sun [not found] ` <52815780.2010006@gmail.com> 2013-11-11 22:28 ` JonY 2013-11-11 23:38 ` Yucong Sun 2013-11-12 2:34 ` Yucong Sun 2013-11-12 2:38 ` Yucong Sun 2013-11-12 9:46 ` JonY 2013-11-12 18:35 ` Yucong Sun 2013-11-12 22:30 ` JonY 2013-11-12 23:38 ` Ryan Johnson 2013-11-12 23:51 ` Yucong Sun 2013-11-13 9:15 ` Corinna Vinschen 2013-11-13 14:01 ` Christopher Faylor 2013-11-13 15:19 ` Corinna Vinschen 2013-11-13 15:51 ` Christopher Faylor 2014-03-12 21:05 ` zosrothko 2013-11-12 9:44 ` JonY
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).