# Ruby C extension problems mingw, missing symbols?

**URL:** <https://www.ruby-forum.com/t/ruby-c-extension-problems-mingw-missing-symbols/113904>\
**Category:** Ruby\
**Created:** [September 6, 2007, 1:39am UTC](https://www.ruby-forum.com/t/ruby-c-extension-problems-mingw-missing-symbols/113904 "2007-09-06T01:39:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![conan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/13edae/32.png) [@conan](https://www.ruby-forum.com/u/conan)\
**Post date:** [September 6, 2007, 1:39am UTC](https://www.ruby-forum.com/t/ruby-c-extension-problems-mingw-missing-symbols/113904/1 "2007-09-06T01:39:22Z")

</div>

I’ve been working all day on this(I might just be useless today) but I  
can’t figure it out.

I’m trying to make a simple extension, but when I include it, I get an  
error:

./alignment.so: 127: The specified procedure could not be found. -  
Init\_alignment.so

I’m running Ruby 1.8.6 (from the Ruby-one-click-installer) on windows.  
I’m using the Mingw32 tools for compiling my code.

In my .cpp file:

void Init\_alignment()  
{

}

In my .rb file:

require ‘alignment’  
puts “WOO!”

My compile script:

g++ alignment.cpp -shared -o alignment.so  
-Ic:/ruby/lib/ruby/1.8/i386-mswin32 -lmsvcrt-ruby18 -lmsvcrt  
-Lc:/ruby/bin -O3 -export-all-symbols

* * *

It compiles fine, but it just doesn’t seem to want to load my routines.  
Anybody have any idea what the problem might be, and how to fix it?

---

<div class="post-metadata">

**Author:** ![conan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/13edae/32.png) [@conan](https://www.ruby-forum.com/u/conan)\
**Post date:** [September 6, 2007, 3:53am UTC](https://www.ruby-forum.com/t/ruby-c-extension-problems-mingw-missing-symbols/113904/2 "2007-09-06T03:53:42Z")

</div>

Hi,

At Thu, 6 Sep 2007 08:39:25 +0900,  
Conan R. wrote in [ruby-talk:267817]:

> ./alignment.so: 127: The specified procedure could not be found. -  
> Init\_alignment.so

> g++ alignment.cpp -shared -o alignment.so

You use C++ compiler. Symbols in C++ object files are mangled  
unless they are marked extern “C”.

Try `nm --extern-only --defined-only alignment.so | grep  
Init\_alignment’.

---

<div class="post-metadata">

**Author:** ![conan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/13edae/32.png) [@conan](https://www.ruby-forum.com/u/conan)\
**Post date:** [September 6, 2007, 6:22pm UTC](https://www.ruby-forum.com/t/ruby-c-extension-problems-mingw-missing-symbols/113904/3 "2007-09-06T18:22:01Z")

</div>

Ah, fantastic. That solved all my problems.

Nobuyoshi N. wrote:

> Hi,
> 
> At Thu, 6 Sep 2007 08:39:25 +0900,  
> Conan R. wrote in [ruby-talk:267817]:
> 
> > ./alignment.so: 127: The specified procedure could not be found. -  
> > Init\_alignment.so
> 
> > g++ alignment.cpp -shared -o alignment.so
> 
> You use C++ compiler. Symbols in C++ object files are mangled  
> unless they are marked extern “C”.
> 
> Try `nm --extern-only --defined-only alignment.so | grep  
> Init\_alignment’.
