# Linear Programming/Simplex Algorithm

**URL:** <https://www.ruby-forum.com/t/linear-programming-simplex-algorithm/195523>\
**Category:** Ruby\
**Created:** [September 24, 2010, 10:48am UTC](https://www.ruby-forum.com/t/linear-programming-simplex-algorithm/195523 "2010-09-24T10:48:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![taura](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/9f8e36/32.png) [@taura](https://www.ruby-forum.com/u/taura)\
**Post date:** [September 24, 2010, 10:48am UTC](https://www.ruby-forum.com/t/linear-programming-simplex-algorithm/195523/1 "2010-09-24T10:48:02Z")

</div>

Hi,

I’m looking for a way, to solve a linear optimization within ruby. I  
already tried this gem:

[http://rglpk.rubyforge.org/rglpk/](http://rglpk.rubyforge.org/rglpk/)

but wasn’t able to get it to work, because I have Windows and somehow  
the gem doesn’t seem to work with the winversion of GLPK (or, more  
likely, I’m too dense to get it to work). I “installed” winglpk (its  
working, I tested it via command line), but whenever I try to install  
the gem, it says, it couldn’t find the GLPK Library Installation. (I  
included the error message at the end of the post.)

Could someone help me please, either with the rglpk gem or with another  
solution? All I really need is a working simplex algorithm to solve my  
LP, all the other stuff GLPK does isn’t relevant for me.

Thanks in advance,

taura

* * *

Error Message, when trying to install rglpk:

Building native extensions. This could take a while…  
ERROR: Error installing rglpk:  
ERROR: Failed to build gem native extension.

C:/Programme/Ruby/bin/ruby.exe extconf.rb  
checking for main() in -lglpk… no

ERROR: Cannot find the GLPK library, aborting.  
\*\*\* extconf.rb failed \*\*\*  
Could not create Makefile due to some reason, probably lack of  
necessary libraries and/or headers. Check the mkmf.log file for more  
details. You may need configuration options.

Provided configuration options:  
–with-opt-dir  
–without-opt-dir  
–with-opt-include  
–without-opt-include=${opt-dir}/include  
–with-opt-lib  
–without-opt-lib=${opt-dir}/lib  
–with-make-prog  
–without-make-prog  
–srcdir=.  
–curdir  
–ruby=C:/Programme/Ruby/bin/ruby  
–with-glpk-dir  
–without-glpk-dir  
–with-glpk-include  
–without-glpk-include=${glpk-dir}/include  
–with-glpk-lib  
–without-glpk-lib=${glpk-dir}/lib  
–with-glpklib  
–without-glpklib

Gem files will remain installed in  
C:/Programme/Ruby/lib/ruby/gems/1.8/gems/rglpk-0.1.1 for inspection.  
Results logged to  
C:/Programme/Ruby/lib/ruby/gems/1.8/gems/rglpk-0.1.1/ext/gem\_make.out

* * *

Contents of mkmf.log:  
have\_library: checking for main() in -lglpk… -------------------- no

"gcc -o conftest -I. -IC:/Programme/Ruby/lib/ruby/1.8/i386-mingw32 -I.  
-g -O2 -DFD\_SETSIZE=256 conftest.c -L. -LC:/Programme/Ruby/lib -L.  
-lmsvcrt-ruby18-static -lglpk -lshell32 -lws2\_32 "  
c:\Programme\Ruby\devkit\gcc\3.4.5\bin..\lib\gcc\mingw32\3.4.5........\mingw32\bin\ld.exe:  
cannot find -lglpk  
collect2: ld returned 1 exit status  
checked program was:  
/\* begin _/  
1: #include \<ws2tcpip.h\>  
2: #include \<winsock2.h\>  
3: #include \<windows.h\>  
4:  
5: /top/  
6: int main() { return 0; }  
7: int t() { void ((volatile p)()); p = (void (()()))main; return 0; }  
/_ end \*/

"gcc -o conftest -I. -IC:/Programme/Ruby/lib/ruby/1.8/i386-mingw32 -I.  
-g -O2 -DFD\_SETSIZE=256 conftest.c -L. -LC:/Programme/Ruby/lib -L.  
-lmsvcrt-ruby18-static -lglpk -lshell32 -lws2\_32 "  
c:\Programme\Ruby\devkit\gcc\3.4.5\bin..\lib\gcc\mingw32\3.4.5........\mingw32\bin\ld.exe:  
cannot find -lglpk  
collect2: ld returned 1 exit status  
checked program was:  
/\* begin _/  
1: /top/  
2: int main() { return 0; }  
3: int t() { main(); return 0; }  
/_ end \*/

* * *
