Saif Butt <saifb...@...> writes:

> 
> Dear All,I am having problems regarding installation of NLOPT in Windows XP.I
have carried out the following steps for installation.1. I created
libnlopt-0.lib file using MinGW gcc compiler.2.Then I tried to create mex
function  using command 
>                         mex nlopt_optimize.c libnlopt-0.lib3. But Matlab
returns me an error message  (I'm using MATLAB Version 7.9.0.529 (R2009b)
).%%%%%%%%%%%%%%%%%%%%%%%%The instruction at 0x69c24c7a referenced memory at
0x00000021.
> The memory could not be read.Exception fielded by 0x00402f60EAX=0x00000000
EBX=0x00000000 ECX=0x00000000 EDX=0x003a04b4ESI=0x003a04b4 EDI=0x00378980
EBP=0x00373150 ESP=0x0006fc00EIP=0x69c24c7a EFL=0x00010246 CS =0x0000001b SS
=0x00000023
> DS =0x00000023 ES =0x00000023 FS =0x0000003b GS =0x00000000Stack dump
(SS:ESP)0x003a04b4 0x00373150 0x0037eba8 0x69c23739 0x00376078 0x00376118
0x00373150 0x00374334 0x00000801 0x00375d03 0x0000000d 0x69c4f51a 
> 0x69c23490 0x00000008 0x0037eba8 0x003762a0 0x69c3b7e5 0x00375d08 0x0000000c
0x69c23b01 0x69c35f6a 0x69c23bc0 0x69c237bb 0x003762a0 0x69c23bdb 0x0000000b
0x0000002c 0x69c3b469 0x00000000 0x00000200 0x00375c01 0x69c35a44 0x00375cf0
0x69c23c9b 0x00000001 0x003906c4 
> 0x00375cd8 0x69c29b17 0x00000001 0x003906c4 0x00375cd8 0x69c103e1 0x00000270
0x00378970 0x00394c88 0x0037896a 0x69c104d6 0x00000001 0x0006fe84 0x00004000
0x0000000f 0x003a04b4 0x00000080 0x69c29c8d 0x0140f474 0x0006fe68 0x69c317a0
0x0006fd74 0x00000000 0x69c2d25f 
> 0x00000000 0x69c2cfd0 0x69c10bf1 0x00000000 0x69c2cfd0 0x00000000 0x0006fe68
0x0140f474 0x0006fe84 0x69c10bda 0x0006fcfc 0x00230023 Open Watcom Linker
Version 1.6 Portions Copyright (c) 1985-2002 Sybase, Inc. All Rights Reserved. 
> Source code is available under the Sybase Open Watcom Public License. See
http://www.openwatcom.org/ for details. loading object files searching libraries
   C:\PROGRA~1\MATLAB\R2009B\BIN\MEX.PL: Error: Link of 'nlopt_optimize.mexw32'
failed. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Does anyone know how to fix
this problem?


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I've figured out what's the problem. I was using Watcom compiler instead of
Lcc-win32 compiler. But now mex file is created with Lcc compiler.
 "nlopt_optimize.mexw32"

Now I tried to implement the example as mentioned in the 

http://ab-initio.mit.edu/wiki/index.php/NLopt_Tutorial

But when I run the code (seperate m files are created for myfunc.m and
myconstraint.m)i.e.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
opt.algorithm = NLOPT_LD_MMA
opt.lower_bounds = [-inf, 0]
opt.min_objective = @(x)myfunc;
opt.fc = { (@(x) myconstraint(x,2,0)), (@(x) myconstraint(x,-1,1)) }
opt.fc_tol = [1e-8, 1e-8];
opt.xtol_rel = 1e-4;

[xopt, fmin, retcode] = nlopt_optimize(opt, [1.234 5.678])
opt.verbose = 1;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [val, gradient] = myconstraint(x,a,b)
    val = (a*x(1) + b)^3 - x(2);
    if (nargout > 1)
        gradient = [3*a*(a*x(1) + b)^2, -1];
    end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [val, gradient] = myfunc(x)
    val = sqrt(x(2));
    if (nargout > 1)
        gradient = [0, 0.5 / val];
    end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


I get the following error message

??? Invalid MEX-file 'C:\Dokumente und
Einstellungen\user\Desktop\nlopt\matlab\nlopt_optimize.mexw32': 

Does anyone has an idea to resolve this issue?






_______________________________________________
NLopt-discuss mailing list
[email protected]
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/nlopt-discuss

Reply via email to