C
Chavoux
Hi When I try to compile the following code I get an error:
[Linker error: undefined reference to `_imp__CreatePort@4'
....
<code>
#include <cstdlib>
#include <iostream>
#include "sDriverDLL.h"
using namespace std;
char * EXTERN InttoStr(int n, char * buff, int radix);
#ifdef __cplusplus
extern "C"
{
#endif //*/
int EXTERN CreatePort(char * PrtName);
int EXTERN OpenPort();
int EXTERN ReadaPacket(char * Packet);
int EXTERN ReadaTag(char * TagStr);
int EXTERN ClosePort();
int EXTERN FreePort();
#ifdef __cplusplus
}
#endif
//*/
int main(int argc, char *argv[])
{
cout << "starting... Creating COMPORT1";
int x = CreatePort("COM1");
}
</code>
I'm using Dev-C++ (minGW compiler) on Windows XP.
In the "sDriverDLL.h" file EXTERN is is declared as follows:
<code>
#if BUILDING_DLL
#define EXTERN __declspec (dllexport) __stdcall
#else /* Not BUILDING_DLL */
#define EXTERN __declspec (dllimport) __stdcall
#endif /* Not BUILDING_DLL */
</code>
The header file also includes the whole section:
<code>
#ifdef __cplusplus
extern "C"
{
#endif //*/
int EXTERN CreatePort(char * PrtName);
.....
#ifdef __cplusplus
}
#endif
</code>
I can actually import the .dll file into Delphi (!), but can't seem to
import it into C++ itself. What am I missing?
Thanks
Chavoux
[Linker error: undefined reference to `_imp__CreatePort@4'
....
<code>
#include <cstdlib>
#include <iostream>
#include "sDriverDLL.h"
using namespace std;
char * EXTERN InttoStr(int n, char * buff, int radix);
#ifdef __cplusplus
extern "C"
{
#endif //*/
int EXTERN CreatePort(char * PrtName);
int EXTERN OpenPort();
int EXTERN ReadaPacket(char * Packet);
int EXTERN ReadaTag(char * TagStr);
int EXTERN ClosePort();
int EXTERN FreePort();
#ifdef __cplusplus
}
#endif
//*/
int main(int argc, char *argv[])
{
cout << "starting... Creating COMPORT1";
int x = CreatePort("COM1");
}
</code>
I'm using Dev-C++ (minGW compiler) on Windows XP.
In the "sDriverDLL.h" file EXTERN is is declared as follows:
<code>
#if BUILDING_DLL
#define EXTERN __declspec (dllexport) __stdcall
#else /* Not BUILDING_DLL */
#define EXTERN __declspec (dllimport) __stdcall
#endif /* Not BUILDING_DLL */
</code>
The header file also includes the whole section:
<code>
#ifdef __cplusplus
extern "C"
{
#endif //*/
int EXTERN CreatePort(char * PrtName);
.....
#ifdef __cplusplus
}
#endif
</code>
I can actually import the .dll file into Delphi (!), but can't seem to
import it into C++ itself. What am I missing?
Thanks
Chavoux