Building .mexw64 files from c++ dlls

13 views (last 30 days)
Stefan
Stefan on 13 Jan 2015
Commented: Stefan on 13 Jan 2015
I want to use C++ DLLs in Matlab. I did all Installations that are required for my Matlab 2010b Version ( Requirements for 64 Bit Compilers): Windows SDK 6.1, Visual Studio C++ 2008 Express SP1 with all required installation points like 64 Bit compilers etc.
When I now use loadlibrary
fullpathToHeader = 'C:\Users\huellinghorst\Documents\MATLAB\ImagerIPC2.h'; fullpathToDll = 'C:\Users\huellinghorst\Documents\MATLAB\ImagerIPC2.lib';
loadlibrary(fullpathToDll, fullpathToHeader);
I get the error
??? Error using ==> loadlibrary at 365 Failed to preprocess the input file. Output from preprocessor is:Der Befehl "cl" ist entweder falsch geschrieben oder konnte nicht gefunden werden. "The command "cl" is either spelled wrong or couldnt be found"
If I try to mex the files (mex -setup is linked to the 2008 VS) I get the following error:
Microsoft (R) Incremental Linker Version 9.00.21022.08 Copyright (C) Microsoft Corporation. All rights reserved.
ImagerIPC2.lib LINK : warning LNK4001: no object files specified; libraries used LINK : error LNK2001: unresolved external symbol mexFunction C:\Users\HUELLI~1\AppData\Local\Temp\mex_JP_oqF\templib.x : fatal error LNK1120: 1 unresolved externals
C:\PROGRA~1\MATLAB\R2010B\BIN\MEX.PL: Error: Link of 'ImagerIPC2.mexw64' failed.
??? Error using ==> mex at 208 Unable to complete successfully.
While the mex example yprime.c works, my c++ files are linked wrongly. Can anybody help me?
The DLLs, Header and Library files are attached.
Thanks in advance!
  1 Comment
Philip Borghesani
Philip Borghesani on 13 Jan 2015
The attached file appears to be in 7z format. Was it created with 7 zip and renamed? Winzip 12.1 could not open it.

Sign in to comment.

Answers (1)

Philip Borghesani
Philip Borghesani on 13 Jan 2015
There are a many things going wrong here but the biggest problem is that you have a 32 bit dll and 64 bit MATLAB. That will not work, you will need to install 32 bit MATLAB or get a 64 bit copy of the dll.
Second problem: In MATLAB versions prior to R2011a loadlibrary did not make use of mex -setup and could only use the full version of Visual Studio for loading a 64 bit library.
This library has many functions that make use of c callbacks you may not be able to use it without writing your own mex file because callbacks are not supported by loadlibrary. Writing a mex file that can properly use c callbacks and transfer the data back to MATLAB is not a trivial undertaking.
  1 Comment
Stefan
Stefan on 13 Jan 2015
Ok thanks for the answer, I organized the x64 dlls and upgraded to Matlab 2014b. Loadlibrary (Using Windows SDK 7.1 as compiler) has problems with the datatypes and a lot of expressions, it seems ther is no compilation made.
What would be your suggestion to realize my approach? Im not really good at C++, you think its realistic to write a wrapper within 2 weeks not really having knowledge in c++?

Sign in to comment.

Categories

Find more on Troubleshooting in 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!