[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

extending ruby with C++

7stud --

3/20/2008 4:42:00 PM

I'm using this old (2001) mini tutorial:

http://www.angelfire.com/electronic2/issac/rb_cpp_e...

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> >::operator<<(int)
std::basic_ostream<char, std::char_traits<char> >::operator<<(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::operator<<
<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-....

16 Answers

Michael Neumann

3/20/2008 7:30:00 PM

0

7stud -- wrote:
> I'm using this old (2001) mini tutorial:
>
> http://www.angelfire.com/electronic2/issac/rb_cpp_e...
>
> 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


Marc Dietrichstein

3/20/2008 10:17:00 PM

0

Can't help you with that specific problem, but i can recommend you rice
(http://rice.ruby...) for building ruby extensions with c++.

Should be easier than using a 7 year old tutorial ;)

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

7stud --

3/21/2008 1:07:00 AM

0

Thanks for the response.

Michael Neumann wrote:
> 7stud -- wrote:
>> I'm using this old (2001) mini tutorial:
>>
>> http://www.angelfire.com/electronic2/issac/rb_cpp_e...
>>
>> 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-....

7stud --

3/21/2008 1:12:00 AM

0

Marc Dietrichstein wrote:
> Can't help you with that specific problem, but i can recommend you rice
> (http://rice.ruby...) 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-....

Michael Neumann

3/21/2008 1:30:00 AM

0

7stud -- wrote:
> Thanks for the response.
>
> Michael Neumann wrote:
>> 7stud -- wrote:
>>> I'm using this old (2001) mini tutorial:
>>>
>>> http://www.angelfire.com/electronic2/issac/rb_cpp_e...
>>>
>>> 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


7stud --

3/21/2008 1:55:00 AM

0

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-....

7stud --

3/21/2008 1:55:00 AM

0

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-....

Ron Fox

3/21/2008 9:26:00 AM

0

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/issac/rb_cpp_e...
>
> 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> >::operator<<(int)
> std::basic_ostream<char, std::char_traits<char> >::operator<<(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::operator<<
> <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?

Michael Neumann

3/21/2008 10:16:00 AM

0

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


7stud --

3/21/2008 5:34:00 PM

0

Michael Neumann wrote:
> 7stud -- wrote:
>> 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


Here is my current extconf.rb:

--------
require 'mkmf'

if (/mswin32/ =~ PLATFORM)
$CFLAGS+=" -GX " # allow exceptions
end

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

create_makefile("Test")
--------

Here is the result:

$ ruby extconf.rb
creating Makefile

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

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

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