Linking amd64 binary with a 32-bit linux library

Maxim Khitrov mkhitrov at
Thu Aug 7 17:55:17 UTC 2008

My knowledge of compilers is insufficient to answer this question. I'm
currently going through the process of installing a 32-bit version of
Matlab onto FreeBSD 7.0 amd64. In fact, Matlab itself has been
installed and seems to be running fine (albeit without a GUI due to
some java-related issues).

The next thing I need to do is to build a library ( that
will allow ruby scripts to access the Matlab Engine. This library must
be usable by mod_ruby, which is compiled for FreeBSD from ports, but
it must use the 32-bit linux libraries from Matlab to do the actual
work. Is such compilation possible?

The exact commands that I would use on a linux system (minus changes
in paths) are the following:

swig -ruby matlab.i
cc -c -shared matlab_wrap.c -I/usr/local/lib/ruby/1.8/amd64-freebsd7/
-I/compat/linux/usr/local/matlab-7.0.4/extern/include -fPIC
cc -shared matlab_wrap.o
-L/compat/linux/usr/local/matlab-7.0.4/bin/glnx86 -lmat -leng -o

The matlab.i file is something that we wrote to use Matlab Engine in
ruby, swig is used to create C code. On a linux system these three
lines give me library that can then be loaded from ruby via
"require 'matlab'" command. On FreeBSD I get this for the third

/usr/bin/ld: skipping incompatible
/compat/linux/usr/local/matlab-7.0.4/bin/glnx86/ when
searching for -lmat
/usr/bin/ld: cannot find -lmat

I take it that this happens because is a linux binary, but
is there any way to do what I'm after?

- Max

More information about the freebsd-questions mailing list