_ftime 的 Cygwin 链接错误
Cygwin linking error for _ftime
当尝试 link 一些具有自定义 Windows/POSIX 可移植性的旧代码时,有 #ifdef
条件编译在 Cygwin 上调用 _ftime()
并且在任何地方都调用 ftime()
否则(注意前导 _
)。
当我尝试编译 link 这段代码时,我得到以下
../../bin/../lib/libconv-core.a(convcore.o):convcore.c:(.text+0xf6b): undefined reference to `_ftime'
../../bin/../lib/libconv-core.a(convcore.o):convcore.c:(.text+0xf6b): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `_ftime'
我们发现目前的Cygwin实际上定义了常用的POSIX函数ftime()
。只需用它的标准名称而不是 Microsoft CRT 的奇怪名称来称呼它。
当尝试 link 一些具有自定义 Windows/POSIX 可移植性的旧代码时,有 #ifdef
条件编译在 Cygwin 上调用 _ftime()
并且在任何地方都调用 ftime()
否则(注意前导 _
)。
当我尝试编译 link 这段代码时,我得到以下
../../bin/../lib/libconv-core.a(convcore.o):convcore.c:(.text+0xf6b): undefined reference to `_ftime'
../../bin/../lib/libconv-core.a(convcore.o):convcore.c:(.text+0xf6b): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `_ftime'
我们发现目前的Cygwin实际上定义了常用的POSIX函数ftime()
。只需用它的标准名称而不是 Microsoft CRT 的奇怪名称来称呼它。