# Ruby-1.8.5 and openssl and gcc 3.2

**URL:** <https://www.ruby-forum.com/t/ruby-1-8-5-and-openssl-and-gcc-3-2/68928>\
**Category:** Ruby\
**Created:** [September 16, 2006, 11:07pm UTC](https://www.ruby-forum.com/t/ruby-1-8-5-and-openssl-and-gcc-3-2/68928 "2006-09-16T23:07:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bil\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/848f3c/32.png) [@Bil\_K](https://www.ruby-forum.com/u/Bil_K)\
**Post date:** [September 16, 2006, 11:07pm UTC](https://www.ruby-forum.com/t/ruby-1-8-5-and-openssl-and-gcc-3-2/68928/1 "2006-09-16T23:07:03Z")

</div>

I’m trying to compile ruby-1.8.5 on a rather old Linux box,  
and it’s failing in ext/openssl,

gcc -I. -I…/… -I…/…/. -I…/…/./ext/openssl  
-DRUBY\_EXTCONF\_H=“extconf.h” -I/users/kleb/local/openssl/include  
-fPIC -g -O2 -c ossl\_bio.c  
ossl\_bio.c: In function `ossl\_obj2bio’:  
ossl\_bio.c:23: called object is not a function  
make: \*\*\* [ossl\_bio.o] Error 1

Does this error look familiar to anyone?

```
 21 if (TYPE(obj) == T_FILE) {
 22 OpenFile *fptr;

```

> 23 GetOpenFile(obj, fptr);  
> 24 rb\_io\_check\_readable(fptr);  
> 25 bio = BIO\_new\_fp(fptr-\>f, BIO\_NOCLOSE);  
> 26 }

As you can see, I tried supplying a fresh openssl (0.9.7k),  
but the error didn’t change.

Here’s the state of gcc on this box,

gcc -v  
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2/specs  
Configured with: …/configure --prefix=/usr --mandir=/usr/share/man  
–infodir=/usr/share/info --enable-shared --enable-threads=posix  
–disable-checking --host=i386-redhat-linux --with-system-zlib  
–enable-\_\_cxa\_atexit  
Thread model: posix  
gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)

Thanks,

---

<div class="post-metadata">

**Author:** ![Bil\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/848f3c/32.png) [@Bil\_K](https://www.ruby-forum.com/u/Bil_K)\
**Post date:** [September 17, 2006, 3:39pm UTC](https://www.ruby-forum.com/t/ruby-1-8-5-and-openssl-and-gcc-3-2/68928/2 "2006-09-17T15:39:54Z")

</div>

Hi,

At Sun, 17 Sep 2006 06:06:16 +0900,  
Bil K. wrote in [ruby-talk:214786]:

> ```
> 25 bio = BIO_new_fp(fptr->f, BIO_NOCLOSE);
> 26 }
> 
> ```

Can’t you show the preprocessed result?

$ gcc -I. -I…/… -I…/…/. -I…/…/./ext/openssl   
-DRUBY\_EXTCONF\_H=“extconf.h”   
-I/users/kleb/local/openssl/include -fPIC -g -O2   
-E ossl\_bio.c | sed -n /^ossl\_obj2bio/,/^}/p

would show the corresponding portion.

---

<div class="post-metadata">

**Author:** ![Bil\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/848f3c/32.png) [@Bil\_K](https://www.ruby-forum.com/u/Bil_K)\
**Post date:** [September 17, 2006, 4:21pm UTC](https://www.ruby-forum.com/t/ruby-1-8-5-and-openssl-and-gcc-3-2/68928/3 "2006-09-17T16:21:56Z")

</div>

Nobuyoshi N. wrote:

> Hi,

Hello.

> At Sun, 17 Sep 2006 06:06:16 +0900,  
> Bil K. wrote in [ruby-talk:214786]:
> 
> > ossl\_bio.c: In function `ossl\_obj2bio’:  
> > ossl\_bio.c:23: called object is not a function  
> > make: \*\*\* [ossl\_bio.o] Error 1
> 
> Can’t you show the preprocessed result?

ossl\_obj2bio(VALUE obj)  
{  
BIO \*bio;

```
 if (rb_type((VALUE)(obj)) == 0x0e) {
     OpenFile *fptr;
     rb_io_check_closed((fptr) = 

```

“.rnd”(rb\_io\_taint\_check(obj))-\>fptr);  
rb\_io\_check\_readable(fptr);  
bio = BIO\_new\_fp(fptr-\>f, 0x00);  
}  
else {  
rb\_string\_value(&(obj));  
bio = BIO\_new\_mem\_buf(((struct RString\*)(obj))-\>ptr, ((struct  
RString\*)(obj))-\>len);  
}  
if (!bio) ossl\_raise(eOSSLError, ((void \*)0));

```
 return bio;

```

}

Regards,

---

<div class="post-metadata">

**Author:** ![Bil\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/848f3c/32.png) [@Bil\_K](https://www.ruby-forum.com/u/Bil_K)\
**Post date:** [September 17, 2006, 5:16pm UTC](https://www.ruby-forum.com/t/ruby-1-8-5-and-openssl-and-gcc-3-2/68928/4 "2006-09-17T17:16:00Z")

</div>

Hi,

At Sun, 17 Sep 2006 23:21:09 +0900,  
Bil K. wrote in [ruby-talk:214845]:

> ```
> if (rb_type((VALUE)(obj)) == 0x0e) {
> OpenFile *fptr;
> rb_io_check_closed((fptr) = ".rnd"(rb_io_taint_check(obj))->fptr);
> 
> ```

This line has to be:

rb\_io\_check\_closed((fptr) = ((struct  
RFile\*)(rb\_io\_taint\_check(obj)))-\>fptr);

In ext/openssl/ossl.h:  
/\*

- OpenSSL has defined RFILE and Ruby has defined RFILE - so undef it!  
_/  
 #if defined(RFILE) /_&& !defined(OSSL\_DEBUG)\*/

# undef RFILE

#endif  
#include \<ruby.h\>  
#include \<rubyio.h\>

RFILE seems redefined somewhere after here.

---

<div class="post-metadata">

**Author:** ![Bil\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/848f3c/32.png) [@Bil\_K](https://www.ruby-forum.com/u/Bil_K)\
**Post date:** [September 17, 2006, 6:06pm UTC](https://www.ruby-forum.com/t/ruby-1-8-5-and-openssl-and-gcc-3-2/68928/5 "2006-09-17T18:06:04Z")

</div>

Nobuyoshi N. wrote:

> rb\_io\_check\_closed((fptr) = ((struct RFile\*)(rb\_io\_taint\_check(obj)))-\>fptr);
> 
> In ext/openssl/ossl.h:  
> /\*
> 
> - OpenSSL has defined RFILE and Ruby has defined RFILE - so undef it!  
> _/  
> #if defined(RFILE) /_&& !defined(OSSL\_DEBUG)\*/
> 
> # undef RFILE
> 
> #endif  
> #include \<ruby.h\>  
> #include \<rubyio.h\>

I have this in my ossl.h too:

```
 20 /*
 21 * OpenSSL has defined RFILE and Ruby has defined RFILE - so 

```

undef it!  
22 _/  
23 #if defined(RFILE) /_&& !defined(OSSL\_DEBUG)\*/  
24 # undef RFILE  
25 #endif  
26 #include \<ruby.h\>  
27 #include \<rubyio.h\>

> RFILE seems redefined somewhere after here.

But I can’t find another RFILE in /ext/openssl or below…

$ cd /ext/openssl && grep -nr RFILE \*  
ossl.h:21:\* OpenSSL has defined RFILE and Ruby has defined RFILE - so  
undef it!  
ossl.h:23:#if defined(RFILE) /_&& !defined(OSSL\_DEBUG)_/  
ossl.h:24:# undef RFILE

Suggestions?

I tried removing the comment from the “#if defined” line  
and just putting "#undef RFILE’ with no apparent effect.

Thanks,

---

<div class="post-metadata">

**Author:** ![Bil\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/848f3c/32.png) [@Bil\_K](https://www.ruby-forum.com/u/Bil_K)\
**Post date:** [September 18, 2006, 12:21pm UTC](https://www.ruby-forum.com/t/ruby-1-8-5-and-openssl-and-gcc-3-2/68928/6 "2006-09-18T12:21:26Z")

</div>

Nobuyoshi N. wrote:

> Hi,

Hello.

> Moving the code block after #include lines of openssl. Try  
> this patch.

Works.

Thanks,

---

<div class="post-metadata">

**Author:** ![Bil\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/848f3c/32.png) [@Bil\_K](https://www.ruby-forum.com/u/Bil_K)\
**Post date:** [September 18, 2006, 4:52am UTC](https://www.ruby-forum.com/t/ruby-1-8-5-and-openssl-and-gcc-3-2/68928/7 "2006-09-18T04:52:50Z")

</div>

Hi,

At Mon, 18 Sep 2006 01:06:07 +0900,  
Bil K. wrote in [ruby-talk:214856]:

> > RFILE seems redefined somewhere after here.
> 
> But I can’t find another RFILE in /ext/openssl or below…

`Somewhere’ inside \<openssl/\*.h\> below it.

> $ cd /ext/openssl && grep -nr RFILE \*  
> ossl.h:21:\* OpenSSL has defined RFILE and Ruby has defined RFILE - so undef it!  
> ossl.h:23:#if defined(RFILE) /_&& !defined(OSSL\_DEBUG)_/  
> ossl.h:24:# undef RFILE
> 
> Suggestions?

Moving the code block after #include lines of openssl. Try  
this patch.

# Index: ext/openssl/ossl.h

RCS file: /cvs/ruby/src/ruby/ext/openssl/ossl.h,v  
retrieving revision 1.14.2.4  
diff -p -u -2 -r1.14.2.4 ossl.h  
— ext/openssl/ossl.h 27 Jul 2006 07:45:33 -0000 1.14.2.4  
+++ ext/openssl/ossl.h 18 Sep 2006 02:49:17 -0000  
@@ -16,14 +16,13 @@  
#if defined(\_\_cplusplus)  
extern “C” {  
+#elif 0  
+}  
#endif

/\*  
-\* OpenSSL has defined RFILE and Ruby has defined RFILE - so undef it!  
-_/  
-#if defined(RFILE) /_&& !defined(OSSL\_DEBUG)\*/  
-# undef RFILE  
-#endif  
-#include \<ruby.h\>  
-#include \<rubyio.h\>

- \*\_FILE\_OFFSET\_BITS needs to be defined before some system headers on
- 
  - Solaris.

- \*/  
+#include “config.h”

/\*  
@@ -70,4 +69,13 @@ extern “C” {

/\*  
+\* OpenSSL has defined RFILE and Ruby has defined RFILE - so undef it!  
+_/  
+#if defined(RFILE) /_&& !defined(OSSL\_DEBUG)_/  
+# undef RFILE  
+#endif  
+#include \<ruby.h\>  
+#include \<rubyio.h\>  
+  
+/_

- Common Module  
\*/  
@@ -212,5 +220,7 @@ void ossl\_debug(const char \*, …);  
void Init\_openssl(void);

-#if defined(\_\_cplusplus)  
+#if 0  
+{  
+#elif defined(\_\_cplusplus)  
}  
#endif
