Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > extending ruby with C++

Reply
Thread Tools

extending ruby with C++

 
 
7stud --
Guest
Posts: n/a
 
      03-20-2008
I'm using this old (2001) mini tutorial:

http://www.angelfire.com/electronic2...pp_ext_tut.txt

When I run make, I get this error:

$ make
cc -bundle -L"/usr/lib" -o Test.bundle Test.o -lruby -lpthread -ldl
-lobjc
/usr/bin/ld: Undefined symbols:
__Unwind_Resume
std::basic_ostream<char, std::char_traits<char> >:perator<<(int)
std::basic_ostream<char, std::char_traits<char> >:perator<<(unsigned
long)
std::ios_base::Init::Init()
std::ios_base::Init::~Init()
std::__throw_bad_alloc()
std::__throw_length_error(char const*)
std::cout
std::basic_ostream<char, std::char_traits<char> >& std::endl<char,
std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char>
>&)

std::basic_ostream<char, std::char_traits<char> >& std:perator<<
<std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&, char const*)
operator delete(void*)
operator new(unsigned long)
___gxx_personality_v0
collect2: ld returned 1 exit status
make: *** [Test.bundle] Error 1

$ ls
Makefile Test.cpp Test.o extconf.rb

I tried that on mac osx. Any idea what's wrong?
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Michael Neumann
Guest
Posts: n/a
 
      03-20-2008
7stud -- wrote:
> I'm using this old (2001) mini tutorial:
>
> http://www.angelfire.com/electronic2...pp_ext_tut.txt
>
> When I run make, I get this error:
>
> $ make
> cc -bundle -L"/usr/lib" -o Test.bundle Test.o -lruby -lpthread -ldl
> -lobjc


use c++ or add -lstdc++.

c++ -bundle -L"/usr/lib" -o Test.bundle Test.o -lruby -lpthread -ldl
-lobjc -lstdc++

Regards,

Michael


 
Reply With Quote
 
 
 
 
Marc Dietrichstein
Guest
Posts: n/a
 
      03-20-2008
Can't help you with that specific problem, but i can recommend you rice
(http://rice.rubyforge.org/) for building ruby extensions with c++.

Should be easier than using a 7 year old tutorial

best,
marc
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
7stud --
Guest
Posts: n/a
 
      03-21-2008
Thanks for the response.

Michael Neumann wrote:
> 7stud -- wrote:
>> I'm using this old (2001) mini tutorial:
>>
>> http://www.angelfire.com/electronic2...pp_ext_tut.txt
>>
>> When I run make, I get this error:
>>
>> $ make
>> cc -bundle -L"/usr/lib" -o Test.bundle Test.o -lruby -lpthread -ldl
>> -lobjc

>
> use c++ or add -lstdc++.
>


I don't know what that means.


> c++ -bundle -L"/usr/lib" -o Test.bundle Test.o -lruby -lpthread -ldl
> -lobjc -lstdc++
>


Following the tutorial, the only commands I executed were:

1) $ ruby extconf.rb

2) $ make


--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
7stud --
Guest
Posts: n/a
 
      03-21-2008
Marc Dietrichstein wrote:
> Can't help you with that specific problem, but i can recommend you rice
> (http://rice.rubyforge.org/) for building ruby extensions with c++.
>
> Should be easier than using a 7 year old tutorial
>
> best,
> marc


Thanks for the response. I'll take a look at Rice, too.
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Michael Neumann
Guest
Posts: n/a
 
      03-21-2008
7stud -- wrote:
> Thanks for the response.
>
> Michael Neumann wrote:
>> 7stud -- wrote:
>>> I'm using this old (2001) mini tutorial:
>>>
>>> http://www.angelfire.com/electronic2...pp_ext_tut.txt
>>>
>>> When I run make, I get this error:
>>>
>>> $ make
>>> cc -bundle -L"/usr/lib" -o Test.bundle Test.o -lruby -lpthread -ldl
>>> -lobjc

>> use c++ or add -lstdc++.
>>

>
> I don't know what that means.


"cc" is usually used to compile C programs. Use the command-line tool
"c++" (or "g++") instead for C++. "cc" will determine that you are
compiling C++ code, but it will not add the standard C++ library (-lstdc++).

Add the following line to your extconf.rb file:

$LIBS << " -lstdc++"

Before the call to "create_makefile"!

Regards,

Michael


 
Reply With Quote
 
7stud --
Guest
Posts: n/a
 
      03-21-2008
Michael Neumann wrote:
> 7stud -- wrote:
>>>> $ make
>>>> cc -bundle -L"/usr/lib" -o Test.bundle Test.o -lruby -lpthread -ldl
>>>> -lobjc
>>> use c++ or add -lstdc++.
>>>

>>
>> I don't know what that means.

>
> "cc" is usually used to compile C programs. Use the command-line tool
> "c++" (or "g++") instead for C++.


How? Where? There is no mention of cc in extconf.rb.

>"cc" will determine that you are
> compiling C++ code, but it will not add the standard C++ library
> (-lstdc++).
>
> Add the following line to your extconf.rb file:
>
> $LIBS << " -lstdc++"
>
> Before the call to "create_makefile"!
>


I tried adding that line to extconf.rb before the create_makefile()
line, but I get the same error.

??

--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
7stud --
Guest
Posts: n/a
 
      03-21-2008
7stud -- wrote:
> Michael Neumann wrote:
>> 7stud -- wrote:
>>>>> $ make
>>>>> cc -bundle -L"/usr/lib" -o Test.bundle Test.o -lruby -lpthread -ldl
>>>>> -lobjc
>>>> use c++ or add -lstdc++.
>>>>
>>>
>>> I don't know what that means.

>>
>> "cc" is usually used to compile C programs. Use the command-line tool
>> "c++" (or "g++") instead for C++.

>
> How? Where? There is no mention of cc in extconf.rb.
>
>>"cc" will determine that you are
>> compiling C++ code, but it will not add the standard C++ library
>> (-lstdc++).
>>
>> Add the following line to your extconf.rb file:
>>
>> $LIBS << " -lstdc++"
>>
>> Before the call to "create_makefile"!
>>

>
> I tried adding that line to extconf.rb before the create_makefile()
> line, but I get the same error.
>
> ??


Here's the error:

$ ruby extconf.rb
creating Makefile

$ make
cc -bundle -L"/usr/lib" -o Test.bundle Test.o -lruby -lpthread -ldl
-lobjc -lstdc++
/usr/bin/ld: Undefined symbols:
__Unwind_Resume
collect2: ld returned 1 exit status
make: *** [Test.bundle] Error 1


--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Ron Fox
Guest
Posts: n/a
 
      03-21-2008
Try using g++ to link the code rather than cc. Using cc does not
include the g++ run-time libraries in the link.

Ron.

7stud -- wrote:
> I'm using this old (2001) mini tutorial:
>
> http://www.angelfire.com/electronic2...pp_ext_tut.txt
>
> When I run make, I get this error:
>
> $ make
> cc -bundle -L"/usr/lib" -o Test.bundle Test.o -lruby -lpthread -ldl
> -lobjc
> /usr/bin/ld: Undefined symbols:
> __Unwind_Resume
> std::basic_ostream<char, std::char_traits<char> >:perator<<(int)
> std::basic_ostream<char, std::char_traits<char> >:perator<<(unsigned
> long)
> std::ios_base::Init::Init()
> std::ios_base::Init::~Init()
> std::__throw_bad_alloc()
> std::__throw_length_error(char const*)
> std::cout
> std::basic_ostream<char, std::char_traits<char> >& std::endl<char,
> std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char>
>> &)

> std::basic_ostream<char, std::char_traits<char> >& std:perator<<
> <std::char_traits<char> >(std::basic_ostream<char,
> std::char_traits<char> >&, char const*)
> operator delete(void*)
> operator new(unsigned long)
> ___gxx_personality_v0
> collect2: ld returned 1 exit status
> make: *** [Test.bundle] Error 1
>
> $ ls
> Makefile Test.cpp Test.o extconf.rb
>
> I tried that on mac osx. Any idea what's wrong?

 
Reply With Quote
 
Michael Neumann
Guest
Posts: n/a
 
      03-21-2008
7stud -- wrote:
> 7stud -- wrote:
>> Michael Neumann wrote:
>> I tried adding that line to extconf.rb before the create_makefile()
>> line, but I get the same error.
>>
>> ??

>
> Here's the error:
>
> $ ruby extconf.rb
> creating Makefile
>
> $ make
> cc -bundle -L"/usr/lib" -o Test.bundle Test.o -lruby -lpthread -ldl
> -lobjc -lstdc++
> /usr/bin/ld: Undefined symbols:
> __Unwind_Resume
> collect2: ld returned 1 exit status
> make: *** [Test.bundle] Error 1


Try this:

$LIBS << " -lstdc++ -lc"

Regards,

Michael


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Extending ruby with crypto++ Dominik Werder Ruby 13 09-12-2004 01:47 PM
Learning extending ruby Dominik Werder Ruby 8 04-30-2004 11:19 PM
Newbie question : Extending Ruby DaZoner Ruby 1 10-14-2003 04:31 AM
Extending Ruby : segment violation DaZoner Ruby 0 10-07-2003 07:43 PM
Summary: callbacks (called in C embedding or extending Ruby) Basile STARYNKEVITCH Ruby 0 09-02-2003 03:29 PM



Advertisments