Hello,
I've got some questions about __declspec dllimprt and dllexport. Can anyone tell me why this code doesn't work?
Code:
// DLL.h
#ifndef _CLIBRARY_H_
#define _CLIBRARY_H_
#ifdef CLIBRARY_EXPORTS
# define CLIBRARY_API __declspec(dllexport)
#else
# define CLIBRARY_API __declspec(dllimport)
#endif
extern "C" {
CLIBRARY_API
unsigned long ShowMessage(
const char* // message
);
}
#endif
Code:
// DLL.cpp
#include "stdafx.h"
extern "C"
{
ULONG ShowMessage(LPCSTR lpszMessage)
{
MessageBox(NULL, lpszMessage, "Message", 0);
return strlen(lpszMessage);
}
}
Code:
// main.cpp
#pragma comment( lib, "..\\..\\C++Library\\Release\\C++Library.lib" )
#include <iostream>
#include "..\\..\\C++Library\\C++Library\\C++Library.h"
using namespace std;
int main( int argc, char** argv )
{
cout << ShowMessage("Dies ist ein Test") << endl;
return 0;
}
My Compiler (VC 9) creates this output:
Code:
Error 1 error LNK2019: unresolved external symbol __imp__ShowMessage referenced in function _main main.obj Link_Load Library
Thanks in anticipation for some help ;-)