在 Linux x86 和 x86_64 上构建 NPAPI 浏览器插件,如何确保它加载其依赖库的正确版本?
我正在尝试使用 Firebreath 构建一个在 32 位和 64 位 Linux 上运行的 Linux 浏览器插件。
在我的 X11/projectDef.cmake 中,
target_link_libraries(${PROJECT_NAME}
${PLUGIN_INTERNAL_DEPS}
"${CMAKE_CURRENT_SOURCE_DIR}/lib/libOIS-1.4.0_32.so"
)
当我想要进行不同的构建时,当前我只是手动更改该行,将 32 切换为 64,所以这可能是错误的。但我的问题是,即使我使用 32 位库进行构建并成功编译,当我尝试在 Firefox 中加载插件时,我也会收到以下错误:
$ firefox
LoadPlugin: failed to initialize shared library /home/daniel/.mozilla/plugins/npBoomstickJavaScriptJoystickSupport.so [libOIS-1.4.0.so: wrong ELF class: ELFCLASS64]
How do I set up my cmake toautomatic include the Correct Library取决于架构?有没有办法在同一台机器上同时构建 x86 和 x86_64?如何让插件正确加载或者有没有办法进一步调试这个问题?
I'm attempting to build a Linux browser plugin using Firebreath that runs on 32bit and 64bit Linux.
In my X11/projectDef.cmake I have
target_link_libraries(${PROJECT_NAME}
${PLUGIN_INTERNAL_DEPS}
"${CMAKE_CURRENT_SOURCE_DIR}/lib/libOIS-1.4.0_32.so"
)
Currently I'm just manually changing that line switching 32 to 64 when I want to do a different build, so that's probably wrong. But my issue is that even when I build with the 32bit library and it compiles successfully, I get the following error when trying to load the plugin in Firefox:
$ firefox
LoadPlugin: failed to initialize shared library /home/daniel/.mozilla/plugins/npBoomstickJavaScriptJoystickSupport.so [libOIS-1.4.0.so: wrong ELF class: ELFCLASS64]
How do I set up my cmake to automatically include the correct library depending on the architecture? Is there a way to build both x86 and x86_64 simultaneously on the same machine? How do I get the plugin to load correctly or is there a way to further debug this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,在 64 位计算机上构建 32 位的唯一方法是使用交叉编译: http://www.vtk.org/Wiki/CMake_Cross_Compiling
我从来没有真正尝试过这个,但在 CMake 中你可以可能使用CMAKE_SIZEOF_VOID_P 在 32 位模式下为 4 , 64 位中的 8 个。您可以将 if 添加到 cmake 脚本中,以根据其大小设置正确的二进制文件。
As far as I know the only way to do a build for 32 bit on a 64 bit machine is to use cross compiling: http://www.vtk.org/Wiki/CMake_Cross_Compiling
I've never actually tried this, but inside CMake you can probably use the CMAKE_SIZEOF_VOID_P which will be 4 in 32 bit mode, 8 in 64 bit. You could add an if to your cmake script to set the correct binaries depending on the size of that.