| 发表于:2008-01-11 14:05:50 楼主 |
请教一个关于dll的问题? /***********test1.h*****************/ class test1{ public: test1(); ~test1(); void displaytest1(); }; /**********test1.cpp*****************/ #include <iostream> using namespace std; #include "test1.h" test1::test1() { } test1::~test1() { } void test1::displaytest1() { cout < <"test1" < <endl; } 下面是我的dll的头文件 /************dlltest.h***********/ #ifdef dll1_api #else #define dll1_api _declspec(dllimport) #endif #include "test1.h" class dll1_api dlltest{ public: dlltest(); ~dlltest(); void displaydlltest(); void displaydlltest1(); private: test1 m_test1; }; /***********dlltest.cpp***********/ #define dll1_api _declspec(dllexport) #include <iostream> using namespace std; #include "dlltest.h" dlltest::dlltest() { } dlltest::~dlltest() { } void dlltest::displaydlltest() { cout < <"dlltest" < <endl; } void dlltest::displaydlltest1() { m_test1.displaytest1(); } 我使用如下代码来使用这个dll #include <iostream> using namespace std; #include "dlltest.h" void main() { dlltest test; test.displaydlltest(); test.displaydlltest1(); char a; cin> > a; } 编译时提示找不到"test1.h",如果我把test1.h添加至测试程序中就可以解决,我的问题是这种情况下是不是必须把test1.h 提供给dll的使用者,如果这样的话感觉挺别扭的,我只想提供dlltest.h,dlltest.lib dlltest.dll 请问如果想只提供这三个文件该如何解决?我不想把所有的类定义都放在dlltest.h中,所以这种方法就不要说了,谢谢各位! |
|
|
|
|