我就不信没人知道!.so文件能包含form资源并动态调入显示吗? (50分)

  • 主题发起人 一个过客
  • 开始时间

一个过客

Unregistered / Unconfirmed
GUEST, unregistred user!
linux + kylix 能实现动态调用dll函数吗? loadlibrary(....)
///////////////////
前面的问题已经解决,就剩标题的这个了
so文件能包含form资源并动态调入显示吗?
 
.o文件就是DLL
 
错了,是.so
张无忌说的是静态二进制文件.o不能动态连接,共享
 
:)我记错了
 
so文件也能够象dll那样放入form窗体资源在里面并且动态调入创建吗?
这种so文件是linux技术还是kylix自己支持的东西?
 
怎么没消息了?
 
>>"so文件是linux技术还是kylix自己支持的东西"
so是Linux本身支持的,Unix也支持
 
自己生成也很简单,也就是ar,ranlib之类的工具
 
总算有明白人了,那么还剩最后一点:
so文件也能够象dll那样放入form窗体资源在里面并且动态调入创建吗?
 
我记得以前在 ibm 的 linux develop 文章区里面有在 linux 下使用
动态连接的例子。你可以找来看看,不过是 C 实现的
 
你说的这个东西其实在gui设计的时候已经有了,你可以参考qt(www.trolltech.com)
 
拜托说明白一点,到底能不能在so里面装入form资源,然后动态调入显示?
我目前只是想知道这样做的可行性,还没具体考虑要怎样做。多谢了
 
来学习的 帮提
 
这是我测试的代码

library DllTest;

{ Important note about exception handling across multiple
binary modules (EXEs and shared objects):
All projects must be built with the same version of the
baseclx runtime package for exception handling to work.
If this is not the case, exceptions raised in one module
may cause unintended side-effects in other modules. }
uses SysUtils;

// stdcall: with c call, must user "cdecl"
function Test(X: Integer;
var Y: integer;
str: PChar): Integer;
cdecl;
//stdcall;
begin

Y:= X+1;
StrCopy(str, 'HELLO Linux String argument');
Result:= X;
end;

exports
Test;
begin
end.

以下用kylix调用
program Project1;
{$APPTYPE CONSOLE}
uses SysUtils;
function Test(X: Integer;
var Y: integer;
str: PChar): Integer;
cdecl;
external 'libDllTest.so';
var
X, Y: integer;
str: array [0..1024] of Char;
begin
X:= 100;
X:= Test(X, Y, str);
writeln(Format('X=%d, Y=%d, str=%s', [X, Y, str]));
readln;
end.



以下用c调用
// Load the math library, and print the cosine of 2.0:
/* If this program were in a file named "foo.c", you would
build the program with the following command:
gcc -rdynamic -o CTest CTest.c -ldl
*/
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
int main(int argc, char **argv) {
void *handle;
int (*Test)(int, int *, char*);
char *error;
int X, Y;
char pstr[1024];
handle = dlopen ("./libDllTest.so", RTLD_LAZY);
if (!handle) {
fputs (dlerror(), stderr);
exit(1);
}
Test = dlsym(handle, "Test");
if ((error = dlerror()) != NULL) {
fprintf (stderr, "%s/n", error);
exit(1);
}

X = (*Test)(300, &amp;Y, pstr);
printf ("Test()=%d Y=%d STR=%s/n", X, Y, pstr);
dlclose(handle);
getchar();
}
 
简单的dll应该可以实现,前面的兄弟已经说了。不过我想知道的是能不能
把form资源放在so里面,然后动态调入并显示??
 
没用过。
一个过客,我已经给你开了贴子,进来收分先。
http://www.delphibbs.com/delphibbs/dispq.asp?lid=1227575
 
呵呵,受到了。被拍的感觉号舒服哦
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
顶部