juliamatlab / mexjulia

embedding Julia in the MATLAB process.
MIT License
52 stars 14 forks source link

Warning: It appears the mexjulia MEX function is missing. #21

Closed abmnmj closed 7 years ago

abmnmj commented 7 years ago

Hello, I'm having trouble getting the mexjulia part to work. And I really would like to get started with migrating parts of my Matlab code into julia from within the "comfort zone" of the Matlab IDE.

Set-up: Windows 7, SP1; Matlab R2015b; MinGW64 Compiler (C++); Julia 0.5.0.

>> Jl.build
The path of the Julia executable is F:\software\Julia\Julia-0.5.0\bin\julia.exe
The path of the Julia configuration script is F:\software\Julia\Julia-0.5.0\share\julia\julia-config.jl
Building with 'MinGW64 Compiler (C++)'.
MEX completed successfully.
Ensuring the MATLAB package is installed...
INFO: Nothing to be done
INFO: METADATA is out-of-date ÔÇö you may not have the latest version of MATLAB
INFO: Use `Pkg.update()` to get the latest versions of your packages
Is F:\software\Julia\mexjulia\branches\rebranding on the MATLAB path? Yes.

I have run Pkg.update() multiple times but the "out-of-date" warning persists. Reinstalled the MATLAB package and got v0.4.2.

When I run Jl.eval it asks me to select the julia executable again:

>> Jl.eval('2+2')
Warning: It appears the mexjulia MEX function is missing. Attempting to build...\n 
> In Jl.check_init (line 42)
  In Jl.mex (line 9)
  In Jl.eval (line 16) 
The path of the Julia executable is F:\software\Julia\Julia-0.5.0\bin\julia.exe
The path of the Julia configuration script is F:\software\Julia\Julia-0.5.0\share\julia\julia-config.jl
Building with 'MinGW64 Compiler (C++)'.
MEX completed successfully.
Ensuring the MATLAB package is installed...
INFO: Nothing to be done
INFO: METADATA is out-of-date ÔÇö you may not have the latest version of MATLAB
INFO: Use `Pkg.update()` to get the latest versions of your packages
Is F:\software\Julia\mexjulia\branches\rebranding on the MATLAB path? Yes.
Invalid MEX-file 'F:\software\Julia\mexjulia\branches\rebranding\mexjulia.mexw64': The specified module
could not be found.

Error in Jl.check_init (line 47)
      mexjulia('');

Error in Jl.mex (line 9)
        Jl.check_init;

Error in Jl.eval (line 16)
        [varargout{:}] = Jl.mex(nargin, 'Mex.jl_eval', varargin{:});

Checking with Matlab, the mex file appears to exist (of course I can also see it in the rebranding folder):

>> which mexjulia
F:\software\Julia\mexjulia\branches\rebranding\mexjulia.mexw64 

So I set a breakpoint on line 38 in Jl.m and try to evaluate again:

Jl.eval('2+2')
38        try

The mexjulia "module" (I assume this is something related to object-oriented programming in Matlab) has the "value":

K>> mexjulia
Invalid MEX-file 'F:\software\Julia\mexjulia\branches\rebranding\mexjulia.mexw64': The specified module 
could not be found.

And again, still in the debugger, the path to the mex-file checks out:

K>> disp(exist('F:\software\Julia\mexjulia\branches\rebranding\mexjulia.mexw64'))
     3

Do you have any ideas of what I am doing wrong based on the information provided? Should this work with the mingw compiler?

Regards, Martin

twadleigh commented 7 years ago

A quick response about MinGW: it should work fine. If it doesn't right now, we should be able to fix it. In fact, when I was first developing this, I was using the MinGW toolchain (in a custom make file) to build the mex function. It was only after getting it basically functional that I migrated to doing the build through MATLAB's mex function.

As for your particular problem here, hopefully I'll be able to dig into the issue this weekend.

Thanks for checking mexjulia out.

abmnmj commented 7 years ago

With rev.28, this now works using the above set-up. Thanks!