From owner-freebsd-questions@FreeBSD.ORG Thu Aug 7 17:55:16 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E128B106564A for ; Thu, 7 Aug 2008 17:55:16 +0000 (UTC) (envelope-from mkhitrov@gmail.com) Received: from fk-out-0910.google.com (fk-out-0910.google.com [209.85.128.184]) by mx1.freebsd.org (Postfix) with ESMTP id 70B1A8FC08 for ; Thu, 7 Aug 2008 17:55:16 +0000 (UTC) (envelope-from mkhitrov@gmail.com) Received: by fk-out-0910.google.com with SMTP id k31so641489fkk.11 for ; Thu, 07 Aug 2008 10:55:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type:content-transfer-encoding :content-disposition; bh=Xgv5rdyNQoJe/9x2U/j0HA0dYbN51iV/0fYdBjW5BOM=; b=r4O9BPazR4MOVISsOXFSCl0AJgiY6on683J1VKVAkUZi7An/Aggop9Hmpd8D8kQHm6 FwMghDfyZaXq856eOduHDTbGb/ASIN46IaKd5Wo5qcPU6VSywSNtYeaOY7iw/XIisj7h m50LRAMTu0E6XzjthXdDGMs3y+bf5mFmKHci4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type :content-transfer-encoding:content-disposition; b=rpUM3cIVKZYzlON+h/NmqTeWFGJLGf7v6Ak1aECxvwTSd7/EO0p1mXE0DcjoxJ17t9 7prbFzYXVYkKoQjaW7YQWT4fzVWSE8uZUOvnigJSCQLkHPI0sQIKJFz37wDT0zUqPZx5 y4vfoZWUIPejuYog61O6e+QosuS7byT4d73Sw= Received: by 10.187.191.19 with SMTP id t19mr140967fap.87.1218131715196; Thu, 07 Aug 2008 10:55:15 -0700 (PDT) Received: by 10.187.217.10 with HTTP; Thu, 7 Aug 2008 10:55:15 -0700 (PDT) Message-ID: <26ddd1750808071055i2b9976b3i4f347407d94a0813@mail.gmail.com> Date: Thu, 7 Aug 2008 13:55:15 -0400 From: "Maxim Khitrov" To: "FreeBSD Questions" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline Subject: Linking amd64 binary with a 32-bit linux library X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Aug 2008 17:55:17 -0000 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