Guidance needed in creating mexw64 file from Matlab File Exchange source code

39 views (last 30 days)
I'm looking for a very simple introduction to compiling C code into a mexw64 library file. I'm not a C programmer, but I suspect all it takes is a couple of Matlab commands. Hopefully someone out there can give me guidance!
Specifically, I wish to create a .mexw64 file from source code that I found in Matlab's File Exchange called "Polygon Clipper"
The files supplied there are:
gpc.c, gpc.h, gpc_mexfile.c, gpc_mexfile.h, PolygonClip.dll, ReadMe.txt, PolygonClip_example.m, PolygonClipper_Example.png
I have 64 bit Matlab 2010b running on Win7 64 bit, with the following toolboxes installed:
* Control System Toolbox
* Data Acquisition Toolbox
* Financial Toolbox
* Image Processing Toolbox
* Neural Network Toolbox
* Optimization Toolbox
* Robust Control Toolbox
* Signal Processing Toolbox
* Simulink
* Simulink Control Design
* Statistics Toolbox
* Symbolic Math Toolbox
* System Identification Toolbox
* Wavelet Toolbox
* Aerospace Toolbox
* Aerospace Blockset
* Bioinformatics Toolbox
* Communications Blockset
* Communications Toolbox
* Curve Fitting Toolbox
* Database Toolbox
* Datafeed Toolbox
* Embedded IDE Link™ CC (for TIs Code Composer Studio™)
* Filter Design HDL Coder™
* Filter Design Toolbox
* Fixed-Income Toolbox
* Fixed-Point Toolbox
* Fuzzy Logic Toolbox
* Genetic Algorithm and Direct Search Toolbox
* Image Acquisition Toolbox
* Instrument Control Toolbox
* MATLAB® Builder™ NE (for Microsoft® .NET Framework)
* MATLAB Compiler
* Mapping Toolbox
* Parallel Computing Toolbox™
* Partial Differential Equation Toolbox
* Real-Time Workshop
* Real-Time Workshop® Embedded Coder™
* Signal Processing Blockset
* SimEvents®
* SimHydraulics®
* SimMechanics™
* SimPowerSystems™
* Simscape™
* Simulink Fixed-Point
* Simulink HDL Coder
* Spline Toolbox
* Spreadsheet Link™ EX (for Microsoft® Excel®)
* Stateflow®
* Target Support Package™ TC2 (for TIs C2000™ DSP)
* Target Support Package™ TC6 (for TIs C6000™ DSP)
* Simulink 3D Animation™
* Vehicle Network Toolbox™
* xPC Target
Do I have everything needed to do this, or do I have to locate and install some sort of C compiler?
  4 Comments
Walter Roberson
Walter Roberson on 5 Mar 2011
Matt, you can _install_ any toolbox you like, but FlexLM keeps you from _executing_ it if you do not have the proper license.
I work for a _quite_ large company, but licensing all 54 of those toolboxes would be several times the operations budget of my sub-department.
Perhaps Scott is using Academic licenses.
Scott
Scott on 6 Mar 2011
Yes, I am in an academic environment and all of these toolboxes are available to me.

Sign in to comment.

Accepted Answer

Matt Fig
Matt Fig on 5 Mar 2011
You will need a 64-bit compiler. MS visual c++ will do the job, if you install the 64 bit version. Beware that many have indicated the 64 bit setup is tricky.
Once you have a compiler installed, do this at the command line:
mex -setup
and follow the directions.
  4 Comments
Scott
Scott on 6 Mar 2011
OK, I installed MS Visual C++ (2010) and ran mex -setup, and got an error, saying I needed to install something called a SDK. Found that and I am in the process of installing an ENORMOUS download from:
http://www.microsoft.com/downloads/details.aspx?FamilyID=6b6c21d2-2006-4afa-9702-529fa782d63b&displaylang=en
Doesn't bode well for me, as everyone is saying 64-bit compilation is tricky.
Just wondering...is there any big-hearted soul out there, who has enough experience to create a mexw64 in his/her sleep, willing to compile this code for me and post it to the File Exchange?

Sign in to comment.

More Answers (2)

Scott
Scott on 6 Mar 2011
WOW, I can't believe it worked! After installing the SDK, I ran mex -setup without a hitch. Then, at the suggestion of the code's author (thanks Sebastian!), I entered:
mex gpc.c gpc_mexfile.c -O -output PolygonClip
and it created PolygonClip.mexw64 without any complaints. Ran it in my application and it worked perfectly!
Thanks to all for the help!
Scott
  1 Comment
Scott
Scott on 7 Mar 2011
To follow up...To help others who are experiencing the same problem I did, I'm trying to submit the compiled mexw64 file to Matlab's File Exchange, but I am told:
Thank you for participating in the MATLAB Central Community. I have reviewed your submission to File Exchange and noticed it contains a MEX file. It's important for others to be able to inspect and learn from your code, so we do not publish any executable files (EXE, DLL, P- code, MEX, etc.). Please consider resubmitting your contribution including the appropriate MATLAB code without the MEX file.
Best regards,
Lindsay Coutinho
MATLAB Central Administrator
MathWorks

Sign in to comment.


Berkan Sesen
Berkan Sesen on 6 Mar 2012
Yes, this worked for me as well!

Categories

Find more on Get Started with MATLAB Compiler SDK in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!