- 论坛徽章:
- 0
|
//gen_dll.cpp
#include <stdio.h>;
#include <iostream>;
using namespace std;
extern "C++"
{
class DLLCLASS
{
private:
string oneStr;
public:
DLLCLASS(){
oneStr = "initial string.";
}
void dllprint()
{
printf( "%s\n", oneStr.c_str() );
}
};
}// extern "C++"
//dllclass.h
#include <string>;
using namespace std;
class DLLCLASS
{
private:
string oneStr;
public:
DLLCLASS();
void dllprint();
};
//testdll.cpp
#include "dllclass.h"
int main( int argc, char* argv[] )
{
DLLCLASS *pClass = new DLLCLASS();
pClass->;dllprint();
delete pClass;
return 1;
}
编译报错:
/home/seasom/testsdll>;make
aCC -AA +z -o gen_dll.o -c gen_dll.cpp
aCC -AA +z -b -o ./libdll.sl gen_dll.o
aCC -AA +z -L. -ldll -o testdll testdll.cpp
/usr/ccs/bin/ld: Unsatisfied symbols:
DLLCLASS: LLCLASS() (first referenced in testdll.o) (code)
DLLCLASS::dllprint() (first referenced in testdll.o) (code)
*** Error exit code 1
Stop.
请教原因:为什么找不到定义?-L. -ldll应该已经把动态库./libdll.sl
连接进来了呀。难道是我概念上理解不对? |
|