gpt4 book ai didi

cygwin - undefined reference : cygwin_posix_to_win32_path_list and cygwin_posix_to_win32_path_list_buf_size

转载 作者:行者123 更新时间:2023-12-05 05:26:55 26 4
gpt4 key购买 nike

我正在尝试在 Cygwin 中编译代码,但收到“cygwin_posix_to_win32_path_list”和“cygwin_posix_to_win32_path_list_buf_size”的 undefined reference 错误。

是否有任何我应该添加的缺失库?我确定安装了 win32 api 包。

感谢您的帮助。

tclEnv.o:tclEnv.c:(.text+0xf6): undefined reference to `cygwin_posix_to_win32_path_list_buf_size'
tclEnv.o:tclEnv.c:(.text+0xf6): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `cygwin_posix_to_win32_path_list_buf_size'
tclEnv.o:tclEnv.c:(.text+0x118): undefined reference to `cygwin_posix_to_win32_path_list'
tclEnv.o:tclEnv.c:(.text+0x118): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `cygwin_posix_to_win32_path_list'
/usr/bin/ld: tclEnv.o: bad reloc address 0x0 in section `.pdata'
collect2: error: ld returned 1 exit status
Makefile:550: recipe for target 'libtcl8.5.dll' failed
make: *** [libtcl8.5.dll] Error 1

最佳答案

这些函数是 Cygwin 1.x 的一部分,但是 were removed in Cygwin 2.x .

因此,我们必须制作一些实用功能,利用版本 2 中的新功能,但保持相同的名称和接口(interface)(适配器)。因为我需要使用一些 code made in 2006我也需要完成这个。因此,让我们从查看文档开始...

这是当前路径转换函数的函数定义

ssize_t cygwin_conv_path(
cygwin_conv_path_t 什么,
const void * 来自,
无效*到,
size_t 尺寸
);

这是之前的路径转换函数的函数定义

void cygwin_posix_to_win32_path_list(const char *posix, char * win32);

使用这个和例子(from the official docs),我们可能可以做一些事情。

/**
* Adapter for old Cygwin 1.x functions missing from Cygwin 2.x
*
* Based on the documentation for 1.4 and 2.x
* - http://pipeline.lbl.gov/code/3rd_party/licenses.win/cygwin-doc-1.4/html/cygwin-api/func-cygwin-posix-to-win32-path-list.html
* - https://cygwin.com/cygwin-api/func-cygwin-conv-path.html
*
*/
#include <sys/cygwin.h>

void cygwin_posix_to_win32_path_list(const char *posix, char * win32){

// We do not know the size of the win32 buffer, but hopefully
// it is at least size long ...
ssize_t size = cygwin_conv_path( CCP_POSIX_TO_WIN_A, posix, NULL, 0);

cygwin_conv_path( CCP_POSIX_TO_WIN_A, posix, win32, size);
}

有很多方法可以使用它来修复您的代码:

  • 复制粘贴到代码中
  • 保存到adapter.c中,并在相关代码中#include adapter.c
  • 将其编译成 adapter.o 并使用 ld 将其链接到其他目标文件

关于cygwin - undefined reference : cygwin_posix_to_win32_path_list and cygwin_posix_to_win32_path_list_buf_size,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23210522/

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