gedit

Discuss Computer Science and Programming related problems

Moderators: Labib, bristy1588

User avatar
amlansaha
Posts: 100
Joined: Tue Feb 08, 2011 1:11 pm
Location: Khulna, Bangladesh
Contact:

gedit

Unread post by amlansaha » Tue Nov 01, 2011 4:14 pm

Can anyone tell me how i can compile a code witten in gedit? please reply me soon.

novice
Posts: 31
Joined: Sun Dec 12, 2010 12:34 am

Re: gedit

Unread post by novice » Wed Nov 02, 2011 4:40 am

Gedit is basically for editing ( I am guessing ). However,you can compile and run from it with the help of something called RunC. Follow the instructions here

http://www.ioi2010.org/environment/runc.shtml

Using RunC is very easy.Ctrl+R will do the compiling and running.Its not the best of options however.
My advice,install geany in ubuntu =) Its really Cool =)

Let us know what you coded :D

novice
Posts: 31
Joined: Sun Dec 12, 2010 12:34 am

Re: gedit

Unread post by novice » Wed Nov 02, 2011 4:42 am

I guessed you are using C and C++. If not,I apologize for wasting your time :(

User avatar
amlansaha
Posts: 100
Joined: Tue Feb 08, 2011 1:11 pm
Location: Khulna, Bangladesh
Contact:

Re: gedit

Unread post by amlansaha » Thu Nov 03, 2011 1:55 pm

yes i am using c. RunC is also cool 8-) thank you very much. i shall also try geany.
Last edited by amlansaha on Thu Nov 03, 2011 11:17 pm, edited 1 time in total.
অম্লান সাহা

Corei13
Posts: 153
Joined: Tue Dec 07, 2010 9:10 pm
Location: Chittagong

Re: gedit

Unread post by Corei13 » Thu Nov 03, 2011 8:37 pm

Go to terminal and type:

Code: Select all

sudo apt-get install gedit-plugins
After installing it go to Gedit > Edit > Preference > Plugins
Then tick Embedded terminal.
Now write a code, suppose something.c, when you need to compile it hit Ctrl+F9 and then enter

Code: Select all

gcc something.c
. If compilation is OK, enter

Code: Select all

./a.out
to run.

For C++ you need to install g++, go to terminal and type

Code: Select all

sudo apt-get install g++
And to compile a code named something.cpp enter

Code: Select all

g++ something.cpp
Running process is same as C.
ধনঞ্জয় বিশ্বাস

User avatar
amlansaha
Posts: 100
Joined: Tue Feb 08, 2011 1:11 pm
Location: Khulna, Bangladesh
Contact:

Re: gedit

Unread post by amlansaha » Thu Nov 03, 2011 11:20 pm

Corei13 wrote:Go to terminal and type:

Code: Select all

sudo apt-get install gedit-plugins
After installing it go to Gedit > Edit > Preference > Plugins
Then tick Embedded terminal.
Now write a code, suppose something.c, when you need to compile it hit Ctrl+F9 and then enter

Code: Select all

gcc something.c
. If compilation is OK, enter

Code: Select all

./a.out
to run.
I tried to compile this code

Code: Select all

#include <stdio.h>
int main()
{
    int a, b, sum;
    scanf("%d", &a);
    scanf("%d", &b);
    sum = a + b;
    printf("Sum is: %d\n", sum);
    return 0;
}
when i hit ctrl+F9 & enter gcc something.c it shows
/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status

what's the problem?
অম্লান সাহা

Corei13
Posts: 153
Joined: Tue Dec 07, 2010 9:10 pm
Location: Chittagong

Re: gedit

Unread post by Corei13 » Thu Nov 03, 2011 11:46 pm

Your code is compiled in my pc without any problem. :-/

Try updating gcc: sudo apt-get install gcc
ধনঞ্জয় বিশ্বাস

User avatar
amlansaha
Posts: 100
Joined: Tue Feb 08, 2011 1:11 pm
Location: Khulna, Bangladesh
Contact:

Re: gedit

Unread post by amlansaha » Sat Nov 05, 2011 12:40 pm

it works :D :D :D
আমি কোডটারে সেভ না করেই কম্পাইল করতে গেছিলাম। এরর তো আসবেই। what a fool i am.
btw, thanks dj :)
অম্লান সাহা

qeemat
Posts: 11
Joined: Thu Feb 16, 2012 6:43 pm

Re: gedit

Unread post by qeemat » Fri Feb 17, 2012 4:48 pm

Gedit is only designed to be a really good editor, not an IDE.

If you have a proper makefile then I believe F8 or F9 is the shortcut key to have gedit run 'make' in the current directory...

Otherwise just switch to the shell prompt and run the GCC yourself:

% g++ -Wall myprog.cpp -o myprog
% ./myprog

The first line compiles "myprog.cpp" into an executable named "myprog" (instead of "a.out").

Assuming there are no errors, the second line executes your program.



If your shell is locked because you started gedit with

% gedit myprog.cpp

instead of

% gedit myprog.cpp &

then you can fix it by:
1. Make sure the terminal window is active
2. Press Ctrl+Z to suspend the foreground process (gedit)
3. Type

% bg 1

to move job 1 (your gedit process) to the background.

If you have more than one process running, you can learn the job number by asking

% jobs

Post Reply