loadlibrary error with 64bit dll and header

4 次查看(过去 30 天)
Hi,
I have three 64bit files (XPS_C8_DRIVERS.dll, XPS_C8_DRIVERS.lib and XPS_C8_DRIVERS.h), when trying to use
loadlibrary ('XPS_C8_DRIVERS.dll','XPS_C8_DRIVERS.h')
I get the following error:
Failed to preprocess the input file.
Output from preprocessor is:XPS_C8_DRIVERS.h
F:\XPS files\XPS_C8_DRIVERS.h(23) : fatal error C1021: invalid preprocessor command 'typedef'
My compiler is Microsoft Software Development Kit (SDK) 7.1.
I'm use to using matlab lab .mdd drivers, and this is the first time I've used .dll in matlab. Are there others things I need to do? Do I need to load the lib file as well? A code snippet from the header file is:
/*************************************************
* XPS_C8_DRIVERS.h *
* *
* Description: *
* XPS functions *
*************************************************/
// Added BaseTsd.h for dual mode 32 / 64 bit variable definitions
#include <BaseTsd.h>
#ifdef _WIN32
#ifndef DLL
#define DLL _declspec(dllimport)
#endif
#else
#define DLL
#define __stdcall
#endif
#ifdef __cplusplus
extern "C"
{
#else
#typedef INT32 bool; /* C does not know bool, only C++ */
#endif
Thanks in advance, Charles
  3 个评论
Chaitra
Chaitra 2014-6-24
编辑:Chaitra 2014-6-24
Are you able to execute these two commands successfully?
>>addpath([matlabroot '\extern\examples\shrlib'])
>>loadlibrary shrlibsample shrlibsample.h
Senaasa
Senaasa 2014-6-24
Yes, both of those commands produce no errors.

请先登录,再进行评论。

回答(2 个)

Chaitra
Chaitra 2014-6-24
编辑:Chaitra 2014-6-24
Are you able to execute these two commands successfully?
>>addpath([matlabroot '\extern\examples\shrlib'])
>>loadlibrary shrlibsample shrlibsample.h
'shrlibsample' is a library that is shipped with MATLAB. Executing these commands will help determine if the necessary compilers and tools to load libraries is present is your system.
As you mentioned that you have a 64 bit MATLAB, In order to build 64-bit binaries, the "x64 Compilers and Tools" and Microsoft Windows Software Development Kit (SDK) must both be installed. The x64 Compilers and Tools are not installed by default.
  1 个评论
Senaasa
Senaasa 2014-6-24
Yes, both of those commands produce no errors. The SDK (7.1) is installed. What are the x64 Compilers and Tools? Are those options you pick when installing matlab? From my research it seemed like the only thing I would need was SDK (7.1) http://www.mathworks.com/support/compilers/R2014a/index.html

请先登录,再进行评论。


Chaitra
Chaitra 2014-6-24
编辑:Chaitra 2014-6-25
Your code indicates that you have used #typedef preprocessor directive
#typedef INT32 bool; /* C does not know bool, only C++ */
As the error message is indicating: "invalid preprocessor command 'typedef'", can you try using this instead?
#ifndef THING_TYPE_DEFINED
#define THING_TYPE_DEFINED
typedef uint32_t thing_type
#endif

类别

Help CenterFile Exchange 中查找有关 Call C from MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by