juliamatlab / mexjulia

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

Build issue with jl.config #44

Open thchr opened 7 years ago

thchr commented 7 years ago

In trying to build on Windows 10, in Matlab R2017a, with the MinGW64 compiler I get the following error when running jl.config (after specifying location of julia executable):

Error & output message

                  build_cflags: '-O -I"C:\Program Files\Julia-0.5.1\include\julia" -DJULIA_ENABLE_THREADING'
        build_ldflags: '-L"C:\Program Files\Julia-0.5.1\bin\..\lib"'
         build_ldlibs: 'libjulia.dll.a'
            build_src: '"C:\Program Files\MATLAB\mexjulia\mexjulia.cpp"'
              inc_dir: 'C:\Program Files\Julia-0.5.1\include\julia'
             is_debug: 'false'
            julia_bin: 'C:\Program Files\Julia-0.5.1\bin\julia.exe'
           julia_home: 'C:\Program Files\Julia-0.5.1\bin'
             lib_base: 'julia'
              lib_dir: 'C:\Program Files\Julia-0.5.1\bin\..\lib'
             lib_path: 'C:\Program Files\Julia-0.5.1\bin\libjulia.dll'
            sys_image: 'C:\Program Files\Julia-0.5.1\lib\julia\sys.dll'
    threading_enabled: 'true'

The mex command to be executed:
mex -v -largeArrayDims -L"C:\Program Files\Julia-0.5.1\bin\..\lib" -outdir "C:\Program Files\MATLAB\mexjulia" -O -I"C:\Program Files\Julia-0.5.1\include\julia" -DJULIA_ENABLE_THREADING "C:\Program Files\MATLAB\mexjulia\mexjulia.cpp" libjulia.dll.a
Verbose mode is on.
... Looking for compiler 'MinGW64 Compiler (C++)' ...
... Looking for environment variable 'MW_MINGW64_LOC' ...Yes ('C:\ProgramData\MATLAB\SupportPackages\R2017a\MW_MinGW_4_9').
... Looking for file 'C:\ProgramData\MATLAB\SupportPackages\R2017a\MW_MinGW_4_9\bin\g++.exe' ...Yes.
... Looking for folder 'C:\ProgramData\MATLAB\SupportPackages\R2017a\MW_MinGW_4_9' ...Yes.
Found installed compiler 'MinGW64 Compiler (C++)'.
Set PATH = C:\ProgramData\MATLAB\SupportPackages\R2017a\MW_MinGW_4_9\bin;C:\Program Files\MATLAB\R2017a\extern\include\win64;C:\Program Files\MATLAB\R2017a\extern\include;C:\Program Files\MATLAB\R2017a\simulink\include;C:\Program Files\MATLAB\R2017a\lib\win64;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\texlive\2015\bin\win32;C:\Program Files\MATLAB\R2017a\runtime\win64;C:\Program Files\MATLAB\R2017a\bin;C:\Program Files\MATLAB\R2014a\runtime\win64;C:\Program Files\MATLAB\R2014a\bin;C:\Program Files\MATLAB\R2014a\polyspace\bin;C:\Program Files\VanDyke Software\Clients\;C:\Program Files (x86)\Skype\Phone\;C:\Users\USERNAME\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Julia-0.5.1\bin
Set INCLUDE = C:\ProgramData\MATLAB\SupportPackages\R2017a\MW_MinGW_4_9\include;C:\ProgramData\MATLAB\SupportPackages\R2017a\MW_MinGW_4_9\include;
Set LIB = C:\ProgramData\MATLAB\SupportPackages\R2017a\MW_MinGW_4_9\lib;;C:\ProgramData\MATLAB\SupportPackages\R2017a\MW_MinGW_4_9\lib;;
Set MW_TARGET_ARCH = win64;win64;
Set LIBPATH = C:\Program Files\MATLAB\R2017a\extern\lib\win64;C:\Program Files\MATLAB\R2017a\extern\lib\win64;
Options file details
-------------------------------------------------------------------
    Compiler location: C:\ProgramData\MATLAB\SupportPackages\R2017a\MW_MinGW_4_9
    Options file: C:\Users\USERNAME\AppData\Roaming\MathWorks\MATLAB\R2017a\mex_C++_win64.xml
    CMDLINE2 : C:\ProgramData\MATLAB\SupportPackages\R2017a\MW_MinGW_4_9\bin\g++ -m64 -Wl,--no-undefined -shared -s -Wl,"C:\Program Files\MATLAB\R2017a/extern/lib/win64/mingw64/exportsmexfileversion.def" C:\Users\USERNAME~1\AppData\Local\Temp\mex_463448389041802_14228\mexjulia.obj C:\Users\USERNAME~1\AppData\Local\Temp\mex_463448389041802_14228\cpp_mexapi_version.obj   libjulia.dll.a  "-LC:\Program Files\Julia-0.5.1\bin\..\lib"   -L"C:\Program Files\MATLAB\R2017a\extern\lib\win64\mingw64" -llibmx -llibmex -llibmat -lm -llibmwlapack -llibmwblas -o "C:\Program Files\MATLAB\mexjulia\mexjulia.mexw64"
    CXX : C:\ProgramData\MATLAB\SupportPackages\R2017a\MW_MinGW_4_9\bin\g++
    COMPILER : C:\ProgramData\MATLAB\SupportPackages\R2017a\MW_MinGW_4_9\bin\g++
    DEFINES : -DTARGET_API_VERSION=700  -DJULIA_ENABLE_THREADING  -DMX_COMPAT_64  -DUSE_MEX_CMD   -m64 -DMATLAB_MEX_FILE 
    MATLABMEX : -DMATLAB_MEX_FILE 
    CFLAGS : -fexceptions -fno-omit-frame-pointer
    CXXFLAGS : -fexceptions -fno-omit-frame-pointer -std=c++11
    INCLUDE : -I"C:\Program Files\Julia-0.5.1\include\julia"  -I"C:\Program Files\MATLAB\R2017a/extern/include" -I"C:\Program Files\MATLAB\R2017a/simulink/include"
    CXXOPTIMFLAGS : -O -DNDEBUG
    CXXDEBUGFLAGS : -g
    LDXX : C:\ProgramData\MATLAB\SupportPackages\R2017a\MW_MinGW_4_9\bin\g++
    LINKER : C:\ProgramData\MATLAB\SupportPackages\R2017a\MW_MinGW_4_9\bin\g++
    LDFLAGS : -m64 -Wl,--no-undefined
    LDTYPE : -shared
    LINKEXPORT : -Wl,"C:\Program Files\MATLAB\R2017a/extern/lib/win64/mingw64/mexFunction.def"
    LINKEXPORTVER : -Wl,"C:\Program Files\MATLAB\R2017a/extern/lib/win64/mingw64/exportsmexfileversion.def"
    LIBLOC : C:\Program Files\MATLAB\R2017a\extern\lib\win64\mingw64
    LINKLIBS : libjulia.dll.a  "-LC:\Program Files\Julia-0.5.1\bin\..\lib"   -L"C:\Program Files\MATLAB\R2017a\extern\lib\win64\mingw64" -llibmx -llibmex -llibmat -lm -llibmwlapack -llibmwblas
    LDOPTIMFLAGS : -s
    LDDEBUGFLAGS : -g
    OBJEXT : .obj
    LDEXT : .mexw64
    SETENV : set COMPILER=C:\ProgramData\MATLAB\SupportPackages\R2017a\MW_MinGW_4_9\bin\g++
                set CCOMPILER=C:\ProgramData\MATLAB\SupportPackages\R2017a\MW_MinGW_4_9\bin\gcc
                set COMPFLAGS=-c -fexceptions -fno-omit-frame-pointer -std=c++11 -DTARGET_API_VERSION=700  -DJULIA_ENABLE_THREADING  -DMX_COMPAT_64  -DUSE_MEX_CMD   -m64 -DMATLAB_MEX_FILE  -DMATLAB_MEX_FILE 
                set CCOMPFLAGS=-c -fexceptions -fno-omit-frame-pointer -DTARGET_API_VERSION=700  -DJULIA_ENABLE_THREADING  -DMX_COMPAT_64  -DUSE_MEX_CMD   -m64 -DMATLAB_MEX_FILE  -DMATLAB_MEX_FILE 
                set OPTIMFLAGS=-O -DNDEBUG
                set DEBUGFLAGS=-g
                set LINKER=C:\ProgramData\MATLAB\SupportPackages\R2017a\MW_MinGW_4_9\bin\g++
                set CLINKER=C:\ProgramData\MATLAB\SupportPackages\R2017a\MW_MinGW_4_9\bin\gcc
                set LINKFLAGS=-m64 -Wl,--no-undefined -shared libjulia.dll.a  "-LC:\Program Files\Julia-0.5.1\bin\..\lib"   -L"C:\Program Files\MATLAB\R2017a\extern\lib\win64\mingw64" -llibmx -llibmex -llibmat -lm -llibmwlapack -llibmwblas -Wl,"C:\Program Files\MATLAB\R2017a/extern/lib/win64/mingw64/mexFunction.def"
                set LINKDEBUGFLAGS=-g
                set NAME_OUTPUT= -o "%OUTDIR%%MEX_NAME%%MEX_EXT%"
    MINGWROOT : C:\ProgramData\MATLAB\SupportPackages\R2017a\MW_MinGW_4_9
    MATLABROOT : C:\Program Files\MATLAB\R2017a
    ARCH : win64
    SRC : "C:\Program Files\MATLAB\mexjulia\mexjulia.cpp";"C:\Program Files\MATLAB\R2017a\extern\version\cpp_mexapi_version.cpp"
    OBJ : C:\Users\USERNAME~1\AppData\Local\Temp\mex_463448389041802_14228\mexjulia.obj;C:\Users\USERNAME~1\AppData\Local\Temp\mex_463448389041802_14228\cpp_mexapi_version.obj
    OBJS : C:\Users\USERNAME~1\AppData\Local\Temp\mex_463448389041802_14228\mexjulia.obj C:\Users\USERNAME~1\AppData\Local\Temp\mex_463448389041802_14228\cpp_mexapi_version.obj 
    SRCROOT : C:\Program Files\MATLAB\mexjulia\mexjulia
    DEF : C:\Users\USERNAME~1\AppData\Local\Temp\mex_463448389041802_14228\mexjulia.def
    EXP : "C:\Program Files\MATLAB\mexjulia\mexjulia.exp"
    LIB : "C:\Program Files\MATLAB\mexjulia\mexjulia.lib"
    EXE : "C:\Program Files\MATLAB\mexjulia\mexjulia.mexw64"
    ILK : "C:\Program Files\MATLAB\mexjulia\mexjulia.ilk"
    MANIFEST : "C:\Program Files\MATLAB\mexjulia\mexjulia.mexw64.manifest"
    TEMPNAME : C:\Program Files\MATLAB\mexjulia\mexjulia
    EXEDIR : C:\Program Files\MATLAB\mexjulia\
    EXENAME : mexjulia
    OPTIM : -O -DNDEBUG
    LINKOPTIM : -s
    CMDLINE1_0 : C:\ProgramData\MATLAB\SupportPackages\R2017a\MW_MinGW_4_9\bin\g++ -c -DTARGET_API_VERSION=700  -DJULIA_ENABLE_THREADING  -DMX_COMPAT_64  -DUSE_MEX_CMD   -m64 -DMATLAB_MEX_FILE  -I"C:\Program Files\Julia-0.5.1\include\julia"  -I"C:\Program Files\MATLAB\R2017a/extern/include" -I"C:\Program Files\MATLAB\R2017a/simulink/include" -fexceptions -fno-omit-frame-pointer -std=c++11 -O -DNDEBUG "C:\Program Files\MATLAB\mexjulia\mexjulia.cpp" -o C:\Users\USERNAME~1\AppData\Local\Temp\mex_463448389041802_14228\mexjulia.obj
    CMDLINE1_1 : C:\ProgramData\MATLAB\SupportPackages\R2017a\MW_MinGW_4_9\bin\g++ -c -DTARGET_API_VERSION=700  -DJULIA_ENABLE_THREADING  -DMX_COMPAT_64  -DUSE_MEX_CMD   -m64 -DMATLAB_MEX_FILE  -I"C:\Program Files\Julia-0.5.1\include\julia"  -I"C:\Program Files\MATLAB\R2017a/extern/include" -I"C:\Program Files\MATLAB\R2017a/simulink/include" -fexceptions -fno-omit-frame-pointer -std=c++11 -O -DNDEBUG "C:\Program Files\MATLAB\R2017a\extern\version\cpp_mexapi_version.cpp" -o C:\Users\USERNAME~1\AppData\Local\Temp\mex_463448389041802_14228\cpp_mexapi_version.obj
-------------------------------------------------------------------
Building with 'MinGW64 Compiler (C++)'.
C:\ProgramData\MATLAB\SupportPackages\R2017a\MW_MinGW_4_9\bin\g++ -c -DTARGET_API_VERSION=700  -DJULIA_ENABLE_THREADING  -DMX_COMPAT_64  -DUSE_MEX_CMD   -m64 -DMATLAB_MEX_FILE  -I"C:\Program Files\Julia-0.5.1\include\julia"  -I"C:\Program Files\MATLAB\R2017a/extern/include" -I"C:\Program Files\MATLAB\R2017a/simulink/include" -fexceptions -fno-omit-frame-pointer -std=c++11 -O -DNDEBUG "C:\Program Files\MATLAB\mexjulia\mexjulia.cpp" -o C:\Users\USERNAME~1\AppData\Local\Temp\mex_463448389041802_14228\mexjulia.obj
Error using mex
C:\Program Files\MATLAB\mexjulia\mexjulia.cpp: In function 'void mexFunction(int, mxArray**, int, const
mxArray**)':
C:\Program Files\MATLAB\mexjulia\mexjulia.cpp:46:97: error: cannot convert 'jl_value_t* {aka _jl_value_t*}' to
'jl_datatype_t* {aka _jl_datatype_t*}' for argument '1' to 'jl_value_t* jl_apply_array_type(jl_datatype_t*,
size_t)'
             args[1] = jl_apply_array_type(reinterpret_cast<jl_value_t *>(jl_voidpointer_type), 1);
                                                                                                 ^

Error in jl.build (line 288)
            eval(mex_cmd);

Error in jl.config (line 268)
            jl.build;

I'm not sure if this issue is related to #41?

In addition: I noted the following minor issue in jl.m on line 246 - if the path includes spaces, the mex command will not execute (at least on my machine); it appears fixable by changing src to ['"' src "'"] (though I'm not sure whether this issue also relates to the above?)

umbertosaetti commented 4 years ago

Having the same problem.