# Problem with ruby1.8 and OpenMP in Ruby extension: shared object cannot be dlopen()'ed

**URL:** <https://www.ruby-forum.com/t/problem-with-ruby1-8-and-openmp-in-ruby-extension-shared-object-cannot-be-dlopen-ed/116377>\
**Category:** Ruby\
**Created:** [October 5, 2007, 12:55am UTC](https://www.ruby-forum.com/t/problem-with-ruby1-8-and-openmp-in-ruby-extension-shared-object-cannot-be-dlopen-ed/116377 "2007-10-05T00:55:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rudi\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/aca169/32.png) [@Rudi\_C](https://www.ruby-forum.com/u/Rudi_C)\
**Post date:** [October 5, 2007, 12:55am UTC](https://www.ruby-forum.com/t/problem-with-ruby1-8-and-openmp-in-ruby-extension-shared-object-cannot-be-dlopen-ed/116377/1 "2007-10-05T00:55:56Z")

</div>

Hi everybody,

I am the main developer of CompLearn, an open-source machine learning  
library  
for scientific researchers. I have written a Ruby binding for  
CompLearn  
called complearn-ruby. It has worked fine in the past. But it has a  
problem  
ever since I converted the base library (libcomplearn) to use OpenMP  
for  
multicore processor support. If I just try to use the simplest  
approach that  
has worked in the past in my extconf.rb, I get the following problem  
when I  
try to require the C-extension Ruby binding complearn4r.so and use the  
multicore part of the system:

ruby: symbol lookup error: /usr/lib/libcomplearn.so.1: undefined  
symbol: GOMP\_parallel\_start

To try to fix this error,

I adjusted the extconf.rb to include this line:

have\_library(‘gomp’, ‘main’)

And rebuilding works but running a simple test program (just trying to  
require  
complearn) fails in a different way than before:

/home/cilibrar/rlc/projects/complearn/complearn-ruby/ext/complearn/  
complearn4r.so: libgomp.so.1: shared object cannot be dlopen()ed - /  
home/cilibrar/rlc/projects/complearn/complearn-ruby/ext/complearn/  
complearn4r.so (LoadError)  
from /home/cilibrar/rlc/projects/complearn/complearn-ruby/lib/  
complearn.rb:2  
from tests/t2.rb:1:in `require’  
from tests/t2.rb:1

I don’t know what else to try and wonder if anybody else can offer a  
clue?

I have tried for a long time experimenting with CFLAGS, CPPFLAGS,  
LDFLAGS,  
and -fopenmp among other settings but I still cannot seem to figure  
out  
a solution. I have put the source code for this problem up at

[http://cilibrar.com/~cilibrar/projsup/rubbug/libcomplearn-1.0.4.tar.gz](http://cilibrar.com/~cilibrar/projsup/rubbug/libcomplearn-1.0.4.tar.gz)  
and  
[http://cilibrar.com/~cilibrar/projsup/rubbug/libcomplearn-ruby-1.0.4.tar.gz](http://cilibrar.com/~cilibrar/projsup/rubbug/libcomplearn-ruby-1.0.4.tar.gz)

I would appreciate greatly any help anybody can offer in this  
problem. Thank  
you for your attention,

Rudi

---

<div class="post-metadata">

**Author:** ![Rudi\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/aca169/32.png) [@Rudi\_C](https://www.ruby-forum.com/u/Rudi_C)\
**Post date:** [October 5, 2007, 1:16am UTC](https://www.ruby-forum.com/t/problem-with-ruby1-8-and-openmp-in-ruby-extension-shared-object-cannot-be-dlopen-ed/116377/2 "2007-10-05T01:16:58Z")

</div>

> /home/cilibrar/rlc/projects/complearn/complearn-ruby/ext/complearn/  
> complearn4r.so: libgomp.so.1: shared object cannot be dlopen()ed - /

That probably means you have some undefined symbol most likely due to  
a missing library during link time.

That being said, even if you manage to load and compile the stuff,  
wrapping an OpenMP library is _probably_ asking for trouble as ruby is  
a single threaded application that relies on knowing how and where the  
stack is. OpenMP will generate new threads behind your back, each one  
with its own stack. Any call from those threads back to ruby will  
probably lead to random crashes or memory issues.

---

<div class="post-metadata">

**Author:** ![Rudi\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/aca169/32.png) [@Rudi\_C](https://www.ruby-forum.com/u/Rudi_C)\
**Post date:** [October 6, 2007, 9:11pm UTC](https://www.ruby-forum.com/t/problem-with-ruby1-8-and-openmp-in-ruby-extension-shared-object-cannot-be-dlopen-ed/116377/3 "2007-10-06T21:11:13Z")

</div>

Thanks for this excellent suggestion. You inspired me to write a much  
superior stdin/stdout style connector instead using pipes that is far  
more flexible in many ways:

[http://hg.cilibrar.com/complearn-uncd/](http://hg.cilibrar.com/complearn-uncd/)

Best regards,

-r.
