• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

C++ compiler in Knoppix?

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

Yamiyanazz

Member
Joined
Jan 3, 2004
Location
Oregon
I'm currently enrolled in a C++ class at my local community college. The computers here don't have any hard drives, but they are all running a gig of ram, so I've been running off of a knoppix 3.7 CD. I know that linux usually compiles programs before installing them, so I was wondering if there was a compiler that I could be using to create and debug my programs while I'm in class. Any way to do this?
 
All of linux is based on GCC (the GNU Compiler Collection). This is a wrapper or a number of different compilers, including C, C++, Objective C, Java, Ada, Pascal, and Fortran (I think those are the ones).

Within it is a compiler called g++ which is a C++ compiler.
 
Excellent. How do I gain access to it? Will I need to create Makefiles each time I want to compile, or can I just tell it which .h and .cpp to compile and it'll figure parts out.

I'm coming from .NET, so don't kill me for ignorance.
 
You don't need to tell a c compiller where the h files are, as they are included in your cpp files. You can use a makefile if you want, but it's not usually worth it for very simple apps. Make is a program designed to call the c++ compiler, makefiles are not actually used by the c++ compiler, but by GNU Make. If you want to just compile a program, you just use (on the command line, in the directory where the files you've written reside):

g++ helloworld.cpp helloworld2.cpp helloworld3.cpp -o myexecutablename

-o flag is optional. If you omit it, the compiled binary is called a.out
-O optimizes (remember that linux is case sensitive)
-g1, -g2, -g3 enable different levels of debugging (3 being highest, 2 is the least you should use if you want a useful amount of debug info)

That's the most important stuff. There are manuals for how to use it on the web I'm sure. Google GNU gcc.
 
knoppix also has a k development environment similar to Visual C++ .NET. I think its called KDevelop or something.
 
Back