loadlibrary error with 64bit dll and header

조회 수: 4 (최근 30일)
Senaasa
Senaasa 2014년 6월 24일
편집: Chaitra 2014년 6월 25일
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