2012-02-25 68 views
-3

我遵循指導,我發現hereMatlab 2011b和mingw64

我已經差不多完成了這項工作。以下部分是批量轉換工作的段落。我已經創建了一個批處理文件,用於在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:

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 entry point error (in libeng.dll)

在mingw64,我怎麼能建立一個獨立的應用程序(engwindemo.exe)從函數的調用內置的libeng.dll(Matlab的R2011b) ?

+1

請妥善格式化您的問題和澄清您的實際問題。 – Egon 2012-02-25 08:54:41

+0

>我的問題是如何構建一個通過mingw64調用matlab 2011b(64位)引擎的獨立可執行文件?在上述過程中,出現了什麼問題 – 2012-02-25 11:18:24

+0

是的,我按照附加的指導方針行事,有些事情我錯過了。 Mingw64可以生成從libeng.dll調用的獨立應用程序。事實上,它沒有運行。 – 2012-02-25 11:33:20

回答

-1

Thank everyone response! I have built up successfully! In the Matlab R2011b win32/64, just setting up in the cygwin(x86_64-w64-mingw32-gcc 4.5.2) environment without any dll file conversion. The part of primary setting is as following

  1. 設置在短文件名的形式的MATLABROOT

    MATLABROOT = C(長文件名可能是確定。):/ PROGRA〜1/MATLAB/R2011b

  2. 鏈接初級文庫由MSVC

    LIBS = -L $(MATLABROOT)/斌/ Win64中內置-lmex -lmx -lmwlapack -lmwblas -leng

  3. 聲明瞭gcc與標誌

    CC = x86_64的-W64-的mingw32-GCC

    CFLAG = -Wall -m64 -O3 -I $(MATLABROOT)/的extern /包括

    MEXFLAG = - m64 -shared -DMATLAB_MEX_FILE -I $(MATLABROOT)/ extern/include -Wl, - 導出全部符號$(LIBS)

  4. 其他附加參數以保持編譯器的快樂。

    And finally, in the cygwin consloe or mingw64 shell just make this project.

+0

你是對的! MinGW能夠「直接鏈接」到DLL(請參閱[這裏](http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/4/html/Using_ld_the_GNU_Linker/win32.html)。你的答案(不需要整個'makefile'來解釋做什麼,不需要advapi32等)。特別是,不需要'''''''''''''''''''''''''' – user1071136 2012-02-26 12:26:41