GCC and extension compilation issues (was: GCC fails on Windows 7 and hpricot install issues)

1,082 views
Skip to first unread message

Luis Lavena

unread,
Mar 7, 2010, 5:51:43 AM3/7/10
to rubyin...@googlegroups.com
Hello,

I'm going to start a new thread on this subject, since was getting a
bit complicated for me to follow both threads of these issues.

The threads I'm talking about are:

http://groups.google.com/group/rubyinstaller/browse_thread/thread/b56521e55fd2b760
http://groups.google.com/group/rubyinstaller/browse_thread/thread/1b246533dff3d4be

Basically:

We need to determine if the issue lies in GCC, Ruby provided
headers/libraries or the Gem is doing something wrong.

1) Try to build a simple gem:

C:\Ruby>gem install win32console --pre --platform=ruby --debug -V

If that fails, please collect the output and generate a gist[1] or a pastie[2].

2) Does the following extension compiles?

http://gist.github.com/322066

If so, please generate a gist [1] or pastie[2] with the output

If not, let's continue with next step

3) Does the following C code compiles?

http://gist.github.com/324305

Please try first "compile.bat" and then "compile-ruby.bat"

If it fails, please collect the output of each individually and
generate a pastie/gist of them.

====

If all the above scenarios worked, then means the gem that you tried
to install has some issues.

In one of the reported cases, the gem that had issues was "linecache19":

http://rubygems.org/gems/linecache19

Which is a dependency of ruby-debug-ide19.

As you can see from there, a dependency of linecache19 is ruby_core_source:

http://rubygems.org/gems/ruby_core_source

And the purpose of that gem is download the Ruby source code and
extract into a folder of Ruby so "linecache19" is able to be compiled.
If the download and extraction of the ruby source code fails, then
linecache19 will fail to search for "ruby.h", as reported before.

This is not a bug of RubyInstaller, but instead could be associated
with a network issue in your end, and I would advise get in touch with
the ruby_core_source gem author to ensure that if the download of
source fails, the gem compilation should not continue (provide a
better error message for example).

In the case of hpricot gem, I believe there is something else in the
system affecting that I cannot reproduce, either a trojan that is
affecting dll/exe generation or something similar. If that is the
case, it should raise a issue in any of the previous 3 tests I've
mentioned.

Please let me know if any of this makes sense and provide me the
output of each individual scenario in case of failure.

I'll try to help workout these issues, as I guess others may suffer
similar situations.

Thank you.

[1] http://gist.github.com/
[2] http://pastie.org/
--
Luis Lavena
AREA 17
-
Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry

Juan Felipe Alvarez Saldarriaga

unread,
Mar 7, 2010, 12:14:04 PM3/7/10
to rubyin...@googlegroups.com
Hey Luis,

Thanks for helping us, so, I can't compile win32console (gcc crash, nothing new :D) there's the outputs:


compile-ruby.bat says that can't find ruby.h :S, here's my PATH:

C:\Users\jfalvarez>set PATH
Path=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32
\WindowsPowerShell\v1.0\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program F
iles (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\TortoiseSVN\bin
;C:\Lib\grails-1.2.1\bin;C:\Program Files (x86)\GtkSharp\2.12\bin;C:\Lib\apache-
maven-2.2.1\bin;C:\Ruby\bin
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.RB;.RBW

Thanks.

Luis Lavena

unread,
Mar 7, 2010, 2:05:27 PM3/7/10
to rubyin...@googlegroups.com
On Sun, Mar 7, 2010 at 6:14 PM, Juan Felipe Alvarez Saldarriaga
<neb...@gmail.com> wrote:
> Hey Luis,
> Thanks for helping us, so, I can't compile win32console (gcc crash, nothing
> new :D) there's the outputs:
>
> 1) http://pastie.org/858324
> 2) http://pastie.org/858330
> 3) http://pastie.org/858335
>
> compile-ruby.bat says that can't find ruby.h :S, here's my PATH:

There is a comment inside compile-ruby, you need to change the PATH to
where your Ruby installation is.

> C:\Users\jfalvarez>set PATH

What is the output of "gem env"?

Juan Felipe Alvarez Saldarriaga

unread,
Mar 7, 2010, 2:49:38 PM3/7/10
to rubyin...@googlegroups.com
Sorry, didn't see it:


gem env:

Luis Lavena

unread,
Mar 8, 2010, 3:07:56 AM3/8/10
to rubyin...@googlegroups.com
On Sun, Mar 7, 2010 at 8:49 PM, Juan Felipe Alvarez Saldarriaga
<neb...@gmail.com> wrote:
> Sorry, didn't see it:
> 3) http://pastie.org/858487
> gem env:
> http://pastie.org/858490
>

Can you please open the file rbconfig.rb, located in
"lib/ruby/1.8/i386-mingw32" folder of your ruby installation.

Search for CFLAGS (line 97), and change:

"-g -O2 "

for:

"-v -g -O2 "

(notice the space at the end, keep it that way)

Now, try to install win32console gem again and please build a pastie
of the output.

It seems that it compiles simple stuff but it segfault when
complicated things are requested.

May I know what type of Antivirus Software do you have installed?

Thank you and apologize for the back and forth.

Thyresias

unread,
Mar 8, 2010, 8:26:13 AM3/8/10
to RubyInstaller
Here is the requested output:
test 1: http://pastie.org/859447 (failed)
test 2: http://pastie.org/859448 (failed)
test 3: http://pastie.org/859450 (success)

my antivirus is NOD32 v4. Notice that at home, on Windows 7 x64,
everything works fine with the same antivirus...

On 8 mar, 09:07, Luis Lavena <luislav...@gmail.com> wrote:
> On Sun, Mar 7, 2010 at 8:49 PM, Juan Felipe Alvarez Saldarriaga
>

Luis Lavena

unread,
Mar 8, 2010, 8:31:51 AM3/8/10
to rubyin...@googlegroups.com
On Mon, Mar 8, 2010 at 2:26 PM, Thyresias <thyr...@gmail.com> wrote:
> Here is the requested output:
> test 1: http://pastie.org/859447 (failed)

In here the error you're getting is not from the win32console compile
itself, but from RubyGems not being able to download the gem.

Please download manually from here:

http://rubygems.org/gems/win32console/versions/1.3.0.beta2

And install locally with:

gem install win32console-1.3.0.beta2.gem --debug -V

>
> my antivirus is NOD32 v4. Notice that at home, on Windows 7 x64,
> everything works fine with the same antivirus...
>

I'm running out of logic options on why this is happening to you. Can
you email me privately so we can arrange a remote/shared screen
session? I'm located CET timezone right now, but we can manage to get
things working.

Thank you.

Thyresias

unread,
Mar 8, 2010, 9:43:12 AM3/8/10
to RubyInstaller
> gem install win32console-1.3.0.beta2.gem --debug -V
The gem won't install, same error:
http://pastie.org/859557
Private mail sent.
-- Thierry

Juan Felipe Alvarez Saldarriaga

unread,
Mar 8, 2010, 6:20:36 PM3/8/10
to RubyInstaller
Hey Luis and Thyresias,

@Thyresias I have Windows 7 x64 and can't compile gems :S.

I modify the rbconfig.rb file and this is the output (can't compile
native gem):
http://pastie.org/860482

I donwload the gem and this is the output (can't compile native gem):
http://pastie.org/860487

Hope this help.

Alexey Borzenkov

unread,
Mar 9, 2010, 12:12:34 AM3/9/10
to rubyin...@googlegroups.com
On Tue, Mar 9, 2010 at 2:20 AM, Juan Felipe Alvarez Saldarriaga
<neb...@gmail.com> wrote:
> I modify the rbconfig.rb file and this is the output (can't compile
> native gem):
> http://pastie.org/860482
>
> I donwload the gem and this is the output (can't compile native gem):
> http://pastie.org/860487
>
> Hope this help.

I think what we might be seing here is *not* gcc crashing, but make
crashing when trying to invoke gcc.

Luis Lavena

unread,
Mar 9, 2010, 2:13:29 AM3/9/10
to rubyin...@googlegroups.com

Well, if you look at this:

"
gcc -I. -I/C/Ruby/lib/ruby/1.8/i386-mingw32 -I/C/Ruby/lib/ruby/1.8/i386-mingw32
-I. -v -g -O2 -c Console.c
"

and then the segmentation fault, it may be gcc since is not showing
the common output that does when verbose is enabled.

I got a recommendation from MinGW guys:

Change the compile options (CFLAGS) to this:

-O0 -Wall

And try again to log the output.

Juan Felipe / Thyresias, can you try change that in rbconfig.rb one
last time and let us know?

Thyresias

unread,
Mar 9, 2010, 5:54:49 AM3/9/10
to RubyInstaller
Changed config.rb as requested, but no luck:
http://pastie.org/861124
Thanks for your time, Luis.
-- Thierry

Alexey Borzenkov

unread,
Mar 9, 2010, 1:56:49 PM3/9/10
to rubyin...@googlegroups.com
On Tue, Mar 9, 2010 at 10:13 AM, Luis Lavena <luisl...@gmail.com> wrote:
> and then the segmentation fault, it may be gcc since is not showing
> the common output that does when verbose is enabled.

Ah, yes. I actually missed the fact that make is the one showing us
the error code. So it is gcc.

It just seems weird to me, because unlike msys/make (which might be
sensitive to BLODA in fork and other emulation functions), gcc is a
normal win32 application and shouldn't behave like this. :-/ It could
be interesting to debug to see where exactly this happens...

Juan Felipe / Thyresias, if you go to the unpacked gem directory in
your ruby command prompt and type:

C:\...> gcc -I. -I/C/Ruby/lib/ruby/1.8/i386-mingw32
-I/C/Ruby/lib/ruby/1.8/i386-mingw32 -I. -g -O0 -Wall -c Console.c

Would it crash or would it succeed?

Juan Felipe Alvarez Saldarriaga

unread,
Mar 9, 2010, 7:18:45 PM3/9/10
to RubyInstaller
Hey Luis and Alexey,

So, I change CFLAGS and this is the output:

1) http://pastie.org/862393 // Remote gem
2) http://pastie.org/862395 // Local gem

Alexey, look the output of your command, still, ruby.h is not found:
http://pastie.org/862399

Thanks for your help.

On Mar 9, 1:56 pm, Alexey Borzenkov <sna...@gmail.com> wrote:

Luis Lavena

unread,
Mar 9, 2010, 7:57:24 PM3/9/10
to rubyin...@googlegroups.com
On Wed, Mar 10, 2010 at 1:18 AM, Juan Felipe Alvarez Saldarriaga
<neb...@gmail.com> wrote:
> Hey Luis and Alexey,
>
> So, I change CFLAGS and this is the output:
>
> 1) http://pastie.org/862393 // Remote gem
> 2) http://pastie.org/862395 // Local gem
>
> Alexey, look the output of your command, still, ruby.h is not found:
> http://pastie.org/862399
>

Can you try changing /C/Ruby for C:/Ruby

And try again?

I'm very disconcerted by these two bugs you guys are experiencing, and
there are still almost 1 month until April's Fools.

Juan Felipe Alvarez Saldarriaga

unread,
Mar 9, 2010, 9:45:23 PM3/9/10
to rubyin...@googlegroups.com
Hey Luis,


Thanks.

Alexey Borzenkov

unread,
Mar 10, 2010, 12:31:12 AM3/10/10
to rubyin...@googlegroups.com
On Wed, Mar 10, 2010 at 5:45 AM, Juan Felipe Alvarez Saldarriaga
<neb...@gmail.com> wrote:
> Hey Luis,
> Look: http://pastie.org/862554
> Thanks.

So, gcc alone works, but invoked via make crashes, is that it? :-/

Ok, now could you maybe try this? Add gcc\...\bin and msys\...\bin
directories to your PATH (I'm afraid there's no command to do that in
current devkit, you will have to do it manually), e.g.:

set DEVKIT=C:\Ruby\devkit
set PATH=%DEVKIT%\gcc\3.4.5\bin;%DEVKIT%\msys\1.0.11\bin

And then execute this:

bash -c "gcc -I. -I/C/Ruby/lib/ruby/1.8/i386-mingw32
-I/C/Ruby/lib/ruby/1.8/i386-mingw32 -I. -O0 -Wall -c Console.c"

I'm starting to suspect that it might be bash crashing here, since
make executes commands via the shell and gcc works, it's the only
point of failure that's left. :-/

Luis Lavena

unread,
Mar 10, 2010, 3:16:00 AM3/10/10
to rubyin...@googlegroups.com

The thing is that Juan situation differs from Thyresias as he doesn't
get segfaults, only missing ruby.h file.

The two issues are completely unrelated and I'm getting really
frustrated by them.

Thyresias

unread,
Mar 10, 2010, 5:25:28 AM3/10/10
to RubyInstaller
> Juan Felipe / Thyresias, if you go to the unpacked gem directory in
> your ruby command prompt and type:
>
> C:\...> gcc -I. -I/C/Ruby/lib/ruby/1.8/i386-mingw32
> -I/C/Ruby/lib/ruby/1.8/i386-mingw32 -I.   -g -O0 -Wall   -c Console.c
>
> Would it crash or would it succeed?

It succeeds ! 0_0

Thyresias

unread,
Mar 10, 2010, 5:53:49 AM3/10/10
to RubyInstaller
> It succeeds ! 0_0

Found the culprit in my case: it is make.
In my configuration, the HOME environment variable is set (by me) to c:
\home\thierry, while HOMEPATH is set (by Windows) to c:\profiles
\thierry.
In that case, make does not fork correctly, probably. Anyway,
unsetting HOME (leaving just HOMEPATH) solves the problem.

Thanks to Thibaut Barrère for helping me on this!

-- Thierry

Luis Lavena

unread,
Mar 10, 2010, 9:01:40 AM3/10/10
to rubyin...@googlegroups.com

Just a followup on this case.

We found (Thyresias, Thibaut and myself) that the problem was some
bashrc file residing inside HOME the culprit.

Inside the file, there were two unset: TMP and TEMP

make doesn't not like not finding a temporary environment variable and
just generates Error 3.

Once these two sets back, things started to work.

One less bug, one still one to knock out.

Going to check over GNU if this is a previous encountered issue and if
not, report it so make gives something more useful than "Error 3" or
"Error 255"

BTW: Nice to meet you guys today!

Thyresias

unread,
Mar 10, 2010, 4:13:15 PM3/10/10
to RubyInstaller
> BTW: Nice to meet you guys today!
Shared pleasure!
Thanks for your help!
-- Thierry

Juan Felipe Alvarez Saldarriaga

unread,
Mar 10, 2010, 11:22:42 PM3/10/10
to rubyin...@googlegroups.com
Hey guys,

So, I try Alexey's bash thing and still doesn't work:

http://pastie.org/864499

My env variables are inside this pastie too.

Thanks.

Thibaut Barrère

unread,
Mar 11, 2010, 4:04:14 AM3/11/10
to RubyInstaller
> Going to check over GNU if this is a previous encountered issue and if
> not, report it so make gives something more useful than "Error 3" or
> "Error 255"

+1 - would save hours of tracking for people later on :)

> BTW: Nice to meet you guys today!

Same!

cheers,

-- Thibaut

Luis Lavena

unread,
Mar 11, 2010, 4:33:56 AM3/11/10
to rubyin...@googlegroups.com
On Thu, Mar 11, 2010 at 5:22 AM, Juan Felipe Alvarez Saldarriaga
<neb...@gmail.com> wrote:
> Hey guys,
>
> So, I try Alexey's bash thing and still doesn't work:
>
> http://pastie.org/864499
>

Well, the thing worked, there is no error in the output of GCC
compilation process.

Now, this problem that "it cannot find ruby.h" is completely different
from the about abnormal program termination.

Can you list (dir /a) all the files from your %USERPROFILE% folder?

We are interested in the files starting with dots (.gemrc .bash_profile, etc.)

Thank you.

Juan Felipe Alvarez Saldarriaga

unread,
Mar 11, 2010, 6:43:58 AM3/11/10
to rubyin...@googlegroups.com
Hey Luis,

Yes, sorry, the thing worked ;), but still, I can't compile gems :S,
look: http://pastie.org/864793 actually I have cygwin installed on
Windows 7 and I change cygwin's HOME from /home/jfalvarez to
/cygdrive/c/Users/jfalvarez

Thanks.

Luis Lavena

unread,
Mar 11, 2010, 8:26:47 AM3/11/10
to rubyin...@googlegroups.com
On Thu, Mar 11, 2010 at 12:43 PM, Juan Felipe Alvarez Saldarriaga
<neb...@gmail.com> wrote:
> Hey Luis,
>
> Yes, sorry, the thing worked ;), but still, I can't compile gems :S,
> look: http://pastie.org/864793 actually I have cygwin installed on
> Windows 7 and I change cygwin's HOME from /home/jfalvarez to
> /cygdrive/c/Users/jfalvarez
>

Please try this:

* Rename .bash_profile and .bashrc to .bash_profile.bak and .bashrc.bak
* Remove any cygwin path that you may have in your default PATH, the
results from "where sh", "where gcc" and "where make" should point to
the DevKit batch files, not cygwin ones.

Once you've cleared that out, try gem installation again.

Cygwin does weird things with the environment that mess up things for
msys. We use msys for make, and is the one having issues to resolve
the proper paths.

Alexey Borzenkov

unread,
Mar 11, 2010, 3:12:31 PM3/11/10
to rubyin...@googlegroups.com
On Thu, Mar 11, 2010 at 4:26 PM, Luis Lavena <luisl...@gmail.com> wrote:
> Please try this:
>
> * Rename .bash_profile and .bashrc to .bash_profile.bak and .bashrc.bak
> * Remove any cygwin path that you may have in your default PATH, the
> results from "where sh", "where gcc" and "where make" should point to
> the DevKit batch files, not cygwin ones.
>
> Once you've cleared that out, try gem installation again.
>
> Cygwin does weird things with the environment that mess up things for
> msys. We use msys for make, and is the one having issues to resolve
> the proper paths.

Or, if the issue is really TMP, one could try creating /tmp, i.e.
empty tmp directory inside devkit\msys\1.0.11...

Juan Felipe Alvarez Saldarriaga

unread,
Mar 12, 2010, 9:40:34 PM3/12/10
to rubyin...@googlegroups.com
Hey Luis and Alexey,

Well, finally I can build ruby gems :D woo! :) I rename .bash_profile
and .bashrc and everything works fine, pretty odd eh? :S so, I'll
change my cygwin's HOME path and see what happen.

Thanks.

Luis Lavena

unread,
Mar 13, 2010, 8:00:10 AM3/13/10
to rubyin...@googlegroups.com
On Sat, Mar 13, 2010 at 3:40 AM, Juan Felipe Alvarez Saldarriaga
<neb...@gmail.com> wrote:
> Hey Luis and Alexey,
>
> Well, finally I can build ruby gems :D woo! :) I rename .bash_profile
> and .bashrc and everything works fine, pretty odd eh? :S so, I'll
> change my cygwin's HOME path and see what happen.
>

Awesome to hear this!

Added to the Troubleshooting wiki page:

http://wiki.github.com/oneclick/rubyinstaller/troubleshooting

> Thanks.
>

Thanks to you for your patience and willingness to help us find the
root of the issue!

Regards,

Reply all
Reply to author
Forward
0 new messages