当前位置: 技术问答>linux和unix
linux下g++问题
来源: 互联网 发布时间:2015-06-08
本文导语: test.cpp #include void main() { printf("hello"); } //编译:g++ test.cpp (加上-L/usr/lib, -lc也错) //出错 undefined reference to `printf(char const *,...)' 怎么解决呢 | #include using namespace std; int main() { printf("hello");...
test.cpp
#include
void main()
{
printf("hello");
}
//编译:g++ test.cpp (加上-L/usr/lib, -lc也错)
//出错 undefined reference to `printf(char const *,...)'
怎么解决呢
#include
void main()
{
printf("hello");
}
//编译:g++ test.cpp (加上-L/usr/lib, -lc也错)
//出错 undefined reference to `printf(char const *,...)'
怎么解决呢
|
#include
using namespace std;
int main()
{
printf("hello");
}
g++ test.cpp
看看。
using namespace std;
int main()
{
printf("hello");
}
g++ test.cpp
看看。
|
#include
using namespace std;
int main()
{
printf("hello");
return 0;
}
using namespace std;
int main()
{
printf("hello");
return 0;
}
|
用find /usr/include/ -name "stdio.h" -print 找到stdio.h的路径,然后用
g++ -c test.cpp -I路径
试一下
g++ -c test.cpp -I路径
试一下
|
#include
int main()
{
printf("hello");
return 0;
}
试一下,.h声明法是c的声明格式,没必要再加standard名字空间.如果还是不行,试试楼上那位大虾的方法,还找不到头文件的话可能就是你的编译器有问题了.
int main()
{
printf("hello");
return 0;
}
试一下,.h声明法是c的声明格式,没必要再加standard名字空间.如果还是不行,试试楼上那位大虾的方法,还找不到头文件的话可能就是你的编译器有问题了.