由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Unix版 - help on building shared object
相关主题
how to redirect error output under unixhow to redirect the output
How to merge stdout and stderr50伪币:请教perl代码差错的问题!多谢啦!
how to see the output to stderr?Linux with Linksys 10/100 PC card
有人知道吗?Re: 怎样知道程序运行时间?time 什么来着?升级kernel失败
为什么time命令无法重定向?[转载] 紧急求助
How to redirect error messages to a file?[转载] Re: how to make the new window get the focus automati
unix下编译fortran 的错误太多,看不到怎么办?Who has WinLinux 2000 for Win98??
如何将到stderr的输出重定向到文件?初级问题:怎么打开.rpm文件阿?
相关话题的讨论汇总
话题: foo话题: shared话题: object话题: building话题: handle
进入Unix版参与讨论
1 (共1页)
i*o
发帖数: 149
1
To build a shared object( .so file),I used following commond:
gcc -fPIC -shared -o output.so input.c
and foo( ) is a function defined in input.c
In order to call foo, I did following in calling process:
void * handle = dlopen("output.so",RTLD_LAZY);
if((error=dlerror())!=NULL){
fputs(error,stderr);
exit(1);
}
foo = dlsym(handle,"foo");
foo()...
However, I got result:
./output.so: undefined symbol: foo
I am pretty sure the problem is from the shared object output.so which was not
m*******m
发帖数: 182
2
Maybe you want to use gnu libtool.

【在 i*o 的大作中提到】
: To build a shared object( .so file),I used following commond:
: gcc -fPIC -shared -o output.so input.c
: and foo( ) is a function defined in input.c
: In order to call foo, I did following in calling process:
: void * handle = dlopen("output.so",RTLD_LAZY);
: if((error=dlerror())!=NULL){
: fputs(error,stderr);
: exit(1);
: }
: foo = dlsym(handle,"foo");

T********r
发帖数: 6210
3
try this way:
gcc -fPIC -shared -o output.so input.c -ldl -lc

【在 i*o 的大作中提到】
: To build a shared object( .so file),I used following commond:
: gcc -fPIC -shared -o output.so input.c
: and foo( ) is a function defined in input.c
: In order to call foo, I did following in calling process:
: void * handle = dlopen("output.so",RTLD_LAZY);
: if((error=dlerror())!=NULL){
: fputs(error,stderr);
: exit(1);
: }
: foo = dlsym(handle,"foo");

i*o
发帖数: 149
4

Using command strings output.so, I found the function void foo(void) is
foo_Fv in the shared object.
Thus, we need call
foo = dlsym(handle,"foo_Fv"); instead of
By the way, I am using Redhat 6.2, I don't know why gcc

【在 T********r 的大作中提到】
: try this way:
: gcc -fPIC -shared -o output.so input.c -ldl -lc

1 (共1页)
进入Unix版参与讨论
相关主题
初级问题:怎么打开.rpm文件阿?为什么time命令无法重定向?
[转载] CUPS下HP932C配制问题求教How to redirect error messages to a file?
怎么回事?!unix下编译fortran 的错误太多,看不到怎么办?
网上哪有redhat linux 6.2 的入门电子版书籍?如何将到stderr的输出重定向到文件?
how to redirect error output under unixhow to redirect the output
How to merge stdout and stderr50伪币:请教perl代码差错的问题!多谢啦!
how to see the output to stderr?Linux with Linksys 10/100 PC card
有人知道吗?Re: 怎样知道程序运行时间?time 什么来着?升级kernel失败
相关话题的讨论汇总
话题: foo话题: shared话题: object话题: building话题: handle