Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Aug 2008 13:55:15 -0400
From:      "Maxim Khitrov" <mkhitrov@gmail.com>
To:        "FreeBSD Questions" <freebsd-questions@freebsd.org>
Subject:   Linking amd64 binary with a 32-bit linux library
Message-ID:  <26ddd1750808071055i2b9976b3i4f347407d94a0813@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
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 (matlab.so) 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
matlab.so

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 matlab.so library that can then be loaded from ruby via
"require 'matlab'" command. On FreeBSD I get this for the third
command:

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

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

- Max



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?26ddd1750808071055i2b9976b3i4f347407d94a0813>