C++11 program link failure under GCC 4.8.2-1

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

C++11 program link failure under GCC 4.8.2-1

Yucong Sun
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

Reply | Threaded
Open this post in threaded view
|

Re: C++11 program link failure under GCC 4.8.2-1

JonY
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?



signature.asc (851 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: C++11 program link failure under GCC 4.8.2-1

Yucong Sun
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 <[hidden email]> 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

Reply | Threaded
Open this post in threaded view
|

Re: C++11 program link failure under GCC 4.8.2-1

Yucong Sun
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 <[hidden email]> 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 <[hidden email]> 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

Reply | Threaded
Open this post in threaded view
|

Re: C++11 program link failure under GCC 4.8.2-1

Yucong Sun
(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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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

Reply | Threaded
Open this post in threaded view
|

Re: C++11 program link failure under GCC 4.8.2-1

JonY
In reply to this post by Yucong Sun
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.



signature.asc (851 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: C++11 program link failure under GCC 4.8.2-1

JonY
In reply to this post by Yucong Sun
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.



signature.asc (851 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: C++11 program link failure under GCC 4.8.2-1

Yucong Sun
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 <[hidden email]> 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

Reply | Threaded
Open this post in threaded view
|

Re: C++11 program link failure under GCC 4.8.2-1

JonY
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.



signature.asc (851 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: C++11 program link failure under GCC 4.8.2-1

Ryan Johnson-10
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

Reply | Threaded
Open this post in threaded view
|

Re: C++11 program link failure under GCC 4.8.2-1

Yucong Sun
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
<[hidden email]> 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

Reply | Threaded
Open this post in threaded view
|

Re: C++11 program link failure under GCC 4.8.2-1

Corinna Vinschen-2
In reply to this post by Ryan Johnson-10
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

attachment0 (853 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: C++11 program link failure under GCC 4.8.2-1

Christopher Faylor-8
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

Reply | Threaded
Open this post in threaded view
|

Re: C++11 program link failure under GCC 4.8.2-1

Corinna Vinschen-2
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

attachment0 (853 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: C++11 program link failure under GCC 4.8.2-1

Christopher Faylor-8
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

Reply | Threaded
Open this post in threaded view
|

Re: C++11 program link failure under GCC 4.8.2-1

zosrothko
In reply to this post by Yucong Sun
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.