Chinaunix
标题:
HP 下的动态链接库的实现问题
[打印本页]
作者:
roywangt
时间:
2004-02-08 07:56
标题:
HP 下的动态链接库的实现问题
我在用户的要求下要把系统改为动态加载工作包
可以在做动态库的时候,遇到了如下问题,请高手帮忙解决。
在HP unix 用aCC编译
hello.cpp
#include<stdio.h>;
int printHello()
{
printf("hello world !\n"
;
return 1;
}
aCC -d -o hello.sl hello.cpp
main.cpp
int main()
{
int (*iRtn)() ;
void* hello;
hello = dlopen("./hello.sl",RTLD_LAZY);
if (hello == NULL)
{
printf("1 you are wrong !\n"
;
return 0;
}
iRtn = (int(*)())dlsym(hello ,"printHello"
;
if (iRtn == NULL)
{
printf("2 you are wrong !\n"
;
return 0;
}
(*iRtn)();
return 1;
}
aCC -o main main.cpp
以上方法编译后,运行的结果是printf("2 you are wrong !\n"
;
为什么不能指定sl下的函数位置呢?
作者:
watercloud
时间:
2004-02-11 14:44
标题:
HP 下的动态链接库的实现问题
dumpbin 看看 hello.sl里的export符号先。
没有用过acc不知道acc生成sl文件是不是这样做的,不过c++程序的函数名
一些编译器在导出时名字都是处理过了的,和程序里的不一样。
作者:
暴雪
时间:
2004-05-13 20:53
标题:
HP 下的动态链接库的实现问题
动态库程序hello.cpp 中要声明库里的函数
作者:
seasom
时间:
2004-07-20 12:10
标题:
HP 下的动态链接库的实现问题
在hello.cpp中加
extern "c"
{
int printHello() ;
}
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2