Matlab 2011b和mingw64

时间:2012-02-25 07:25:33

标签: matlab mingw-w64

我遵循了here的指导。

我差不多完成了工作。以下部分是批量转换工作的段落。我已经创建了一个批处理文件,用于在Matlab 2011b Windows 7(64位)中转换由MSVC预先构建的大量DLL。

    set path=C:\MinGW64\bin;C:\mingw\msys\bin;

    mkdir lib
    mkdir bin
    @echo y |copy *.dll  .\bin
    @echo y |copy *.lib  .\lib

    @echo EXPORTS >libmex.def
    @echo EXPORTS >libmx.def
    @echo EXPORTS >libmat.def
    @echo EXPORTS >libeng.def
    @echo EXPORTS >libmwlapack.def


    c:\mingw64\bin\pexports ./bin/libmex.dll | sed "s/^_//" > libmex.def
    c:\mingw64\bin\pexports ./bin/libmat.dll | sed "s/^_//" > libmat.def
    c:\mingw64\bin\pexports ./bin/libeng.dll | sed "s/^_//" > libeng.def
    c:\mingw64\bin\pexports ./bin/libmwlapack.dll | sed "s/^_//" >libmwlapack.def
    gendef ./bin/libmx.dll

    echo "Add the mexErrMsgTxt string to each def file,"
    echo "then press any key to continue the conversion process"
    pause

    lib /machine:x64 /def:libmex.def /name:.\bin\libmex.dll /out:.\lib\libmex.lib
    lib /machine:x64 /def:libmx.def  /name:.\bin\libmx.dll  /out:.\lib\libmx.lib
    lib /machine:x64 /def:libmat.def /name:.\bin\libmat.dll /out:.\lib\libmat.lib
    lib /machine:x64 /def:libeng.def /name:.\bin\libeng.dll /out:.\lib\libeng.lib
    lib /machine:x64 /def:libmwlapack.def /name:.\bin\libmwlapack.dll /out:.\lib\libmwlapack.lib

    c:\mingw64\bin\x86_64-w64-mingw32-dlltool --kill-at -U -d libmex.def -l /lib/libmex.a
    c:\mingw64\bin\x86_64-w64-mingw32-dlltool --kill-at -U -d libmat.def -l ./lib/libmat.a
    c:\mingw64\bin\x86_64-w64-mingw32-dlltool --kill-at -U -d libeng.def -l ./lib/libeng.a
    c:\mingw64\bin\x86_64-w64-mingw32-dlltool --kill-at -U -d libmx.def -l./lib/libmx.a
    c:\mingw64\bin\x86_64-w64-mingw32-dlltool --kill-at -U -d libmwlapack.def -l ./lib/libmwlapack.a

engwindemo.exe的Makefile:

    LIBS= -Lc:/mingw64/lib ../lib/libeng.a ../lib/libmx.a ../lib/
    libmex.a ../lib/libmat.a

    CC=c:/mingw64/bin/gcc -m64 -O3 -I../include -Ic:/mingw64/include

    EXE=../bin/engwindemo.exe

    SRC=engwindemo.c

    all:$(EXE)

    $(EXE):  $(SRC)
           $(CC) $(SRC) $(LIBS) -L../lib -ladvapi32 -luser32 -lgdi32 -lkernel32 -
    lmingwex -o $(EXE)
           @rm -f *.o*

使用(mingw64)gcc,编译和链接过程是可以的。执行engwindemo.exe,我收到此错误:

  

_engClose入口点错误(在libeng.dll中)

在mingw64中,如何构建一个独立的应用程序(engwindemo.exe),该应用程序从libeng.dll(Matlab R2011b)中内置的函数调用?

1 个答案:

答案 0 :(得分:-1)

  谢谢大家回复!我成功建立了!在Matlab R2011b中   win32 / 64,只是在cygwin(x86_64-w64-mingw32-gcc 4.5.2)环境中设置,没有任何dll文件转换。   主要设置部分如下

  1. 以短文件名形式设置MATLABROOT(长文件名可能没问题。)

    MATLABROOT = C:/ PROGRA〜1 / MATLAB / R2011b

  2. 链接由MSVC构建的主库

    LIBS = -L $(MATLABROOT)/ bin / win64 -lmex -lmx -lmwlapack -lmwblas -leng

  3. 使用标志

    声明gcc

    CC = x86_64-w64-mingw32-gcc

    CFLAG = -Wall -m64 -O3 -I $(MATLABROOT)/ extern / include

    MEXFLAG = -m64 -shared -DMATLAB_MEX_FILE -I $(MATLABROOT)/ extern / include -Wl, - export-all-symbols $(LIBS)

  4. 其他附加参数可以让编译器满意。

      

    最后,在cygwin consloe或mingw64 shell中只做这个项目。