制作动态链接在Mac OS X雪豹32位库64位共享库 [英] Making a 64 bit shared library that dynamically links to a 32 bit library on Mac OS X Snow Leopard

查看:419
本文介绍了制作动态链接在Mac OS X雪豹32位库64位共享库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:经过一些更多的阅读我认为,这个问题完全是一般的,你不能混用架构在同一个过程,所以64位Java不能的dlopen()一个32位的库像FMOD。是否有任何可能解决此,牢记我写我自己的C接口FMOD库?

Update: After some more reading I see that this problem is totally general, you can't mix architectures in the same process, so 64 bit Java cannot dlopen() a 32 bit library like FMOD. Is there any possible workaround for this, keeping in mind I'm writing my own C interface to the FMOD library?

我需要一个64位的dylib在最大OS X 因为只有Java本地访问喜欢在64位机中的64位资料库。问题是,我的C源代码code动态包括FMOD它在Mac上只提供32位dylibs。当我尝试不-m32选项编译(因为我必须输出64位dylib)我得到以下错误:

I need to make a 64-bit dylib on Max OS X because Java Native Access only likes 64-bit libraries on 64-bit machines. The problem is, my C source code dynamically includes FMOD which on Mac only provides 32-bit dylibs. When I try to compile without the -m32 option (since I must output a 64-bit dylib) I get the following error:

    gcc -dynamiclib -std=c99 -pedantic -Wall -O3 -fPIC -pthread -o  ../bin/libpenntotalrecall_fmod.dylib ../../src/libpenntotalrecall_fmod.c -lfmodex -L../../lib/osx/

    ld: warning: in /usr/lib/libfmodex.dylib, missing required architecture x86_64 in file
    Undefined symbols:
      "_FMOD_System_CreateSound", referenced from:
          _startPlayback in ccJnlwrd.o
      "_FMOD_Channel_GetPosition", referenced from:
          _streamPosition in ccJnlwrd.o
      "_FMOD_System_Create", referenced from:
          _startPlayback in ccJnlwrd.o
      "_FMOD_System_PlaySound", referenced from:
          _startPlayback in ccJnlwrd.o
      "_FMOD_Sound_Release", referenced from:
          _stopPlayback in ccJnlwrd.o
      "_FMOD_Channel_IsPlaying", referenced from:
          _playbackInProgress in ccJnlwrd.o
      "_FMOD_System_Update", referenced from:
          _streamPosition in ccJnlwrd.o
          _startPlayback in ccJnlwrd.o
      "_FMOD_Channel_SetPaused", referenced from:
          _startPlayback in ccJnlwrd.o
      "_FMOD_System_Release", referenced from:
          _stopPlayback in ccJnlwrd.o
      "_FMOD_System_Init", referenced from:
          _startPlayback in ccJnlwrd.o
      "_FMOD_Channel_SetVolume", referenced from:
          _startPlayback in ccJnlwrd.o
      "_FMOD_System_Close", referenced from:
          _stopPlayback in ccJnlwrd.o
      "_FMOD_Channel_SetCallback", referenced from:
          _startPlayback in ccJnlwrd.o
    ld: symbol(s) not found
    collect2: ld returned 1 exit status
    make: *** [all] Error 1

难道不应该能够从我的源$ C ​​$ C动态包括32位库得到64位dylib?!

Shouldn't it be possible to get a 64 bit dylib from my source code that dynamically includes 32 bit libraries?!

推荐答案

正如您所指出的那样,你不能混用架构在同一个进程。

As you've noted, you can't mix architectures in the same process.

解决方法是再有的两个的过程。其中之一是一个32位的帮手的过程,链接到32位库,并通过一些IPC机制暴露了它的功能,另一种是64位Java进程链接到您自己的64位资料库。

The workaround is then to have two processes. One of them is a 32 bit "helper" process that links to the 32-bit library and exposes its functions through some IPC mechanism, and the other is the 64-bit Java process linked to your own 64-bit library.

您64位库启动辅助器进程,并提供一组功能,它实现通过传递请求到辅助处理过的IPC机构和返回结果。该IPC可以是简单的一对与管道创建匿名管道()系统调用。

Your 64-bit library starts up the helper process, and provides a set of functions that it implements by passing requests to the helper process over the IPC mechanism and returning the results. The IPC can be as simple as a pair of anonymous pipes created with the pipe() system call.

这篇关于制作动态链接在Mac OS X雪豹32位库64位共享库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆