loadlibrary error with 64bit dll and header

4 visualizzazioni (ultimi 30 giorni)
Senaasa
Senaasa il 24 Giu 2014
Modificato: Chaitra il 25 Giu 2014
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 Commenti
Chaitra
Chaitra il 24 Giu 2014
Modificato: Chaitra il 24 Giu 2014
Are you able to execute these two commands successfully?
>>addpath([matlabroot '\extern\examples\shrlib'])
>>loadlibrary shrlibsample shrlibsample.h
Senaasa
Senaasa il 24 Giu 2014
Yes, both of those commands produce no errors.

Accedi per commentare.

Risposte (2)

Chaitra
Chaitra il 24 Giu 2014
Modificato: Chaitra il 24 Giu 2014
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 Commento
Senaasa
Senaasa il 24 Giu 2014
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

Accedi per commentare.


Chaitra
Chaitra il 24 Giu 2014
Modificato: Chaitra il 25 Giu 2014
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

Community Treasure Hunt

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

Start Hunting!

Translated by