gpt4 book ai didi

dart - 在 libc.so.6 中找不到 stat 方法

转载 作者:行者123 更新时间:2023-12-04 07:42:14 26 4
gpt4 key购买 nike

使用 Dart FFI 我试图动态加载 linux/posix 'stat' 函数。
我假设该函数在 libc.so.6 库中,但是当我尝试加载它时出现错误:

Invalid argument(s): Failed to lookup symbol (/lib/x86_64-linux-gnu/libc.so.6: undefined symbol: stat)
我成功地从 libc.so.6 库加载了其他函数,所以我的动态加载技术工作正常。
我有两个理论:
  • stat 是 xstat 的宏,因此 stat 不再存在。
  • stat 位于另一个我无法处理的库中。

  • 理想情况下,我想使用 stat 而不是 xstat,因为我需要这段代码也可以在 osx 上运行,据我所知它不支持 xstat。
    帮助?

    最佳答案

    I have two theories:


    无需理论化:您只需查看:
    echo "#include <sys/stat.h>" | gcc -xc - -E -dD | less
    nm -AD /lib/x86_64-linux/gnu/*.so* | grep ' stat$'
    会告诉你你需要知道的一切(你的第一个理论是正确的)。

    I want to use stat rather than xstat


    你不能:它不存在(使用 GLIBC 时)。

    I need this code to also work on osx which as far as I can tell doesn't support xstat.


    您的代码可以检测它运行的平台并进行调整。这是使用非可移植机制(例如 FFI)的代价。

    关于dart - 在 libc.so.6 中找不到 stat 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67395291/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com