put class into dll is one of the questions that make me trouble utill one day
when I see <com inside>'s first chapter, I get the result.
and tried in dos cmd and also VC6.
B:by hand in dos.
1:write TestCC.h
#ifdef IMPDLL
#define DLL __declspec(dllimport)
#else
#define DLL __declspec(dllexport)
#endif
class DLL TestCC{
public:
void showMe();
};
2:write TestCC.cpp
#include "stdio.h"
#include "TestCC.h"
void TestCC::showMe(){
printf("ok,here is in dll./n");
}
3:write test use
#define IMPDLL
#include "TestCC.h"
int main(){
TestCC c;
c.showMe();
return 0;
}
4:create exp and lib and def file(I can not understand realy,just try and get).
cl -c TestCC.cpp -oTestCC.dll
//althogh error,but can create lib file and other.
computer like:
D:/oracc>cl testCC.cpp -oTestCC.dll
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.
testCC.cpp
Microsoft (R) Incremental Linker Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
/out:testCC.exe
/out:TestCC.dll
testCC.obj
Creating library TestCC.lib and object TestCC.exp
LIBC.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
TestCC.dll : fatal error LNK1120: 1 unresolved externals
5:link them and create dll.
link -entry:_DllMainCRTStartup@12 -dll TestCC.exp TestCC.lib TestCC.obj
msvcrt.lib
6:use it and ok.
D:/oracc>cl useTestCC2.cpp testCC.lib
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.
useTestCC2.cpp
Microsoft (R) Incremental Linker Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
/out:useTestCC2.exe
useTestCC2.obj
testCC.lib
D:/oracc>useTestCC2
ok,here is in dll.
//------------------------------end by hand in dos.--------------------//