필터 지우기
필터 지우기

Problem trying to load .dll library using 'loadlibrary', error is, A 'Selected' compiler was not found. You may need to run mex -setup.

조회 수: 29 (최근 30일)
I am a beginner on using the loadlibrary function and using .dll files, so I will appreciate any help I can get.
I am trying to load a .dll file with a header file, I am using:
>> loadlibrary('nameoflibrarydll', 'nameofheaderfile')
and it comes up with the error:
??? Error using ==> loadlibrary at 264 A 'Selected' compiler was not found. You may need to run mex -setup.
I do not understand what 'mex' is?
I think a problem is is that the .dll file is written using an old version of Matlab, and it needs to be used using Matlab 2011a. This is so that I can access functions from the header file, the codes of which probably need updating also to run in the new version of Matlab.
I also tried the same line of code for loadlibrary on a different computer and it comes up with the error:
C:\Users\User One\Documents\MATLAB Pentools\Wintab32.dll is not a valid Win32 application.
I understand the problem is to do with 32 bit and 64 bit versions of windows, but I do not understand what this means. If anyone could help explain what all the terminology means and how you think I may be able to proceed with accessing the .dll file, I would be most grateful.

채택된 답변

Friedrich
Friedrich 2012년 2월 13일
Hi,
in order to use loadlibrary you need to choose a compiler. In order to choose a compiler run
mex -setup
This starts a small setup routine in which you select your compiler.
In addition, 32bit ML can load 32bit DLLs only. 64bit ML can load 64bit DLLs only.
How was the DLL generated? I hope not with the MATLAB Compiler, because you shouldn't/can't load ML Compiler generated DLLs in MATLAB. They are not designed to work with loadlibrary and will most likely crash ML.
  댓글 수: 6
hde
hde 2012년 2월 16일
That would appear to be a good solution, using the DLL outside of MATLAB. Are you able to recommend any good documentation for creating an application using c or c++ in Visual studio that will allow me to call up functions in Matlab, from Visual studio, which then links to the DLL? I have not used c or c++ before so any hints to go about this would be great?
Thanks for your ideas, I am most grateful.
Friedrich
Friedrich 2012년 2월 17일
I meant using C/C++ and the DLL only to check if the DLL can be used at all (so no MATLAB involved here). There a several guides in the internet showing you how to use a DLL:
http://www.flipcode.com/archives/Creating_And_Using_DLLs.shtml

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Pang Pang
Pang Pang 2017년 8월 17일
In environment, select add-on. Search for MinGW-w64 Compiler and install. Just type in (mex -setup) without the parentheses in the command window once installation finishes.

카테고리

Help CenterFile Exchange에서 C Shared Library Integration에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by