pico
pico

Reputation: 1369

How to build multiple .dll files (.mexw32 files) in single Visual Studio project?

I maintain a Matlab library that consists of huge number of MEX files. Thus far I have built the library with a Matlab script but now I would like to start using the Microsoft Visual Studio IDE for the whole build process. I have gotten pretty far with the following the instructions:

However these instructions seem to work only with a single MEX file. The problem I'm having is how to build multiple .mexw32 targets (or equivalently .dll targets) within a single Visual Studio project? Creating separate project (within the same solution) for MEX files is not an option I'm eager to consider. These files count in hundreds.

For those who are not familiar with Matlab the MEX files are extension files written in C++ and compiled essentially into .dll files with a special extension .mexw32. Each of these export a single entry point void mexFunction(...). AFAIK you cannot link these into a single .dll which is what I would prefer to do.

Upvotes: 3

Views: 2332

Answers (2)

David Heffernan
David Heffernan

Reputation: 613053

It might be easier to build this in a MATLAB script. For example a MATLAB command like this:

mex -f msvc90opts.bat MyMexFile.c

will do the job. You would obviously have one line per MEX file. The msvc90opts.bat file is based on a template supplied in the MATLAB installation folder under bin\win32\mexopts.

For my build process I then wrap these calls to mex up into a function and then invoke that from the command line using:

matlab.exe -wait -sd . -nosplash -nojvm -r "BuildMex, exit"

Upvotes: 1

detunized
detunized

Reputation: 15289

I think creating a project per MEX file and putting them into one solution is the only option. Project files are designed to represent one target, would that be a static library, a dynamic library or an executable. Solutions were designed to represent a collection of projects and how they depend on each other. That is exactly what you need.

Maybe you have to look into the possibility of automating the whole thing with some scripts to create such big number of projects and adding them to a single solution.

Upvotes: 0

Related Questions