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++



출처 - http://blog.naver.com/PostView.nhn?blogId=kalkins&logNo=80114013159&categoryNo=17&viewDate=&currentPage=1&listtype=0










How do I fix this please? I am new to Linux.

share|improve this question
Did you install g++? Also, in eclipse you may have to set the compiler path in preferences. – scaryrawr Oct 8 '12 at 2:32

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.

share|improve this answer
version option gives me "g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3" – Will Oct 8 '12 at 3:27
I set "compiler invocation command" into the exact path.nothing changes. also,is there a fix that does fixing for all projects instead of one? – Will Oct 8 '12 at 3:44
So it clear that you have g++ installed on the box. This points to the path not being correct in eclipse. Try adding the path variable to the evironment here: window->preferences->C/C++->build->Environment. – bobestmOct 8 '12 at 20:39
thank you a lot. – Will Oct 9 '12 at 4:32

I have exactly the same problem. I never had problems with eclipse before under linux and now it wont even compile code. I tried to change the name of the g++ and gcc compilers to their exact location in project->properties->c/c++ Build->discovery options etc. nothing helped, I tried to reinstall eclipse and did an initialize, added the path to the variables etc.. Nothing worked so fare. The project I am working on is quiet big and I rather would like eclipse to manage the source and makefile, instead of doing it manually

Linux Mint 15 Eclispe: Version: 3.8.1 (I tried it with the latest version as well ... nothing changed)

g++ --version g++ (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3 Copyright (C) 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

gcc --version gcc (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3 Copyright (C) 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

example:

#include // not resolved using namespace std;

int main() {
    std::cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
    return 0;
}

Well the code above is not what bothers me, as I can fix it by adding the includes of the exact c++ include path, but the code just wont compile. Wired enough eclipse gives me the error:

Description Resource Path Location Type Program "g++" not found in PATH Preferences, C++/Build/Settings/Discovery, [CDT GCC Builtin Compiler Settings] options C/C++ Scanner Discovery Problem

but it appears to me to be possible to compile single files, by opening them and pressing crt+b, but the whole project wont compile.

Fixed the problem this morning:
- got the latest eclipse
- created a new workspace
- created a new project

after a few seconds the very same error disappears

share|improve this answer

I had similar problem and it is solved by

  1. Installing g++ The GNU C++ complier using ubuntu software centre and

  2. Changing in -

    Window -> Preferences -> C/C++ -> Build -> Settings -> Discovery -> CDT GCC Build in Complier Settings [Shared]

    From: ${COMMAND} -E -P -v -dD "${INPUTS}"

    To: /usr/bin/${COMMAND} -E -P -v -dD "${INPUTS}"

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.

share|improve this answer









출처 - http://stackoverflow.com/questions/12774629/program-g-not-found-in-path-in-eclipse-juno-cdt-in-ubuntu











What is the difference between g++ and gcc? Which ones should be used for general c++ development?

share|improve this question
up vote167down voteaccepted

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.

share|improve this answer
2 
@Brian: I spend several years thinking that 'gpp' was the C++ backend... – Mike F Oct 5 '08 at 21:00
6 
gcc used to mean 'Gnu C Compiler'. That eventually changed when more languages were added. – Ferruccio Oct 5 '08 at 21:49
8 
That's not entirely true. If you just run gcc on a C++ file, it will not 'just work' like g++ does. That's because it won't automatically link to the C++ std library, etc. Just use g++ for C++ files. – jonner Oct 5 '08 at 23:57
55 
The actual compiler is "cc1" for C and "cc1plus" for C++; both gcc and g++ are drivers (which call the preprocessor/compiler/assembler/linker as needed). – CesarB Oct 23 '08 at 14:34
4 
+1 because I didn't know that the c stood for collection. – René Nyffenegger Mar 30 '12 at 8:44

GCC: GNU Compiler Collection

  • Referrers to all the different languages that are supported by the GNU compiler.

gcc: GNU C      Compiler
g++: GNU C++ Compiler

The main differences:

  1. gcc will compile: *.c/*.cpp files as C and C++ respectively.
  2. g++ will compile: *.c/*.cpp files but they will all be treated as C++ files.
  3. Also if you use g++ to link the object files it automatically links in the std C++ libraries (gcc does not do this).
  4. gcc compiling C files has less predefined macros.
  5. gcc compiling *.cpp and g++ compiling *.c/*.cpp files has a few extra macros.

Extra Macros when compiling *.cpp files:

#define __GXX_WEAK__ 1
#define __cplusplus 1
#define __DEPRECATED 1
#define __GNUG__ 4
#define __EXCEPTIONS 1
#define __private_extern__ extern
share|improve this answer
7 
You can link the std C++ library in gcc by passing -lstdc++ parameter. – Denilson Sá Aug 23 '10 at 0:13
There are more differences between 'gcc' and 'g++' than only the standard libraries, so gcc -lstdc++ will still not get you the same behavior as g++. We put all of that language-specific behavior into its own driver for a reason, that's what it's there for. :-) – Ti Strga Jan 28 at 21:03
@TiStrga: You did not read the answer very carefully. Denilson is basically correct as he is only taking about the linking phase. – Loki Astari Jan 28 at 22:54
1 
My comment isn't talking about just linking... that's the point. Even just restricting the discussion to linking (which your answer was not), a user still won't be able to use the entire C++ standard library by only specifying -lstdc++, as there will be missing dependencies on math, RTTI, and exception information. Whether a given test case links or fails will depend on the operating system and which C++ features are used by the test case, which again is why all of that knowledge is built into the g++ driver instead of being left up to the user to figure out. – Ti Strga Jan 29 at 15:38
1 
Trust me, we have this discussion a lot, usually when a Linux user tries to move his incomplete Makefile to another platform. :-) The g++ link stage does a lot more than gcc -lstdc++ on other OSes, especially when the target is an embedded platform. Fortunately, that's why we ship a g++ in the first place. – Ti StrgaJan 29 at 15:40
show 2 more comments

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).

share|improve this answer

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.

share|improve this answer

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++

share|improve this answer

“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

share|improve this answer

gcc is the GNU C Compiler you should not use it to compile a C++ program, because it will give a linking error, that it can't link with the C++ standard library. g++, however, is the C++ frontend to gcc, and automatically links with the C++ standard library. GCC stands for the GNU Compiler Collection, which includes both the C and C++ compilers (gcc and g++), and some other ones, including Fortran and Java (gfortran and gcj).

share|improve this answer








출처 - http://stackoverflow.com/questions/172587/what-is-the-difference-between-g-and-gcc





















Posted by linuxism
,