Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Can';t同时编译ncurses和string 我现在正在学习如何使用C++和NCURSE。根据Youtube上的教程,我无法启动,因为我试图编译我的cpp文件时出现了一个错误。 文件名为Select.cpp,因此我使用命令行gcc-o Select-Select.cpp-lncurses来编译它,但我一直收到相同的错误,即: /tmp/ccirp2Pk.o: En la función `main': Select.cpp:(.text+0x10e): referencia a `std::allocator<char>::allocator()' sin definir Select.cpp:(.text+0x127): referencia a `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)' sin definir Select.cpp:(.text+0x136): referencia a `std::allocator<char>::~allocator()' sin definir Select.cpp:(.text+0x14d): referencia a `std::allocator<char>::allocator()' sin definir Select.cpp:(.text+0x166): referencia a `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)' sin definir Select.cpp:(.text+0x175): referencia a `std::allocator<char>::~allocator()' sin definir Select.cpp:(.text+0x18c): referencia a `std::allocator<char>::allocator()' sin definir Select.cpp:(.text+0x1a5): referencia a `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)' sin definir Select.cpp:(.text+0x1b4): referencia a `std::allocator<char>::~allocator()' sin definir Select.cpp:(.text+0x217): referencia a `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::c_str() const' sin definir Select.cpp:(.text+0x2cb): referencia a `std::allocator<char>::~allocator()' sin definir Select.cpp:(.text+0x2df): referencia a `std::allocator<char>::~allocator()' sin definir Select.cpp:(.text+0x2f3): referencia a `std::allocator<char>::~allocator()' sin definir Select.cpp:(.text+0x319): referencia a `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()' sin definir Select.cpp:(.text+0x34c): referencia a `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()' sin definir /tmp/ccirp2Pk.o:(.data.rel.local.DW.ref.__gxx_personality_v0[DW.ref.__gxx_personality_v0]+0x0): referencia a `__gxx_personality_v0' sin definir collect2: error: ld returned 1 exit status /tmp/ccirp2Pk.o:En la función`main': Select.cpp:(.text+0x10e):引用'std::allocator::allocator()'sin definir Select.cpp:(.text+0x127):引用一个'std::uuuCXX11::basic_string::basic_string(char const*,std::allocator const&')sin definir Select.cpp:(.text+0x136):引用'std::allocator::~allocator()'sin definir Select.cpp:(.text+0x14d):引用'std::allocator::allocator()'sin definir 选择.cpp:(.text+0x166):引用一个'std::uuuCXX11::basic_string::basic_string(char const*,std::allocator const&')sin definir Select.cpp:(.text+0x175):引用'std::allocator::~allocator()'sin definir Select.cpp:(.text+0x18c):引用'std::allocator::allocator()'sin definir Select.cpp:(.text+0x1a5):引用一个'std::\uuuCXX11::basic\u string::basic\u string(char const*,std::allocator const&')sin definir 选择.cpp:(.text+0x1b4):引用'std::allocator::~allocator()'sin definir Select.cpp:(.text+0x217):引用一个'std:uu cxx11::basic_string::c_str()const'sin definir Select.cpp:(.text+0x2cb):引用一个'std::allocator::~allocator()'sin definir Select.cpp:(.text+0x2df):引用'std::allocator::~allocator()'sin definir 选择.cpp:(.text+0x2f3):引用'std::allocator::~allocator()'sin definir 选择.cpp:(.text+0x319):引用一个`std:\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 选择.cpp:(.text+0x34c):引用一个`std:\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ /tmp/ccirp2Pk.o:(.data.rel.local.DW.ref.\uuuugxx\u personality\u v0[DW.ref.\uuuuuuugxx\u personality\u v0]+0x0):在定义中引用“uuuuuugxx\u personality\u v0” collect2:错误:ld返回了1个退出状态_C++_String_Compiler Errors_Ncurses - Fatal编程技术网

Can';t同时编译ncurses和string 我现在正在学习如何使用C++和NCURSE。根据Youtube上的教程,我无法启动,因为我试图编译我的cpp文件时出现了一个错误。 文件名为Select.cpp,因此我使用命令行gcc-o Select-Select.cpp-lncurses来编译它,但我一直收到相同的错误,即: /tmp/ccirp2Pk.o: En la función `main': Select.cpp:(.text+0x10e): referencia a `std::allocator<char>::allocator()' sin definir Select.cpp:(.text+0x127): referencia a `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)' sin definir Select.cpp:(.text+0x136): referencia a `std::allocator<char>::~allocator()' sin definir Select.cpp:(.text+0x14d): referencia a `std::allocator<char>::allocator()' sin definir Select.cpp:(.text+0x166): referencia a `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)' sin definir Select.cpp:(.text+0x175): referencia a `std::allocator<char>::~allocator()' sin definir Select.cpp:(.text+0x18c): referencia a `std::allocator<char>::allocator()' sin definir Select.cpp:(.text+0x1a5): referencia a `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)' sin definir Select.cpp:(.text+0x1b4): referencia a `std::allocator<char>::~allocator()' sin definir Select.cpp:(.text+0x217): referencia a `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::c_str() const' sin definir Select.cpp:(.text+0x2cb): referencia a `std::allocator<char>::~allocator()' sin definir Select.cpp:(.text+0x2df): referencia a `std::allocator<char>::~allocator()' sin definir Select.cpp:(.text+0x2f3): referencia a `std::allocator<char>::~allocator()' sin definir Select.cpp:(.text+0x319): referencia a `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()' sin definir Select.cpp:(.text+0x34c): referencia a `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()' sin definir /tmp/ccirp2Pk.o:(.data.rel.local.DW.ref.__gxx_personality_v0[DW.ref.__gxx_personality_v0]+0x0): referencia a `__gxx_personality_v0' sin definir collect2: error: ld returned 1 exit status /tmp/ccirp2Pk.o:En la función`main': Select.cpp:(.text+0x10e):引用'std::allocator::allocator()'sin definir Select.cpp:(.text+0x127):引用一个'std::uuuCXX11::basic_string::basic_string(char const*,std::allocator const&')sin definir Select.cpp:(.text+0x136):引用'std::allocator::~allocator()'sin definir Select.cpp:(.text+0x14d):引用'std::allocator::allocator()'sin definir 选择.cpp:(.text+0x166):引用一个'std::uuuCXX11::basic_string::basic_string(char const*,std::allocator const&')sin definir Select.cpp:(.text+0x175):引用'std::allocator::~allocator()'sin definir Select.cpp:(.text+0x18c):引用'std::allocator::allocator()'sin definir Select.cpp:(.text+0x1a5):引用一个'std::\uuuCXX11::basic\u string::basic\u string(char const*,std::allocator const&')sin definir 选择.cpp:(.text+0x1b4):引用'std::allocator::~allocator()'sin definir Select.cpp:(.text+0x217):引用一个'std:uu cxx11::basic_string::c_str()const'sin definir Select.cpp:(.text+0x2cb):引用一个'std::allocator::~allocator()'sin definir Select.cpp:(.text+0x2df):引用'std::allocator::~allocator()'sin definir 选择.cpp:(.text+0x2f3):引用'std::allocator::~allocator()'sin definir 选择.cpp:(.text+0x319):引用一个`std:\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 选择.cpp:(.text+0x34c):引用一个`std:\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ /tmp/ccirp2Pk.o:(.data.rel.local.DW.ref.\uuuugxx\u personality\u v0[DW.ref.\uuuuuuugxx\u personality\u v0]+0x0):在定义中引用“uuuuuugxx\u personality\u v0” collect2:错误:ld返回了1个退出状态

Can';t同时编译ncurses和string 我现在正在学习如何使用C++和NCURSE。根据Youtube上的教程,我无法启动,因为我试图编译我的cpp文件时出现了一个错误。 文件名为Select.cpp,因此我使用命令行gcc-o Select-Select.cpp-lncurses来编译它,但我一直收到相同的错误,即: /tmp/ccirp2Pk.o: En la función `main': Select.cpp:(.text+0x10e): referencia a `std::allocator<char>::allocator()' sin definir Select.cpp:(.text+0x127): referencia a `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)' sin definir Select.cpp:(.text+0x136): referencia a `std::allocator<char>::~allocator()' sin definir Select.cpp:(.text+0x14d): referencia a `std::allocator<char>::allocator()' sin definir Select.cpp:(.text+0x166): referencia a `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)' sin definir Select.cpp:(.text+0x175): referencia a `std::allocator<char>::~allocator()' sin definir Select.cpp:(.text+0x18c): referencia a `std::allocator<char>::allocator()' sin definir Select.cpp:(.text+0x1a5): referencia a `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)' sin definir Select.cpp:(.text+0x1b4): referencia a `std::allocator<char>::~allocator()' sin definir Select.cpp:(.text+0x217): referencia a `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::c_str() const' sin definir Select.cpp:(.text+0x2cb): referencia a `std::allocator<char>::~allocator()' sin definir Select.cpp:(.text+0x2df): referencia a `std::allocator<char>::~allocator()' sin definir Select.cpp:(.text+0x2f3): referencia a `std::allocator<char>::~allocator()' sin definir Select.cpp:(.text+0x319): referencia a `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()' sin definir Select.cpp:(.text+0x34c): referencia a `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()' sin definir /tmp/ccirp2Pk.o:(.data.rel.local.DW.ref.__gxx_personality_v0[DW.ref.__gxx_personality_v0]+0x0): referencia a `__gxx_personality_v0' sin definir collect2: error: ld returned 1 exit status /tmp/ccirp2Pk.o:En la función`main': Select.cpp:(.text+0x10e):引用'std::allocator::allocator()'sin definir Select.cpp:(.text+0x127):引用一个'std::uuuCXX11::basic_string::basic_string(char const*,std::allocator const&')sin definir Select.cpp:(.text+0x136):引用'std::allocator::~allocator()'sin definir Select.cpp:(.text+0x14d):引用'std::allocator::allocator()'sin definir 选择.cpp:(.text+0x166):引用一个'std::uuuCXX11::basic_string::basic_string(char const*,std::allocator const&')sin definir Select.cpp:(.text+0x175):引用'std::allocator::~allocator()'sin definir Select.cpp:(.text+0x18c):引用'std::allocator::allocator()'sin definir Select.cpp:(.text+0x1a5):引用一个'std::\uuuCXX11::basic\u string::basic\u string(char const*,std::allocator const&')sin definir 选择.cpp:(.text+0x1b4):引用'std::allocator::~allocator()'sin definir Select.cpp:(.text+0x217):引用一个'std:uu cxx11::basic_string::c_str()const'sin definir Select.cpp:(.text+0x2cb):引用一个'std::allocator::~allocator()'sin definir Select.cpp:(.text+0x2df):引用'std::allocator::~allocator()'sin definir 选择.cpp:(.text+0x2f3):引用'std::allocator::~allocator()'sin definir 选择.cpp:(.text+0x319):引用一个`std:\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 选择.cpp:(.text+0x34c):引用一个`std:\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ /tmp/ccirp2Pk.o:(.data.rel.local.DW.ref.\uuuugxx\u personality\u v0[DW.ref.\uuuuuuugxx\u personality\u v0]+0x0):在定义中引用“uuuuuugxx\u personality\u v0” collect2:错误:ld返回了1个退出状态,c++,string,compiler-errors,ncurses,C++,String,Compiler Errors,Ncurses,我已经意识到,问题是每当我使用字符串时,即使我在Begging中包含了 我正在使用的代码是: #包括 使用名称空间std; #包括 int main(int argc,字符**argv){ //课程开始了 initscr(); noecho(); cbreak(); //获取屏幕大小 int-yMax,xMax; getmaxyx(stdscr、yMax、xMax); //为我们的菜单创建一个窗口 窗口*menuwin=newwin(6,xMax-12,yMax-8,5); 框(menuwin,

我已经意识到,问题是每当我使用字符串时,即使我在Begging中包含了

我正在使用的代码是:

#包括
使用名称空间std;
#包括
int main(int argc,字符**argv){
//课程开始了
initscr();
noecho();
cbreak();
//获取屏幕大小
int-yMax,xMax;
getmaxyx(stdscr、yMax、xMax);
//为我们的菜单创建一个窗口
窗口*menuwin=newwin(6,xMax-12,yMax-8,5);
框(menuwin,0,0);
刷新();
雷弗斯(梅努温);
//这样我们就可以使用箭头键了
键盘(menuwin,TRUE);
字符串选项[3]={“步行”、“慢跑”、“跑步”};
智力选择;
int highlight=0;
而(1){

对于(int i=0;i在任何论坛(不仅仅是stackoverflow)寻求帮助时,第一步是将问题减少到重现问题所需的最小步骤。在您的情况下,您提供了太多的代码,关于所采取步骤的信息太少。这会更好:


(示例问题) 我正在尝试用NCURSE和C++ STD::String构建程序。这是我的代码

#包括
#包括
int main()
{
std::字符串s;
initscr();
endwin();
返回0;
}
我使用的是Ubuntu18.04和gcc版本9.0.1 这是我的构建命令

gcc main.cpp

/tmp/ccWWu0ZW.o: In function `main':
main.cpp:(.text+0x2d): undefined reference to `initscr'
...
失败(为了简洁起见,截断了错误)


此时,我们将更好地准备帮助您。我要指出,您需要在构建步骤中链接ncurses库,如下所示:

g++main.cpp-lcurses

这会起作用。请了解,当你说“它不起作用”时,我们几乎不知道你在说什么。给出错误消息,具体说明,并具体说明你的尝试。可能你有以下错误:

main.cpp:1:10: fatal error: ncurses.h: No such file or directory
    1 | #include <ncurses.h>
main.cpp:1:10:致命错误:ncurses.h:没有这样的文件或目录
1 |#包括

在这种情况下,我们会告诉你为你的发行版安装NCURESE开发PKG(对于我来说,Ubuntu,那就是< C++安装安装LIbNCURSES5 DEV/<代码>)。但是没有具体的情况,我们可能会忽略你的问题,或者做一些无用的猜测。

使用<代码> G++<代码>而不是<代码> GCC < /C> >编译和链接C++代码。不要依赖于A。Youtube上的“教程”"对C++方法的未定义引用意味着你不链接LBC+++与你的构建,如果你使用G++而不是GCC——当我使用GCC的G+ +集成时它是应该发生的,问题是G++不会编译NCRESS,这将是另一个问题,我已经在线阅读了d大多数人似乎用“包括”解决了这个问题,但我不明白为什么地雷不起作用。感谢书中的建议:)看看我的答案,我不知道你为什么认为g++不能编译包含ncursesThanks的代码。例如,我会注意你们给我的建议。谢谢你告诉我如何更好地发布我的问题或doubs。
main.cpp:1:10: fatal error: ncurses.h: No such file or directory
    1 | #include <ncurses.h>