You are not logged in.

#1 2011-11-02 03:29:20

6msj
Member
Registered: 2011-10-03
Posts: 42

[SOLVED]External Tools in Gedit and compiling C++

g++ *.cpp -o ${GEDIT_CURRENT_DOCUMENT_NAME%.*}
./${GEDIT_CURRENT_DOCUMENT_NAME%.*}


gnome-terminal –working-directory=$GEDIT_CURRENT_DOCUMENT_DIR -e “./${GEDIT_CURRENT_DOCUMENT_NAME%.*}” &


This is the command I put into a hotkey to compile c++. It doesn't respond though, nothing happens when I press the hotkey.

The other command that is built in is the build command.
#!/bin/sh

EHOME=`echo $HOME | sed "s/#/\#/"`
DIR=$GEDIT_CURRENT_DOCUMENT_DIR
while test "$DIR" != "/"; do
    for m in GNUmakefile makefile Makefile; do
        if [ -f "${DIR}/${m}" ]; then
            echo "Using ${m} from ${DIR}" | sed "s#$EHOME#~#" > /dev/stderr
            make -C "${DIR}"
            exit
        fi
    done
    DIR=`dirname "${DIR}"`
done
echo "No Makefile found!" > /dev/stderr


When I run build though, I get this.

Running tool: Build

No Makefile found!

Done.


I'm a programming newbie and i've just been using the terminal to compile and run my programs. It'd be nice to have a hotkey do the same thing.

Last edited by 6msj (2011-11-02 22:49:00)

Offline

#2 2011-11-02 13:52:19

Cerebral
Forum Fellow
From: Waterloo, ON, CA
Registered: 2005-04-08
Posts: 3,108
Website

Re: [SOLVED]External Tools in Gedit and compiling C++

To help figure this out you can add some debug logs into the script - for every iteration of the loop, echo $DIR - see if it's set to what you expect

Offline

#3 2011-11-02 17:12:16

6msj
Member
Registered: 2011-10-03
Posts: 42

Re: [SOLVED]External Tools in Gedit and compiling C++

Which do i do the echo $DIR in? I tried putting it in the first one but it doesn't seem to do anything. I'm not even sure what a makefile is..

Thanks.

Offline

#4 2011-11-02 19:31:38

/dev/zero
Member
From: Melbourne, Australia
Registered: 2011-10-20
Posts: 1,247

Re: [SOLVED]External Tools in Gedit and compiling C++

Makefiles are scripts that help structure a software build. You can use them to specify the steps of your build, the dependencies of each step, and what to do if the dependencies haven't been met yet. When you run the `make' command, it looks for Makefiles, and uses the instructions in the makefile to build your program.

The script you've written for gedit is looking for Makefiles. That's what this bit sets up:

for m in GNUmakefile makefile Makefile; do

The script only ends peacefully if it finds a file having one of the names: GNUmakefile, makefile, or Makefile.

You have two options: you can either look up Makefile tutorials on the internet, or you can modify your build script so it runs the commands you want to run, instead of make. Either option will improve your unix-fu.

I suspect that at this point you would find it easier to write a simple makefile than to try modifying that script. Now, stfw! :-)

Last edited by /dev/zero (2011-11-02 19:33:29)

Offline

#5 2011-11-02 22:43:59

6msj
Member
Registered: 2011-10-03
Posts: 42

Re: [SOLVED]External Tools in Gedit and compiling C++

Thanks, will do.

Offline

Board footer

Powered by FluxBB