【问题标题】:Can't find ELF header找不到 ELF 标头
【发布时间】:2022-01-04 15:29:32
【问题描述】:

我正在尝试在 Debian 机器上使用 zwo asi python 绑定库(here)。

为此,我从zwo's website(Mac 和 Linux 版本)下载了 SDK,将 ASICamera2.h 文件放在/usr/include 中,并运行了在 lib 文件夹中的 README.txt 中编写的命令存档。
使用命令时,我有效地得到了“200”的答案:

cat /sys/module/usbcore/parameters/usbfs_memory_mb

然后我在/etc/profile 中创建了一个名为 ZWO_ASI_LIB 的环境变量,它引用了我之前谈到的 ASICamera2.h 文件。

这是我的python脚本的代码(不是完整的代码,而是导致问题的部分):

import os
import sys
import zwoasi

def startCamera():
    env_filename = os.getenv('ZWO_ASI_LIB')

    if env_filename:
        zwoasi.init(env_filename)
    else:
        print("Error : Library not found")
        sys.exit(1)

startCamera()

当我通过python3 x.py 命令在终端中启动它时,我收到此错误:

Traceback (most recent call last):
  File "x.py", line 87, in <module>
    startCamera()
  File "x.py", line 21, in startCamera
    zwoasi.init(env_filename)
  File "usr/local/lib/python3.7/dist-packages/zwoasi/__init__.py", line 821, in init
    zwolib = c.cdll.LoadLibrary(library_file)
  File "usr/lib/python3.7/ctypes/__init__.py", line 434, in LoadLibrary
    return self._dlltype(name)
  File "/usr/lib/python3.7/ctypes/__init__.py", line 356, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /usr/include/ASICamera2.h: invalid ELF header

我想我应该在 SDK 库的某个地方(.elf 文件?)有一个 ELF 标头,但我找不到它。可能是我没有引用正确的文件,但根据the documentation given on the zwo's website,我放入环境变量中的文件是标题。
另外,我真的不明白他们所说的“Linux下的动态和静态库:ASICamera2.so,ASICamera2.a”是什么意思

我使用的相机是 ASI178MC。

【问题讨论】:

    标签: python-3.x sdk elf


    【解决方案1】:

    OSError: /usr/include/ASICamera2.h: invalid ELF header

    您已经告诉您的运行时环境ASICamera2.h 是它应该加载的共享库的名称(使用dlopen on)。

    ASICamera2.hC 标头(文本)文件,定义了该库的API,而不是库本身。

    您应该将 Python 指向一个共享库(这可能也是您下载的 SDK 的一部分)。通常共享库以.so 结尾。您指向的文档说该库名为ASICamera2.so

    【讨论】:

    • 我明天试试!非常感谢您的回答:D
    • 非常感谢!这就是问题^^'我不知道...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-08
    • 2021-11-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多