【发布时间】:2012-04-06 05:12:56
【问题描述】:
我为我的渲染包装器创建了一个简单的 linux 32 位共享库 (.so),但是当我发现我只能 通过 32 位应用程序使用它们............
这就是我的代码的样子:
RendIFace.h:
//Basic renderer interface
struct Renderer
{
int type;
...other things
};
GLRend.c:
#include "RendIFace.h"
struct Renderer* GLRendererCreate(int width,int height,int bytesPerPixel)
{
struct Renderer* rend = (struct Renderer*)malloc(sizeof(Renderer));
rend->type = GLR;
..other things
return rend;
}
SDLRend.c:
#include "RendIFace.h"
struct Renderer* SDLRendererCreate(int width,int height,int bytesPerPixel)
{
struct Renderer* rend = (struct Renderer*)malloc(sizeof(Renderer));
rend->type = SDLR;
..other things
return rend;
}
我将它们编译为共享的 32 位库 (.so) 并通过主应用程序加载它们...
但是现在有一个大问题。我的库都是 32 位并返回 32 位指针,这意味着我无法通过 一个 64 位应用程序,无需重建所有库代码库(!!!)。
所以我想问问有经验的人:我如何处理这个问题?两种架构都可以只使用一个共享库吗???
【问题讨论】:
-
我认为这行不通。 DLL/SO 被加载到 程序进程。当位数不同时,我从未见过/听说过它可以工作(因为 32 位 IA32 现在正试图在 64 位 AMD64 上下文中运行,除此之外,CC 可能不同)。
-
您也在编写应用程序吗?还是只是库?
-
我正在编写应用程序和库...
标签: c linux gcc shared-libraries