[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem porting linux shared library to windows using cygwin and lib

From: Thomas Leitner
Subject: Re: Problem porting linux shared library to windows using cygwin and libtool
Date: Tue, 16 Dec 2003 10:25:24 +1300

> if you wish to create Matlab MEX-Files using the GNU build
> environment, check out

The problem with that is that I have a varying number of C++ files which should 
be compiled as MEX-files. Currently, I let configure search the src directory 
and generate a list of all CPP files. This list is then compiled via a 
Makefile. To complicate the matter I need to compile these files not one time, 
but several times and link them against different libraries. If I used libtool 
support for this I would have to add for each CPP file to compile as MEX file 
lines similar to these (taken from your m-regex

noinst_LTLIBRARIES = libreg.l
libreg_la_SOURCES = m-regex.h m-regex.c
libreg_la_CFLAGS = -DMATLAB_MEX_FILE -I$(MATLAB)/extern/include
libreg_la_LDFLAGS = -no-undefined
libreg_la_LIBADD = $(LTLIBOBJS)

Therefore I will stick to my current approach.

> and

I had a look at your m-config tools.  I currently use the following script to 
determine the mex-extension:

echo "mexFunction() {}" > ac_mexext.c
$MEX ac_mexext.c -output ac_mexext_out 2>&1
gamatlab_cv_mex_extension=`find ac_mexext_out*  | sed -e "s/.*\.\(.*\)/\1/"`
rm -f ac_mexext.c ac_mexext_out.${gamatlab_cv_mex_extension}
if test -z  "$gamatlab_cv_mex_extension"; then
  AC_MSG_ERROR([the extension of the mex files could not be detected])

I noticed that this is a bit shorter than your code and its tested under Linux 
and Cygwin/Windows.

For getting the Matlab root directory I use the following script:

$MEX -v > test.mex 2>&1
MATLABDIR=`sed -n "s/.*MATLAB.*=\(.*\)/\1/p" test.mex`
rm -f test.mex

This works under Linux and Windows.

> P.S. The code is not tested with Matlab 6.5, I've only access
> to 6.1, and 5.x.  Any feedback would be appreciated.

I have tried to compile m-regex under Linux and Windows using Matlab 6.5r13. 
Under Linux I had the problem that I had a script called matlab in my path 
which confused your scripts finding the correct matlab root directory. After 
setting the Matlab root directory on the command line with the switch 
'--with-matlab' everything worked fine.

The problem was the same under Windows, but using the former mentioned switch 
everything worked fine.

However that does not solve my problem. I can compile mex files with my current 
approach under Windows (maybe I change this later and use your m-config and 
mextools package, but currently that is not possible). The problem is that I 
need to compile a library, not a mex file, that gets linked against the matlab 
import libraries. This works when compiled as static library but not when 
compiled as shared library.

To show why I would like to have a shared library: Under Windows the current 
files sum up to 45MB without stripping, 20MB with stripping. Under Linux with a 
shared library they are only 3.5MB without stripping, 2.6 with stripping.

Thomas Leitner

reply via email to

[Prev in Thread] Current Thread [Next in Thread]