# Difficulty with name-mangling when extending Ruby with Thrust (C++)

**URL:** <https://www.ruby-forum.com/t/difficulty-with-name-mangling-when-extending-ruby-with-thrust-c/177617>\
**Category:** Ruby\
**Created:** [October 21, 2009, 4:00am UTC](https://www.ruby-forum.com/t/difficulty-with-name-mangling-when-extending-ruby-with-thrust-c/177617 "2009-10-21T04:00:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ralf\_Gunter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/53a042/32.png) [@Ralf\_Gunter](https://www.ruby-forum.com/u/Ralf_Gunter)\
**Post date:** [October 21, 2009, 4:00am UTC](https://www.ruby-forum.com/t/difficulty-with-name-mangling-when-extending-ruby-with-thrust-c/177617/1 "2009-10-21T04:00:17Z")

</div>

Hello,

I’m trying to extend Ruby with Thrust for a short physics project of  
mine, but I keep running into some trouble with C++'s name mangling.  
Specifically, when calling functions such as thrust::replace or  
thrust::sequence, I get errors similar to the following:

irb: symbol lookup error: /home/ralfgunter/ruby/thrust/thrust.so:  
undefined symbol:  
_ZN6thrust6detail6device4cuda9vectorizeIiNS1\_6detail26unary\_transform\_if\_functorINS\_10device\_ptrIfEES7\_S7\_NS0\_14constant\_unaryIfEENS0\_20if\_equal\_to\_exemplarIfEEEEEEvT\_T0_

This is not always the case - thrust::fill works fine, for instance. I  
am using nvcc from CUDA 2.3, Ruby 1.9.1-p243, gcc 4.3.3 (ubuntu), and I  
had to mess a bit with the Makefile to compile; these were the  
workarounds:

1. Replaced ‘g++’ with ‘nvcc’
2. Replaced every instance of ‘-Wl,’ with '-Xlinker ’
3. Added a '-Xcompiler ’ before ‘-Wall’, ‘-rdynamic’, and pretty much  
everything else that would make ‘make’ spit out an error.

As far as I know, this is usually solved by wrapping the ‘offending  
functions’ with ‘extern “C”’, though now the functions I’m having some  
difficulty with are Thrust’s own, so I think this solution might not  
apply in this case. Please do correct me if I’m wrong!

I’d love if anyone could help me with this one, as it’s been bugging me  
for a while!

Cheers,  
Ralf
