.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Programming (http://forums.bots-united.com/forumdisplay.php?f=25)
-   -   cygwin gcc -O2 problem (http://forums.bots-united.com/showthread.php?t=4662)

markus_heiden 10-11-2005 16:55

cygwin gcc -O2 problem
 
Hi,

when I compile with the current cygwin g++ (v.3.4.4) I get 'strange' errors in the link step when I use the -O2 option for compiling. This happens since I use the stl.

Example:
g++ -mno-cygwin -w -O2 -march=i686 -I<some include dir...> -c -o xxx.o xxx.cpp
g++ -mno-cygwin -fPIC -shared -o my.dll xxx.o yyy.o....

The linker then shows multiple errors like this:
...undefined reference to `std::basic_filebuf<char, std::char_traits<char> >::_close()'


This does not happen, when I do not use the -O2 option. Then everything works fine. What am I doing wrong?

Markus

Whistler 11-11-2005 07:19

Re: cygwin gcc -O2 problem
 
I'm using MinGW and it's no problem. Have you tried using the "dllwrap" command?

markus_heiden 11-11-2005 13:01

Re: cygwin gcc -O2 problem
 
Hi Whistler,

Quote:

Originally Posted by Whistler
I'm using MinGW and it's no problem. Have you tried using the "dllwrap" command?

I have never tried the dllwrap command. Whatfor is it good? I only use the dlltool.

Someone got any clues where the problem with the -O2 option is?

Markus

Pierre-Marie Baty 12-11-2005 20:27

Re: cygwin gcc -O2 problem
 
It suggests a faulty STL implementation in GCC... Try downgrading the optimization level ?

markus_heiden 16-11-2005 01:20

Re: cygwin gcc -O2 problem
 
Yes, I tried already leaving -O2 away, that fixes the problem. But I want to optimize the binary, so that is no real solution. Maybe waiting for a new gcc version is the only option...

Markus

Whistler 17-11-2005 03:18

Re: cygwin gcc -O2 problem
 
PHP Code:

k25@xg25 /cygdrive/c
g++ -O2 --o 1.o 1.cpp

k25
@xg25 /cygdrive/c
g++ -fPIC -shared -o 1.dll 1.o 

well I just can't resemble your problem here... the above thing runs well and no error. Here's my 1.cpp:
PHP Code:

#include <iostream>
using namespace std;

__declspec(dllexportint test1()
{
  
cout << "test1" << endl;



markus_heiden 25-11-2005 17:13

Re: cygwin gcc -O2 problem
 
The problem seems to come from the stl (I think). Since you use no stl in your example, there is no problem.

Strange is, that most of the stl code compiles fine with -O2, just some parts show this error.

Markus

sfx1999 25-11-2005 17:33

Re: cygwin gcc -O2 problem
 
Try using -O1 on the files that have the error.

jeefo 25-11-2005 21:57

Re: cygwin gcc -O2 problem
 
Quote:

Since you use no stl in your example
And what about cout << "test1" << endl;
:)

@$3.1415rin 26-11-2005 11:33

Re: cygwin gcc -O2 problem
 
that's std c++ library, stl would be rather std::list, vector whatever

markus_heiden 26-11-2005 13:59

Re: cygwin gcc -O2 problem
 
-O1 works fine. What may be the problem now?

Markus

Whistler 27-11-2005 01:29

Re: cygwin gcc -O2 problem
 
well, try the STLPort or the latest gcc SVN snapshot and if problem disappeared then it's a gcc bug.

markus_heiden 27-11-2005 17:02

Re: cygwin gcc -O2 problem
 
OK, that's too much for me :-) I'll better wait for a new cygwin gcc package...

Thanks for your help.

Markus


All times are GMT +2. The time now is 10:44.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.