|
From: James Tursa on 18 Jun 2008 18:33 "Richie Cotton" <richierocks(a)nospam.gmail.com> wrote in message <g3bd6u$cb8$1(a)fred.mathworks.com>... > I'm trying to understand how Mex files work, and I'm working > my way through the built-in examples. Most work fine, but > the 'dynamically allocating memory' example throws an error. > > In this example, the gateway routine and the computational > subroutine are in two separate files. I presume this is > valid practise, but the compiler throws an 'unresolved > external symbol' error when linking. > > The example files are in matlabroot\extern\examples\refbook, > named dblmat.f and compute.f > > Both files compile fine, but running mex dblmat.f results in > the output: > Creating library > C:\DOCUME~1\rcotton\LOCALS~1\Temp\mex_98A65341-3E5D-4E6E- 8085-421F61D78F59\templib.lib > and object > C:\DOCUME~1\rcotton\LOCALS~1\Temp\mex_98A65341-3E5D-4E6E- 8085-421F61D78F59\templib.exp > > dblmat.obj : error LNK2001: unresolved external symbol > _COMPUTE(a)12 > dblmat.mexw32 : fatal error LNK1120: 1 unresolved externals > > I'm using v2007b, with Compaq Visual Fortran 6.6 under Win XP. > > How do I persuade Matlab/Visual Fortran to recognise the > computational subroutine? From what you have written, it looks like you are doing this: mex dblmat.f when you should be doing this: mex dblmat.f compute.f i.e., you need to give the mex command all of the pieces. This would also be the case if, for example, compute.f was some other pre-compiled object code or library etc. For example, if your mex routine needed a Fortran source code file and a pre-compiled object code and a library dll the mex command would look like this: mex mysource.f myobj.obj mylib.dll James Tursa
From: Richie Cotton on 19 Jun 2008 05:17 > From what you have written, it looks like you are doing > this: > > mex dblmat.f > > when you should be doing this: > > mex dblmat.f compute.f Thanks. With hindsight, that's embarrassingly obvious.
|
Pages: 1 Prev: Question about OO design in 2008a Next: using sub2ind on multi dimensional matrices |