How to compile C++ with GCC
2008-01-08 16:09
477 查看
In the midst of TS/Hurricane Gaston, I find this.
If you compile gcc t.cc, it does not find the standard C++ library stdc++.
If you compile gcc -lstdc++ t.cc, it works fine.
If you compile g++ t.cc, it works fine.
But you must always have your program like this:
#include <iostream>
using namespace std;
int main() {
cout << "Hello world" << endl;
return 0;
}
or:
#include <iostream>
int main() {
std::cout << "Hello world" << std::endl;
return 0;
}
不管用不用using namespace都是要-lstdc++指定吧。
当时gcc没找到libstdc++是会报错的
If you compile gcc t.cc, it does not find the standard C++ library stdc++.
If you compile gcc -lstdc++ t.cc, it works fine.
If you compile g++ t.cc, it works fine.
But you must always have your program like this:
#include <iostream>
using namespace std;
int main() {
cout << "Hello world" << endl;
return 0;
}
or:
#include <iostream>
int main() {
std::cout << "Hello world" << std::endl;
return 0;
}
不管用不用using namespace都是要-lstdc++指定吧。
当时gcc没找到libstdc++是会报错的
相关文章推荐
- How to Compile XviD with Microsoft Visual C++ 6.0(zhuan)
- How to Compile XviD with Microsoft Visual C++ 6.0
- How to Compile XviD with Microsoft Visual C++ 6.0(转)
- How to compile a C/C++ DLL for 64 bit with Visual Studio?
- How to compile C++ boost library with Intel C++ compiler
- How to create a resizeable dialog box with scroll bars in Visual C++
- How to compile TLD with Win7-64bit + matlab2013b-64bit + VS2012 + OpenCV3.0
- question 002: dev c++ 当中如何调整字体大小?How to get the first program with C++? c++属于什么软件?
- GDB compile with arm-none-linux-gnueabi Howto
- how to compile kinfu_remake with cuda 9.0 opencv2.4.13.4
- [Tutorial] How to build a GUI in ROS with Qt / C++?
- How to configure a C/C++ project with Eclipse and CMake
- How to compile GCC-4.3.3 in the Linux?
- How to implement the similar mechanism with Java final in c++?
- How_to_build_a_static_Qt_version_for_Windows_with_gcc | Qt Wiki | Qt Developer Network
- Working with Group Policy Objects Programmatically - simple C++ example illustrating how to modify a
- How to Properly Write Received UDP Audio Data to ALSA with C++
- Mac如何通过Xcode安装GCC编译器 How to install gcc on mac with xcode
- How To Compile Qt with Visual Studio
- How to compile GCC-4.3.3 in the cygwin?