linux c++ compile error
This is my first time programming in linux and when I compile a simple c++ program like this:
g++ simple.cpp I get this error: /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crt1.o: In function `_start': /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crt1.o(.text+0x18): undefined reference to `main' collect2: ls returned 1 exit status Am I unable to compile classes and their methods without some main included somewhere? Thanks. |
Hello
To compile your code try g++ -c sample.cpp If there are no errors then link using g++ sample.o -o sample this links the sample.o produced by step 1 and then generates a linux executable "sample" in the same directory. To execute the program type ./sample OMAR |
Hello Again
Previous message assumed that you had a main function in sample.cpp. For multi-file programs, e.g., sample1.cpp and sample2.cpp, where one has main function in it, do the following g++ -c sample1.cpp g++ -c sample2.cpp g++ sample1.o sample2.o -o sample To execute ./sample It might be a good idea to read the man page on g++. On the console type man g++ This should open the help for g++. To move forward line by line press ENTER. To exit press Q. OMAR. |
Idea...
I think that u have to public your code to obtain a best help...
|
All times are GMT -5. The time now is 03:38 PM. |