Fox, Solaris 2.9 problem

Thanks! That got me further, but still no luck. Any ideas on this one?

<snip>

opengl_wrap.cpp: In function `VALUE FXGLViewer_readPixels(FXGLViewer*, int,
   int, int, int)':
opengl_wrap.cpp:688: `alloca' undeclared (first use this function)
opengl_wrap.cpp:688: (Each undeclared identifier is reported only once for
each
   function it appears in.)

Hmmm... I wonder if this is an error in the Ruby header files? Here's the
offending line that it's trying to compile in FXRuby's opengl_wrap.cpp:

    char *charBuffer = ALLOCA_N(char, size);

ALLOCA_N() is a macro defined in "ruby.h" as follows:

    #define ALLOCA_N(type, n) (type *) alloca(sizeof(type)*(n))

and so when this macro is expanded it expects to have seen a declaration of
the C function alloca() somewhere earlier in the code. If you look a little
higher up in "ruby.h", before the definition of ALLOCA_N(), you'll see the
lines:

    #if defined(HAVE_ALLOCA_H) && !defined(__GNUC__)
    #include <alloca.h>
    #endif

and I believe that this is where the declaration of alloca() *should* come
into the picture. So it seems that the only reasons this wouldn't occur are:

1. If HAVE_ALLOCA_H isn't defined; or,
2. If HAVE_ALLOCA_H is defined, but __GNUC__ is too.

You can check the "config.h" header file for your Ruby installation (should
be in the same place as the "ruby.h" header file) to confirm that
HAVE_ALLOCA_H is defined; I'm pretty sure you'll find that it is. But since
you're compiling with GCC, the __GNUC__ symbol should also be declared (GCC
does this internally) and so we won't actually include <alloca.h> at this point.

This left me wondering where Ruby is expecting to find a declaration for
alloca() in this case. So I brought up the man page for alloca() [under
Linux] and learned that "... by default the glibc version of <stdlib.h>
includes <alloca.h> and that contains [a line that aliases alloca to a
built-in, inlined function]".

My initial guess, based on what you're seeing when trying to build the code
using GCC but under Solaris 2.x, is that Ruby's header file magic assumes
that since it has already included <stdlib.h> and you're compiling with GCC,
there's no need to include <alloca.h>. That is certainly true for Linux,
where we are indeed linking against the GNU C library, but I'm not sure if
it's also true for Solaris. In other words, it's possible that your code
gets linked against the Solaris C runtime library instead.

Were you waiting for a conclusion? :wink:

I don't have one (and that's why I'm Cc'ing this to the ML). I might
initially try changing those lines in "ruby.h" from this:

    #if defined(HAVE_ALLOCA_H) && !defined(__GNUC__)
    #include <alloca.h>
    #endif

to this:

    #if defined(HAVE_ALLOCA_H)
    #include <alloca.h>
    #endif

which basically says, "if you've got an <alloca.h> header file, include it
unconditionally". Then try to pick up the compile of FXRuby where it left
off and see what happens.

Hope this gives you something to go on,

Lyle

···

On Thu, 07 Nov 2002 08:33:28 -0700, Daniel Berger <djberge@qwest.com> wrote :

lyle@knology.netlyle@knology.net writes:

Were you waiting for a conclusion? :wink:

I don’t have one (and that’s why I’m Cc’ing this to the ML). I might
initially try changing those lines in “ruby.h” from this:

#if defined(HAVE_ALLOCA_H) && !defined(__GNUC__)
#include <alloca.h>
#endif

to this:

#if defined(HAVE_ALLOCA_H)
#include <alloca.h>
#endif

which basically says, “if you’ve got an <alloca.h> header file, include it
unconditionally”. Then try to pick up the compile of FXRuby where it left
off and see what happens.

    I had to do this change on solaris 8. Then FXruby compiles just fine.
  • Ville

<snip>

    #if defined(HAVE_ALLOCA_H) && !defined(__GNUC__)
    #include <alloca.h>
    #endif

to this:

    #if defined(HAVE_ALLOCA_H)
    #include <alloca.h>
    #endif

which basically says, "if you've got an <alloca.h> header file, include it
unconditionally". Then try to pick up the compile of FXRuby where it left
off and see what happens.

Hope this gives you something to go on,

Lyle

We're getting closer. Making this change got me through the installation.

Now I'm having problems with the tests:

root@sp5wd-b1-/usr/local/FXRuby-1.0.14/tests-590>/opt/sfw/bin/ruby TC_FXButton.rb
/opt/sfw/lib/ruby/site_ruby/1.7/test/unit/error.rb:35: warning: escaped terminator
'"' inside string interpolation
/opt/sfw/lib/ruby/site_ruby/1.7/sparc-solaris2.9/fox.so: ld.so.1:
/opt/sfw/bin/ruby: fatal: relocation error: file
/opt/sfw/lib/ruby/site_ruby/1.7/sparc-solaris2.9/fox.so: symbol
_ZN16FXProgressDialog9metaClassE: referenced symbol not found -
/opt/sfw/lib/ruby/site_ruby/1.7/sparc-solaris2.9/fox.so (LoadError)
        from TC_FXButton.rb:3
Loaded suite TC_FXButton
/opt/sfw/lib/ruby/site_ruby/1.7/test/unit/ui/util/procwrapper.rb:26: warning:
Object#type is deprecated; use Object#class
/opt/sfw/lib/ruby/site_ruby/1.7/test/unit/ui/util/procwrapper.rb:26: warning:
Object#type is deprecated; use Object#class
/opt/sfw/lib/ruby/site_ruby/1.7/test/unit/ui/util/procwrapper.rb:26: warning:
Object#type is deprecated; use Object#class
Started...
/opt/sfw/lib/ruby/site_ruby/1.7/test/unit/ui/util/procwrapper.rb:26: warning:
Object#type is deprecated; use Object#class
/opt/sfw/lib/ruby/site_ruby/1.7/test/unit/ui/util/procwrapper.rb:26: warning:
Object#type is deprecated; use Object#class
/opt/sfw/lib/ruby/site_ruby/1.7/test/unit/ui/util/procwrapper.rb:26: warning:
Object#type is deprecated; use Object#class
/opt/sfw/lib/ruby/site_ruby/1.7/test/unit/ui/util/procwrapper.rb:26: warning:
Object#type is deprecated; use Object#class

Finished in 0.002416 seconds.
0 runs, 0 assertions, 0 failures, 0 errors

I'm guessing I should be seeing a widget of some kind at this point, but no luck.
Am I looking at rebuilding Fox with different ld options? I don't remember now if
I ended up using GNU's ld or Sun's ld.

Regards,

Dan

PS - heh - "0 failures" :stuck_out_tongue:

···

"lyle@knology.net" wrote:

Daniel Berger wrote:

We’re getting closer. Making this change got me through the installation.

Good.

Now I’m having problems with the tests:

root@sp5wd-b1-/usr/local/FXRuby-1.0.14/tests-590>/opt/sfw/bin/ruby TC_FXButton.rb

OK, we see a lot of warnings being issued for Test::Unit stuff (not my
code!) but also:

/opt/sfw/lib/ruby/site_ruby/1.7/sparc-solaris2.9/fox.so: ld.so.1:
/opt/sfw/bin/ruby: fatal: relocation error: file
/opt/sfw/lib/ruby/site_ruby/1.7/sparc-solaris2.9/fox.so: symbol
_ZN16FXProgressDialog9metaClassE: referenced symbol not found -
/opt/sfw/lib/ruby/site_ruby/1.7/sparc-solaris2.9/fox.so (LoadError)
from TC_FXButton.rb:3

My initial guess is that it simply doesn’t see the FOX shared library
(i.e. libFOX.so) in your dynamically-loaded libraries path. Ruby is
seeing “fox.so”, which is the shared library that implements the FXRuby
extension module; but “fox.so” depends on “libFOX.so” which is the main
C++ FOX library and that seems to be missing in action. So if you’re
using the C shell (or tcsh), try typing:

setenv LD_LIBRARY_PATH /opt/sfw/lib

which is where I’m assuming you installed FOX. Or if you’re running the
Bourne shell (or bash) you’d want to type:

export LD_LIBRARY_PATH=/opt/sfw/lib

Then try to run a test case again. Or for that matter, just fire up
‘irb’ and try to:

irb(main):001:0> require 'fox'

It will either work or it won’t :wink:

I’m guessing I should be seeing a widget of some kind at this point, but no luck.

Actually, no; none of the unit tests in the “tests” subdirectory
actually display anything. There are however a number of example
programs in the “examples” subdirectory that display all kinds of weird
and wonderful GUIs. But if the unit tests don’t run (due to the
previously described problem) then the examples won’t either.

Am I looking at rebuilding Fox with different ld options? I don’t remember now if
I ended up using GNU’s ld or Sun’s ld.

I hope this isn’t required, but I honestly don’t the answer. I think our
new Sun box is now in here at work but I don’t know if it’s been set up
yet. I’ll ask today about how that’s going and if I can get an account
to play on.

Lyle Johnson wrote:

My initial guess is that it simply doesn’t see the FOX shared library
(i.e. libFOX.so) in your dynamically-loaded libraries path. Ruby is
seeing “fox.so”, which is the shared library that implements the FXRuby
extension module; but “fox.so” depends on “libFOX.so” which is the main
C++ FOX library and that seems to be missing in action. So if you’re
using the C shell (or tcsh), try typing:

    setenv LD_LIBRARY_PATH /opt/sfw/lib

which is where I’m assuming you installed FOX. Or if you’re running the
Bourne shell (or bash) you’d want to type:

    export LD_LIBRARY_PATH=/opt/sfw/lib

Dang, I should have known you would ask about this. It shouldn’t be an issue. My
current LD_LIBRARY_PATH is:

/usr/local/lib:/usr/lib:/opt/sfw/lib:/usr/ccs/lib:/usr/local/qt/lib:/opt/oracle/lib

The FOX lib was installed under /usr/local, so the libFOX.so file is under
/usr/local/lib

Am I looking at rebuilding Fox with different ld options? I don’t remember now if
I ended up using GNU’s ld or Sun’s ld.

I hope this isn’t required, but I honestly don’t the answer. I think our
new Sun box is now in here at work but I don’t know if it’s been set up
yet. I’ll ask today about how that’s going and if I can get an account
to play on.

I think I built FOX with GNU’s ld and Ruby 1.7.3 using Sun’s ld. I was (just now)
going to try and rebuild Ruby 1.7.3 with the --with-gnu-ld option, but that doesn’t
appear to be a valid option (it didn’t show up with “configure --help” and setting it
didn’t seem to do anything).

What do I need to change within the configure script to get it to recognize this? I
looked around some, but I only messed things up.

Matz, can we add --with-gnu-ld to the configure setup?

Thanks for your help.

Dan

Daniel Berger wrote:

Dang, I should have known you would ask about this. It shouldn’t be an issue. My
current LD_LIBRARY_PATH is:

/usr/local/lib:/usr/lib:/opt/sfw/lib:/usr/ccs/lib:/usr/local/qt/lib:/opt/oracle/lib

The FOX lib was installed under /usr/local, so the libFOX.so file is under
/usr/local/lib.

OK.

I think I built FOX with GNU’s ld and Ruby 1.7.3 using Sun’s ld. I was (just now)
going to try and rebuild Ruby 1.7.3 with the --with-gnu-ld option, but that doesn’t
appear to be a valid option (it didn’t show up with “configure --help” and setting it
didn’t seem to do anything).

What do I need to change within the configure script to get it to recognize this? I
looked around some, but I only messed things up.

Instead of worrying about the configure script, maybe you can just
modify the Makefile directly. Look for the place(s) where it’s invoking
“ld” and hard-code the path to GNU ld (/usr/local/bin/ld or whatever).

Lyle Johnson wrote:

I think I built FOX with GNU’s ld and Ruby 1.7.3 using Sun’s ld. I was (just now)
going to try and rebuild Ruby 1.7.3 with the --with-gnu-ld option, but that doesn’t
appear to be a valid option (it didn’t show up with “configure --help” and setting it
didn’t seem to do anything).

What do I need to change within the configure script to get it to recognize this? I
looked around some, but I only messed things up.

Instead of worrying about the configure script, maybe you can just
modify the Makefile directly. Look for the place(s) where it’s invoking
“ld” and hard-code the path to GNU ld (/usr/local/bin/ld or whatever).

Problem solved!

Actually, I didn’t end up rebuilding Ruby 1.7.3. I rebuilt the FOX library instead with
the --with-gnu-ld option and that solved it. I ran one of the examples to make sure.

I don’t know why that works. I’ll just nod my head and move along.

Thanks for all your help Lyle!

Regards,

Dan