Invalid MEX-file CPgetdirectories.mexw32


I have encountered the following error message when I used the attached pipeline to open images in subfolders:

There was a problem running the image analysis. Sorry, it is unclear what the problem is. It would be wise to close the entire CellProfiler program in case something strange has happened to the settings. The output file may be unreliable as well. Matlab says the error is: Invalid MEX-file ‘C:\Program Files\CellProfiler\CPsubfunctions\CPgetdirectories.mexw32’: This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem.
. in the LoadImages module, which is module #01 in the pipeline.
CPgetdirectorytree in C:\Program Files\CellProfiler\CPsubfunctions\CPgetdirectorytree.m (17)
CPretrievemediafilenames in C:\Program Files\CellProfiler\CPsubfunctions\CPretrievemediafilenames.m (81)
LoadImages in C:\Program Files\CellProfiler\Modules\LoadImages.m (615)
AnalyzeImagesButton_Callback in C:\Program Files\CellProfiler\CellProfiler.m (4505)
gui_mainfcn in C:\Program Files\CellProfiler\CellProfiler.m (6265)
CellProfiler in C:\Program Files\CellProfiler\CellProfiler.m (55)

I am using the newest CellProfiler version (1.0.7522) and tried both the windows binaries and the developer’s version on two different machines. The pipeline works fine when I use it only on one folder.

I hope I haven’t missed anything obvious. Let me know if I can provide any additional information. Your help would be very much appreciated!
CPSegmentationPipelineSubFolders.mat (1.42 KB)


Does the error occur on the compiled version, or just in the Developer’s, or both? It would be a slightly different issue in each case. The CPgetdir subfunction has cpp code that has to be compiled on separate platforms; if you are getting an error with the compiled version, it may be because you downloaded Windows Vista 32-bit but you actually have Windows XP 64-bit for example. If you are getting an error with the developer’s version, it may be that all the dlls you need for you the mex file to work are not on your path.

Can you be more specific, and let us know which CP you downloaded, and which architecture you’re on?



Thanks for your reply. I downloaded both the developer’s code version 1.0.7522 and the compiled 32-bit Windows XP version (I am running 32-bit Windows XP on both the machines I tested). I get the same error message with both versions. I tried to first do a fresh install of the compiled binaries on a machine where there wasn’t any CellProfiler installed before and could reproduce the error. Than I removed the compiled version and installed the developer’s version, and got the error message again. The CPgetdirectories.mexw32 and CPgetdirectories.c files are in the CPsubfunctions folder, which is included in the Matlab path.

Thanks for your help,

Also make sure that your Modules directory is pointed to the correct directory (Last entry in File -> Set prefs)

The only other thing I can think of is you are using a newer or older version of Matlab/ matlab MCR. This version of CP (and the mex file) were both compiled on 2008a, or v7.6 (the MCR should be v78). So if you’re trying to use an MCR that’s newer or older, or a Matlab that’s newer or older, that could be the problem. Since you have matlab, you can always recompile the file with the command

mex CPgetdirectories.c

which should create a CPgetdirectories.mex. Then you can replace the troublesome CPgetdir with the file you created.


Thanks for the suggestions. I am using 2008b on one machine, and 2009a on the other, so that could be one explanation. However, the MCR I used was 7.8. The modules directory is set correctly in CellProfiler. Surprisingly, compiling CPgetdirectories.c resulted in the following error message with both Matlab 2008b and 2009a:

mex CPgetdirectories.c
Error C:\PROGRA~1\CP_DEV~1\CPSUBF~1\CPgetdirectories.c: 89 undeclared identifier FindExInfoStandard' Error C:\PROGRA~1\CP_DEV~1\CPSUBF~1\CPgetdirectories.c: 91 undeclared identifierFindExSearchLimitToDirectories’
Error C:\PROGRA~1\CP_DEV~1\CPSUBF~1\CPgetdirectories.c: 93 operands of = have illegal types pointer to void' andint’
Warning C:\PROGRA~1\CP_DEV~1\CPSUBF~1\CPgetdirectories.c: 91 possible usage of FindExSearchLimitToDirectories before definition
Warning C:\PROGRA~1\CP_DEV~1\CPSUBF~1\CPgetdirectories.c: 89 possible usage of FindExInfoStandard before definition
3 errors, 2 warnings

Do you have an idea what could be causing this, e.g. a missing/wrong .h file?


Hm, try mex -setup and make sure you chose the gcc compiler?

I used the lcc compiler that comes with Matlab:

Lcc-win32 C 2.4.1 in C:\PROGRA~1\MATLAB\R2008b\sys\lcc

Re: the subfolders issue, your pipeline file is possibly corrupt. Your pipeline gets to this line:

when it shouldn’t, according to your pipeline when I loaded it up. To be clear, did you want to choose the LoadImages settings “Analyze all subfolders…” = “Yes” and “If Yes to Analyze all subfolders…” = “No”?

If these settings are what you want, then the safest thing to do is to remove your LoadImages module and add it afresh, with all the same settings.

Interestingly, I have just installed CellProfiler (developer’s version) on my Mac notebook and ran the same pipeline on the same files that gave me the error message on the PC. Surprisingly (or not), it runs just fine on the Mac, opening images in the subfolders without giving any error message. So I assume that somehow, the mex file for win32 did get messed up on my PC…

I am very sorry to keep bothering you with this issue. Although the pipeline runs on my mac notebook now, I would really like to also be able to run it on the PCs. I guess the test on the Mac showed that it is not the pipeline, but something in the CellProfiler installation on the windows machines. I tried again to compile the c-file without success, although I didn’t have any trouble compiling other files, e.g. CPdir.c or sample_sub.c. I also tried different Matlab versions (2006a, 2008b, and 2009a), all giving the same error message. I have attached the CPgetdirectories.c file that came with the distribution (with changed extension, to be able to upload it). Could maybe somebody try to compile it on a PC?

Thank you guys so much for helping me with this!
CPgetdirectories.c.m (6.84 KB)

OK, I just compiled it. Give this a try (after renaming the extension).

If this still doesn’t work, you might be running into the problem similar to that described here. In that case, go here, download and install the Redistributable Package and try again.
CPgetdirectories.mexw32.m (9 KB)

Good call, Mark! Installing the Visual C++ Redistributable Package solved the issue.
Thank you very much for your help!

Good to hear! We’ll probably link to this thread in case others have similar issues.