按照前人的指点,使用了命令
sudo apt-get install build-essential
但是在尝试编译代码的时候,C的可以通过GCC命令编译,但是C++的却碰到了问题,求助!
代码原型:
#include<stdio.h>
int main()
{
printf("Hello Ubuntu!\n");
return 0;
}
#include <iostream>
int main()
{
std::cout<<"囗囗囗囗!";
return 0;
}
we@we-desktop:~/桌面$ gcc test_c.c -o test_c
we@we-desktop:~/桌面$ ./test_c
Hello Ubuntu!
we@we-desktop:~/桌面$ gcc test_c+.cpp -o test_c+
/tmp/ccEMMzJP.o: In function `main':
test_c+.cpp:(.text+0x1c): undefined reference to `std::cout'
test_c+.cpp:(.text+0x21): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/ccEMMzJP.o: In function `__static_initialization_and_destruction_0(int, int)':
test_c+.cpp:(.text+0x50): undefined reference to `std::ios_base::Init::Init()'
test_c+.cpp:(.text+0x55): undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccEMMzJP.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld 返回 1
C++环境配置怎么配置的?
- hnzksq
- 帖子: 473
- 注册时间: 2007-07-11 16:21
- 来自: 火星
C++环境配置怎么配置的?
------
“不要揣测神的心,我的孩子,”老头子的声音仿佛梦呓,“神的胸膛里没有心,那只是一块铁石。”
“不要揣测神的心,我的孩子,”老头子的声音仿佛梦呓,“神的胸膛里没有心,那只是一块铁石。”
- BigSnake.NET
- 帖子: 12522
- 注册时间: 2006-07-02 11:16
- 来自: 廣州
- 联系:
- hnzksq
- 帖子: 473
- 注册时间: 2007-07-11 16:21
- 来自: 火星
- hnzksq
- 帖子: 473
- 注册时间: 2007-07-11 16:21
- 来自: 火星
Re: C++环境配置怎么配置的?
we@we-desktop:~/桌面/code$ ls
test_c.c test_c+.cpp test.py
we@we-desktop:~/桌面/code$ g++ -wall test_c+.cpp -o test_c+
g++: 无法识别的选项‘-wall’
we@we-desktop:~/桌面/code$ g++ -Wall test_c+.cpp -o test_c+
we@we-desktop:~/桌面/code$ ls
test_c+ test_c.c test_c+.cpp test.py
we@we-desktop:~/桌面/code$ test_c+
bash: test_c+:找不到命令
we@we-desktop:~/桌面/code$ ./test_c+
we@we-desktop:~/桌面/code$ ./test_c+
we@we-desktop:~/桌面/code$ test_c+
bash: test_c+:找不到命令
we@we-desktop:~/桌面/code$ g++ -Wall test_c+.cpp -o test_c1
we@we-desktop:~/桌面/code./test_c1
we@we-desktop:~/桌面/codetest_c1
bash: test_c1:找不到命令
we@we-desktop:~/桌面/code$ ls
test_c+ test_c1 test_c.c test_c+.cpp test.py
we@we-desktop:~/桌面/code$ test_c1
bash: test_c1:找不到命令
we@we-desktop:~/桌面/code$
test_c.c test_c+.cpp test.py
we@we-desktop:~/桌面/code$ g++ -wall test_c+.cpp -o test_c+
g++: 无法识别的选项‘-wall’
we@we-desktop:~/桌面/code$ g++ -Wall test_c+.cpp -o test_c+
we@we-desktop:~/桌面/code$ ls
test_c+ test_c.c test_c+.cpp test.py
we@we-desktop:~/桌面/code$ test_c+
bash: test_c+:找不到命令
we@we-desktop:~/桌面/code$ ./test_c+
we@we-desktop:~/桌面/code$ ./test_c+
we@we-desktop:~/桌面/code$ test_c+
bash: test_c+:找不到命令
we@we-desktop:~/桌面/code$ g++ -Wall test_c+.cpp -o test_c1
we@we-desktop:~/桌面/code./test_c1
we@we-desktop:~/桌面/codetest_c1
bash: test_c1:找不到命令
we@we-desktop:~/桌面/code$ ls
test_c+ test_c1 test_c.c test_c+.cpp test.py
we@we-desktop:~/桌面/code$ test_c1
bash: test_c1:找不到命令
we@we-desktop:~/桌面/code$
------
“不要揣测神的心,我的孩子,”老头子的声音仿佛梦呓,“神的胸膛里没有心,那只是一块铁石。”
“不要揣测神的心,我的孩子,”老头子的声音仿佛梦呓,“神的胸膛里没有心,那只是一块铁石。”
- BigSnake.NET
- 帖子: 12522
- 注册时间: 2006-07-02 11:16
- 来自: 廣州
- 联系:
Re: C++环境配置怎么配置的?
不一样你就吃掉它hnzksq 写了:g++,gcc不都一样
^_^ ~~~
要理解递归,首先要理解递归。
地球人都知道,理论上,理论跟实际是没有差别的,但实际上,理论跟实际的差别是相当大滴。
要理解递归,首先要理解递归。
地球人都知道,理论上,理论跟实际是没有差别的,但实际上,理论跟实际的差别是相当大滴。