免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1562 | 回复: 1
打印 上一主题 下一主题

请教原因:aCC编程使用动态链接库中定义的类,编译出错。 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-07-20 16:19 |只看该作者 |倒序浏览
//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
连接进来了呀。难道是我概念上理解不对?

论坛徽章:
0
2 [报告]
发表于 2004-07-22 10:23 |只看该作者

请教原因:aCC编程使用动态链接库中定义的类,编译出错。

自己解决了,好高兴啊!
修改一个文件即可。

//gen_dll.cpp

#include <stdio.h>;
#include "dllclass.h"

#include <iostream>;
using namespace std;

DLLCLASS:LLCLASS(){
        oneStr = "initial string.";
}
void DLLCLASS:: dllprint(){
        printf( "%s\nnew version of dll.\n", oneStr.c_str() );
}
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP