#包括< iostream>用C+&#x2B中的C库(Raylib)编译时会导致错误。项目
我正在尝试在我的C ++项目中使用Raylib,该项目以前在Windows上工作正常。现在,在Linux上,我在尝试编译以下任何一个时,我会遇到很多错误:
#include<iostream>
#include<cstdio>
#include<fstream>
#include<sstream>
错误是由以下几个条目制成的:(实际上,列表实际上太长了,在此处将其发布得太长
/snap/clion/193/bin/cmake/linux/bin/cmake --build /home/usr/CLionProjects/Project/cmake-build-debug --target project -j 12
[1/6] Building CXX object CMakeFiles/project.dir/Button.cpp.o
FAILED: CMakeFiles/project.dir/Button.cpp.o
/usr/bin/c++ -DGRAPHICS_API_OPENGL_33 -DPLATFORM_DESKTOP -I/home/usr/CLionProjects/Project/cmake-build-debug -I/home/usr/CLionProjects/Project/External/raylib -I/home/usr/CLionProjects/Project/External/raylib-3.7/src -I/home/usr/CLionProjects/Project/External/raylib-3.7/src/external/glfw/include -g -std=gnu++2a -MD -MT CMakeFiles/project.dir/Button.cpp.o -MF CMakeFiles/project.dir/Button.cpp.o.d -o CMakeFiles/project.dir/Button.cpp.o -c /home/usr/CLionProjects/Project/Button.cpp
In file included from /usr/include/c++/10/cwchar:44,
from /usr/include/c++/10/bits/postypes.h:40,
from /usr/include/c++/10/iosfwd:40,
from /usr/include/c++/10/ios:38,
from /usr/include/c++/10/ostream:38,
from /usr/include/c++/10/iostream:39,
from /home/usr/CLionProjects/Project/Button.h:20,
from /home/usr/CLionProjects/Project/Button.cpp:5:
/usr/include/wchar.h:600:9: error: ‘__gnuc_va_list’ has not been declared
600 | __gnuc_va_list __arg)
| ^~~~~~~~~~~~~~
/usr/include/wchar.h:607:8: error: ‘__gnuc_va_list’ has not been declared
607 | __gnuc_va_list __arg)
| ^~~~~~~~~~~~~~
/usr/include/wchar.h:613:9: error: ‘__gnuc_va_list’ has not been declared
613 | __gnuc_va_list __arg)
| ^~~~~~~~~~~~~~
/usr/include/wchar.h:673:8: error: ‘__gnuc_va_list’ has not been declared
673 | __gnuc_va_list __arg)
| ^~~~~~~~~~~~~~
/usr/include/wchar.h:680:7: error: ‘__gnuc_va_list’ has not been declared
680 | __gnuc_va_list __arg)
| ^~~~~~~~~~~~~~
/usr/include/wchar.h:685:8: error: ‘__gnuc_va_list’ has not been declared
685 | __gnuc_va_list __arg)
| ^~~~~~~~~~~~~~
In file included from /usr/include/features.h:461,
from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:522,
from /usr/include/c++/10/utility:68,
from /usr/include/c++/10/array:38,
from /home/usr/CLionProjects/Project/Button.h:16,
from /home/usr/CLionProjects/Project/Button.cpp:5:
/usr/include/wchar.h:693:12: error: ‘__gnuc_va_list’ has not been declared
693 | extern int __REDIRECT (vfwscanf, (__FILE *__restrict __s,
| ^~~~~~~~~~
/usr/include/wchar.h:697:12: error: ‘__gnuc_va_list’ has not been declared
697 | extern int __REDIRECT (vwscanf, (const wchar_t *__restrict __format,
| ^~~~~~~~~~
/usr/include/wchar.h:700:12: error: ‘__gnuc_va_list’ has not been declared
700 | extern int __REDIRECT_NTH (vswscanf, (const wchar_t *__restrict __s,
| ^~~~~~~~~~~~~~
In file included from /usr/include/c++/10/cstdio:42,
from /usr/include/c++/10/ext/string_conversions.h:43,
from /usr/include/c++/10/bits/basic_string.h:6545,
from /usr/include/c++/10/string:55,
from /usr/include/c++/10/bits/locale_classes.h:40,
from /usr/include/c++/10/bits/ios_base.h:41,
from /usr/include/c++/10/ios:42,
from /usr/include/c++/10/ostream:38,
from /usr/include/c++/10/iostream:39,
from /home/usr/CLionProjects/Project/Button.h:20,
from /home/usr/CLionProjects/Project/Button.cpp:5:
/usr/include/stdio.h:342:8: error: ‘__gnuc_va_list’ has not been declared
342 | __gnuc_va_list __arg);
| ^~~~~~~~~~~~~~
/usr/include/stdio.h:347:54: error: ‘__gnuc_va_list’ has not been declared
347 | extern int vprintf (const char *__restrict __format, __gnuc_va_list __arg);
| ^~~~~~~~~~~~~~
/usr/include/stdio.h:350:8: error: ‘__gnuc_va_list’ has not been declared
350 | __gnuc_va_list __arg) __THROWNL;
| ^~~~~~~~~~~~~~
/usr/include/stdio.h:359:42: error: ‘__gnuc_va_list’ has not been declared
359 | const char *__restrict __format, __gnuc_va_list __arg)
| ^~~~~~~~~~~~~~
/usr/include/stdio.h:367:9: error: ‘__gnuc_va_list’ has not been declared
367 | __gnuc_va_list __arg)
| ^~~~~~~~~~~~~~
/usr/include/stdio.h:380:8: error: ‘__gnuc_va_list’ has not been declared
380 | __gnuc_va_list __arg)
| ^~~~~~~~~~~~~~
/usr/include/stdio.h:433:7: error: ‘__gnuc_va_list’ has not been declared
433 | __gnuc_va_list __arg)
| ^~~~~~~~~~~~~~
/usr/include/stdio.h:440:53: error: ‘__gnuc_va_list’ has not been declared
440 | extern int vscanf (const char *__restrict __format, __gnuc_va_list __arg)
| ^~~~~~~~~~~~~~
/usr/include/stdio.h:445:40: error: ‘__gnuc_va_list’ has not been declared
445 | const char *__restrict __format, __gnuc_va_list __arg)
| ^~~~~~~~~~~~~~
In file included from /usr/include/features.h:461,
from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:522,
from /usr/include/c++/10/utility:68,
from /usr/include/c++/10/array:38,
from /home/usr/CLionProjects/Project/Button.h:16,
from /home/usr/CLionProjects/Project/Button.cpp:5:
/usr/include/stdio.h:451:12: error: ‘__gnuc_va_list’ has not been declared
451 | extern int __REDIRECT (vfscanf,
| ^~~~~~~~~~
/usr/include/stdio.h:456:12: error: ‘__gnuc_va_list’ has not been declared
456 | extern int __REDIRECT (vscanf, (const char *__restrict __format,
| ^~~~~~~~~~
/usr/include/stdio.h:459:12: error: ‘__gnuc_va_list’ has not been declared
459 | extern int __REDIRECT_NTH (vsscanf,
| ^~~~~~~~~~~~~~
In file included from /usr/include/c++/10/cstdio:42,
from /usr/include/c++/10/ext/string_conversions.h:43,
from /usr/include/c++/10/bits/basic_string.h:6545,
from /usr/include/c++/10/string:55,
from /usr/include/c++/10/bits/locale_classes.h:40,
from /usr/include/c++/10/bits/ios_base.h:41,
from /usr/include/c++/10/ios:42,
from /usr/include/c++/10/ostream:38,
from /usr/include/c++/10/iostream:39,
from /home/usr/CLionProjects/Project/Button.h:20,
from /home/usr/CLionProjects/Project/Button.cpp:5:
/usr/include/stdio.h:831:8: error: ‘__gnuc_va_list’ has not been declared
831 | __gnuc_va_list __args)
| ^~~~~~~~~~~~~~
In file included from /usr/include/c++/10/string:55,
from /usr/include/c++/10/bits/locale_classes.h:40,
from /usr/include/c++/10/bits/ios_base.h:41,
from /usr/include/c++/10/ios:42,
from /usr/include/c++/10/ostream:38,
from /usr/include/c++/10/iostream:39,
from /home/usr/CLionProjects/Project/Button.h:20,
from /home/usr/CLionProjects/Project/Button.cpp:5:
/usr/include/c++/10/bits/basic_string.h: In function ‘std::string std::__cxx11::to_string(float)’:
/usr/include/c++/10/bits/basic_string.h:6663:20: error: no matching function for call to ‘__to_xstring<std::string>(int (*)(char*, size_t, const char*, int) noexcept, const int&, const char [3], float&)’
6663 | "%f", __val);
|
)迄今为止,由于Raylib用C编写C ++编译器,因此与交叉编译有关,但我找不到解决方案。有人有想法吗?
I'm trying to use Raylib in my C++ project which previously worked fine on windows. Now on Linux I get loads of errors when trying to compile if any of the following is included:
#include<iostream>
#include<cstdio>
#include<fstream>
#include<sstream>
The errors are made of several entries of the following: ( The list is actually too long to post it here )
/snap/clion/193/bin/cmake/linux/bin/cmake --build /home/usr/CLionProjects/Project/cmake-build-debug --target project -j 12
[1/6] Building CXX object CMakeFiles/project.dir/Button.cpp.o
FAILED: CMakeFiles/project.dir/Button.cpp.o
/usr/bin/c++ -DGRAPHICS_API_OPENGL_33 -DPLATFORM_DESKTOP -I/home/usr/CLionProjects/Project/cmake-build-debug -I/home/usr/CLionProjects/Project/External/raylib -I/home/usr/CLionProjects/Project/External/raylib-3.7/src -I/home/usr/CLionProjects/Project/External/raylib-3.7/src/external/glfw/include -g -std=gnu++2a -MD -MT CMakeFiles/project.dir/Button.cpp.o -MF CMakeFiles/project.dir/Button.cpp.o.d -o CMakeFiles/project.dir/Button.cpp.o -c /home/usr/CLionProjects/Project/Button.cpp
In file included from /usr/include/c++/10/cwchar:44,
from /usr/include/c++/10/bits/postypes.h:40,
from /usr/include/c++/10/iosfwd:40,
from /usr/include/c++/10/ios:38,
from /usr/include/c++/10/ostream:38,
from /usr/include/c++/10/iostream:39,
from /home/usr/CLionProjects/Project/Button.h:20,
from /home/usr/CLionProjects/Project/Button.cpp:5:
/usr/include/wchar.h:600:9: error: ‘__gnuc_va_list’ has not been declared
600 | __gnuc_va_list __arg)
| ^~~~~~~~~~~~~~
/usr/include/wchar.h:607:8: error: ‘__gnuc_va_list’ has not been declared
607 | __gnuc_va_list __arg)
| ^~~~~~~~~~~~~~
/usr/include/wchar.h:613:9: error: ‘__gnuc_va_list’ has not been declared
613 | __gnuc_va_list __arg)
| ^~~~~~~~~~~~~~
/usr/include/wchar.h:673:8: error: ‘__gnuc_va_list’ has not been declared
673 | __gnuc_va_list __arg)
| ^~~~~~~~~~~~~~
/usr/include/wchar.h:680:7: error: ‘__gnuc_va_list’ has not been declared
680 | __gnuc_va_list __arg)
| ^~~~~~~~~~~~~~
/usr/include/wchar.h:685:8: error: ‘__gnuc_va_list’ has not been declared
685 | __gnuc_va_list __arg)
| ^~~~~~~~~~~~~~
In file included from /usr/include/features.h:461,
from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:522,
from /usr/include/c++/10/utility:68,
from /usr/include/c++/10/array:38,
from /home/usr/CLionProjects/Project/Button.h:16,
from /home/usr/CLionProjects/Project/Button.cpp:5:
/usr/include/wchar.h:693:12: error: ‘__gnuc_va_list’ has not been declared
693 | extern int __REDIRECT (vfwscanf, (__FILE *__restrict __s,
| ^~~~~~~~~~
/usr/include/wchar.h:697:12: error: ‘__gnuc_va_list’ has not been declared
697 | extern int __REDIRECT (vwscanf, (const wchar_t *__restrict __format,
| ^~~~~~~~~~
/usr/include/wchar.h:700:12: error: ‘__gnuc_va_list’ has not been declared
700 | extern int __REDIRECT_NTH (vswscanf, (const wchar_t *__restrict __s,
| ^~~~~~~~~~~~~~
In file included from /usr/include/c++/10/cstdio:42,
from /usr/include/c++/10/ext/string_conversions.h:43,
from /usr/include/c++/10/bits/basic_string.h:6545,
from /usr/include/c++/10/string:55,
from /usr/include/c++/10/bits/locale_classes.h:40,
from /usr/include/c++/10/bits/ios_base.h:41,
from /usr/include/c++/10/ios:42,
from /usr/include/c++/10/ostream:38,
from /usr/include/c++/10/iostream:39,
from /home/usr/CLionProjects/Project/Button.h:20,
from /home/usr/CLionProjects/Project/Button.cpp:5:
/usr/include/stdio.h:342:8: error: ‘__gnuc_va_list’ has not been declared
342 | __gnuc_va_list __arg);
| ^~~~~~~~~~~~~~
/usr/include/stdio.h:347:54: error: ‘__gnuc_va_list’ has not been declared
347 | extern int vprintf (const char *__restrict __format, __gnuc_va_list __arg);
| ^~~~~~~~~~~~~~
/usr/include/stdio.h:350:8: error: ‘__gnuc_va_list’ has not been declared
350 | __gnuc_va_list __arg) __THROWNL;
| ^~~~~~~~~~~~~~
/usr/include/stdio.h:359:42: error: ‘__gnuc_va_list’ has not been declared
359 | const char *__restrict __format, __gnuc_va_list __arg)
| ^~~~~~~~~~~~~~
/usr/include/stdio.h:367:9: error: ‘__gnuc_va_list’ has not been declared
367 | __gnuc_va_list __arg)
| ^~~~~~~~~~~~~~
/usr/include/stdio.h:380:8: error: ‘__gnuc_va_list’ has not been declared
380 | __gnuc_va_list __arg)
| ^~~~~~~~~~~~~~
/usr/include/stdio.h:433:7: error: ‘__gnuc_va_list’ has not been declared
433 | __gnuc_va_list __arg)
| ^~~~~~~~~~~~~~
/usr/include/stdio.h:440:53: error: ‘__gnuc_va_list’ has not been declared
440 | extern int vscanf (const char *__restrict __format, __gnuc_va_list __arg)
| ^~~~~~~~~~~~~~
/usr/include/stdio.h:445:40: error: ‘__gnuc_va_list’ has not been declared
445 | const char *__restrict __format, __gnuc_va_list __arg)
| ^~~~~~~~~~~~~~
In file included from /usr/include/features.h:461,
from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:522,
from /usr/include/c++/10/utility:68,
from /usr/include/c++/10/array:38,
from /home/usr/CLionProjects/Project/Button.h:16,
from /home/usr/CLionProjects/Project/Button.cpp:5:
/usr/include/stdio.h:451:12: error: ‘__gnuc_va_list’ has not been declared
451 | extern int __REDIRECT (vfscanf,
| ^~~~~~~~~~
/usr/include/stdio.h:456:12: error: ‘__gnuc_va_list’ has not been declared
456 | extern int __REDIRECT (vscanf, (const char *__restrict __format,
| ^~~~~~~~~~
/usr/include/stdio.h:459:12: error: ‘__gnuc_va_list’ has not been declared
459 | extern int __REDIRECT_NTH (vsscanf,
| ^~~~~~~~~~~~~~
In file included from /usr/include/c++/10/cstdio:42,
from /usr/include/c++/10/ext/string_conversions.h:43,
from /usr/include/c++/10/bits/basic_string.h:6545,
from /usr/include/c++/10/string:55,
from /usr/include/c++/10/bits/locale_classes.h:40,
from /usr/include/c++/10/bits/ios_base.h:41,
from /usr/include/c++/10/ios:42,
from /usr/include/c++/10/ostream:38,
from /usr/include/c++/10/iostream:39,
from /home/usr/CLionProjects/Project/Button.h:20,
from /home/usr/CLionProjects/Project/Button.cpp:5:
/usr/include/stdio.h:831:8: error: ‘__gnuc_va_list’ has not been declared
831 | __gnuc_va_list __args)
| ^~~~~~~~~~~~~~
In file included from /usr/include/c++/10/string:55,
from /usr/include/c++/10/bits/locale_classes.h:40,
from /usr/include/c++/10/bits/ios_base.h:41,
from /usr/include/c++/10/ios:42,
from /usr/include/c++/10/ostream:38,
from /usr/include/c++/10/iostream:39,
from /home/usr/CLionProjects/Project/Button.h:20,
from /home/usr/CLionProjects/Project/Button.cpp:5:
/usr/include/c++/10/bits/basic_string.h: In function ‘std::string std::__cxx11::to_string(float)’:
/usr/include/c++/10/bits/basic_string.h:6663:20: error: no matching function for call to ‘__to_xstring<std::string>(int (*)(char*, size_t, const char*, int) noexcept, const int&, const char [3], float&)’
6663 | "%f", __val);
|
From what I could find on the internet so far it has to do with cross-compiling since Raylib is written in C and I'm using a C++ compiler, but I couldn't find a solution. Has anyone an idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,即使我不明白为什么,问题就解决了。
这无效,并输出上面列出的错误。但是,在Raylib解决了整个问题之前,请包括iostream:
Ok, so the problem is solved, even though I don't understand why.
This doesn't work and outputs the errors listed above. However, just including iostream BEFORE raylib solved the whole issue: