fedora g++ 설치(install)
# yum install gcc-c++
우선 결론을 말씀드리자면, C++ 코드의 경우에는 ' g++ '을 사용하는 것이 좋습니다.
' gcc '의 경우도 C++ 코드의 컴파일이 가능하지만 관련 라이브러리들이 자동으로 링크되지 않기 때문에 에러 메시지를 냅니다. 이러한 경우에는 대부분 -c 옵션을 주고 컴파일을 수행하면, 링크 이전까지는 아무런 에러없이 진행되어 *.o 오브젝트 파일을 생성합니다.
굳이 ' gcc '로 컴파일을 하신다면 -lstdc++ 옵션을 줍니다.
많은 교재에서 보던 간단한 hello.cpp 코드의 컴파일을 수행한다면, 아래와 같습니다.
g++ -o hello hello.cpp
또는
gcc -o hello hello.cpp -lstdc++
1 1 | |||
|
7 | Typically, g++ will be installed when gcc (GNU Compiler Collection) is installed. First confirm that you have g++ installed. You can check this by typing the following in a terminal: which g++. The response ought to be /usr/bin/g++. If you find g++ installed, in eclipse go to project->properties->C/C++ Build->Discovery Options, under tools GCC C++ Compiler, put the exact path to g++ instead of g++ (if g++ alone does not work). You will find this link useful: What is the difference between g++ and gcc? If you still have problems, do get back with feedback. | ||||||||
|
0 | I had similar problem and it is solved by
I hope it helps. I think if you add it to the project as mentioned in the first answer, you will need to add all the time for new projects. And if you add as I wrote you don't need to add it for new projects. |
167 | gcc is 'Gnu Compiler Collection'. If you pass it a C++ file, it will invoke the C++ compiler ('g++') behind the scenes. gcc is essentially the frontend for several compilers and the linker too. Edit: As several people pointed out, this doesn't mean that 'gcc' and 'g++' are interchangeable for c++ files: gcc will invoke g++ with different arguments to what you'd get if you'd invoked g++ directly. | ||||||||||||||||||||
|
99 | GCC: GNU Compiler Collection
gcc: GNU C Compiler The main differences:
Extra Macros when compiling *.cpp files:
| ||||||||||||||||
|
14 | For c++ you should use g++. It's the same compiler (e.g. the GNU compiler collection). GCC or G++ just choose a different front-end with different default options. In a nutshell: if you use g++ the frontend will tell the linker that you may want to link with the C++ standard libraries. The gcc frontend won't do that (also it could link with them if you pass the right command line options). | ||
6 | Although the gcc and g++ commands do very similar things, g++ is designed to be the command you'd invoke to compile a C++ program; it's intended to automatically do the right thing. Behind the scenes, they're really the same program. As I understand, both decide whether to compile a program as C or as C++ based on the filename extension. Both are capable of linking against the C++ standard library, but only g++ does this by default. So if you have a program written in C++ that doesn't happen to need to link against the standard library, gcc will happen to do the right thing; but then, so would g++. So there's really no reason not to use g++ for general C++ development. | ||
4 | The only notable difference is that i you pass a .c to gcc it will compile as C, whereas g++ will always treat it as C++ | ||
4 | “GCC” is a common shorthand term for the GNU Compiler Collection. This is both the most general name for the compiler, and the name used when the emphasis is on compiling C programs (as the abbreviation formerly stood for “GNU C Compiler”). When referring to C++ compilation, it is usual to call the compiler “G++”. Since there is only one compiler, it is also accurate to call it “GCC” no matter what the language context; however, the term “G++” is more useful when the emphasis is on compiling C++ programs. You could read more here: http://gcc.gnu.org/onlinedocs/gcc-3.3.5/gcc/G_002b_002b-and-GCC.html | ||
0 |
| ||
출처 - http://stackoverflow.com/questions/172587/what-is-the-difference-between-g-and-gcc
[출처] ' gcc '와 ' g++ '의 차이, C++ 코드 컴파일 방법 |작성자 곰탱이
'IDE & Build > Eclipse' 카테고리의 다른 글
eclipse - Can't make svn store password, even though the configuration is set to allow it (0) | 2014.07.23 |
---|---|
subclipse - Failed to load JavaHL Library (0) | 2014.02.16 |
eclipse - javadoc 한글 깨짐 (0) | 2013.06.20 |
svn password 초기화 (0) | 2013.01.16 |
eclipse.ini 설정 (0) | 2012.12.29 |