Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在ubuntu22.04下构建出现错误implicit declaration of function ‘fdopen’ #162

Open
RequiemSouls opened this issue May 20, 2024 · 2 comments

Comments

@RequiemSouls
Copy link

RequiemSouls commented May 20, 2024

使用最新的master分支(b6f30d8)的源码,在ubuntu22.04上,系统默认的gcc版本是gcc10,构建C++报错,找不到,应该是gcc10不支持c++20
通过源码构建安装了gcc14,构建报错implicit declaration of function ‘fdopen’
通过在make.lua中添加linux = { flags = "-std=gnu17" }解决了,但是觉得有点怪异,感觉指定了两个标准库,还有别的办法解决吗

具体报错
[210/430] Compile C build/linux/debug/obj/ecs/ecs_persistence.obj
FAILED: build/linux/debug/obj/ecs/ecs_persistence.obj
gcc -MMD -MT build/linux/debug/obj/ecs/ecs_persistence.obj -MF build/linux/debug/obj/ecs/ecs_persistence.obj.d -std=c17 -Wall -g -Ibuild/linux/debug/lua54 -o build/linux/debug/obj/ecs/ecs_persistence.obj -c 3rd/luaecs/ecs_persistence.c
3rd/luaecs/ecs_persistence.c: In function ‘fileopen’:
3rd/luaecs/ecs_persistence.c:301:19: error: implicit declaration of function ‘fdopen’; did you mean ‘fopen’? [-Wimplicit-function-declaration]
301 | FILE *f = fdopen(fd, mode);
| ^~~~~~
| fopen
3rd/luaecs/ecs_persistence.c:301:19: error: initialization of ‘FILE *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]

系统:
Linux version 6.5.0-35-generic (buildd@lcy02-amd64-079) (x86_64-linux-gnu-gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) # 35~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 7 09:00:52 UTC 2
GCC版本:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/14.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure -enable-checking=release -enable-language=c,c++ -disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.1.0 (GCC)

@yuchanns
Copy link

linux = {
	defines = {
		"_GNU_SOURCE"
	}
}

@RequiemSouls
Copy link
Author

改成你这种写法,确实优雅一点

linux = {
	defines = {
		"_GNU_SOURCE"
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants