gpt4 book ai didi

尝试使用 msys2 编译库时类型冲突

转载 作者:行者123 更新时间:2023-12-03 07:37:29 24 4
gpt4 key购买 nike

我正在尝试编译 wcslib在 Windows/msys2 下。
虽然这个库在 GNU/Linux 和 MacOS 上编译没有问题,但我正面临 msys2 的一个棘手问题:

wcs.h:1965:5: error: conflicting types for 'wcsset'
1965 | int wcsset(struct wcsprm *wcs);
| ^~~~~~
In file included from wcs.c:30:
C:/msys64/mingw64/x86_64-w64-mingw32/include/string.h:179:20: note: previous declaration of 'wcsset' was here
179 | wchar_t *__cdecl wcsset(wchar_t *_Str,wchar_t _Val) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
| ^~~~~~
wcs.c:2185:5: error: conflicting types for 'wcsset'
2185 | int wcsset(struct wcsprm *wcs)
| ^~~~~~
In file included from wcs.c:30:
C:/msys64/mingw64/x86_64-w64-mingw32/include/string.h:179:20: note: previous declaration of 'wcsset' was here
179 | wchar_t *__cdecl wcsset(wchar_t *_Str,wchar_t _Val) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
| ^~~~~~
make[3]: *** [GNUmakefile:135: libwcs-7.3.1.a(wcs.o)] Error 1
 
gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -c wcsbth.c
In file included from wcsbth.l:121:
wcs.h:1965:5: error: conflicting types for 'wcsset'
1965 | int wcsset(struct wcsprm *wcs);
| ^~~~~~
In file included from wcsbth.c:231:
C:/msys64/mingw64/x86_64-w64-mingw32/include/string.h:179:20: note: previous declaration of 'wcsset' was here
179 | wchar_t *__cdecl wcsset(wchar_t *_Str,wchar_t _Val) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
| ^~~~~~
make[3]: *** [GNUmakefile:135: libwcs-7.3.1.a(wcsbth.o)] Error 1

gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -c wcserr.c

gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -c wcsfix.c
In file included from wcsfix.c:38:
wcs.h:1965:5: error: conflicting types for 'wcsset'
1965 | int wcsset(struct wcsprm *wcs);
| ^~~~~~
In file included from wcsfix.c:30:
C:/msys64/mingw64/x86_64-w64-mingw32/include/string.h:179:20: note: previous declaration of 'wcsset' was here
179 | wchar_t *__cdecl wcsset(wchar_t *_Str,wchar_t _Val) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
| ^~~~~~
make[3]: *** [GNUmakefile:135: libwcs-7.3.1.a(wcsfix.o)] Error 1

gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -c wcshdr.c
In file included from wcshdr.h:1276,
from wcshdr.c:36:
wcs.h:1965:5: error: conflicting types for 'wcsset'
1965 | int wcsset(struct wcsprm *wcs);
| ^~~~~~
In file included from wcshdr.c:31:
C:/msys64/mingw64/x86_64-w64-mingw32/include/string.h:179:20: note: previous declaration of 'wcsset' was here
179 | wchar_t *__cdecl wcsset(wchar_t *_Str,wchar_t _Val) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
| ^~~~~~
make[3]: *** [GNUmakefile:135: libwcs-7.3.1.a(wcshdr.o)] Error 1

gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -c wcspih.c
In file included from wcspih.l:123:
wcs.h:1965:5: error: conflicting types for 'wcsset'
1965 | int wcsset(struct wcsprm *wcs);
| ^~~~~~
In file included from wcspih.c:231:
C:/msys64/mingw64/x86_64-w64-mingw32/include/string.h:179:20: note: previous declaration of 'wcsset' was here
179 | wchar_t *__cdecl wcsset(wchar_t *_Str,wchar_t _Val) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
| ^~~~~~
make[3]: *** [GNUmakefile:135: libwcs-7.3.1.a(wcspih.o)] Error 1

gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -c wcsprintf.c
gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -c wcstrig.c
gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -c wcsulex.c
gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -c wcsunits.c
gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -c wcsutil.c
gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -c wcsutrn.c
make[3]: Target 'libwcs-7.3.1.a' not remade because of errors.
make[2]: *** [GNUmakefile:258: lib] Error 2
make[2]: Target 'build' not remade because of errors.
make[2]: Leaving directory '/home/siril/wcslib-7.3.1/C'
Mon 2020/12/07 09:23:14 +0100, executing on
make[2]: Entering directory '/home/siril/wcslib-7.3.1/utils'
cd .. && ./config.status
config.status: creating makedefs
config.status: creating wcslib.pc
config.status: creating wcsconfig.h
config.status: creating wcsconfig_f77.h
config.status: wcsconfig_f77.h is unchanged
config.status: creating wcsconfig_tests.h
config.status: wcsconfig_tests.h is unchanged
config.status: creating wcsconfig_utils.h
 
gcc -DHAVE_CONFIG_H -I.. -I../C -g -O2 -c -o fitshdr.o fitshdr.c
gcc -o fitshdr fitshdr.o -lm -pthread -lcurl -lm
make[2]: Leaving directory '/home/siril/wcslib-7.3.1/utils'
make[1]: Leaving directory '/home/siril/wcslib-7.3.1'
当然,更改 lib 函数的名称不是一种选择(至少不是我的选择)。有人知道摆脱它的好选择吗?例如删除符号的方法或......其他东西。

最佳答案

我看了一下string.h错误消息中提到的文件。看起来你可以定义一个处理器宏 NO_OLDNAMES告诉头文件不要为 wcsset 生成原型(prototype).
您仍然需要在链接时注意问题,但这可能已经足够了。

关于尝试使用 msys2 编译库时类型冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65179621/

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