0

I don't know, maybe this is a duplicate, but I didn't find any help.

So, the problem. I have a simple problem - I made a script to automate C++ compiling a bit. Well, there's the script.

#!/bin/bash
clear
PATH="/media/joris/LinuxStuff/C plus plus prog"
echo Path is $PATH
echo Name of file?
read filename
echo $PATH/$filename/$filename.cpp
echo Compiled file name?
read compfilename
g++ -o $PATH/$filename/$filename.cpp /media/joris/LinuxStuff/C\ plus\ plus\ prog/$filename/$filename

And this is what I get:

Path is /media/joris/LinuxDomenai/C plus plus prog
Name of file?
nope
/media/joris/LinuxStuff/C plus plus prog/nope/nope.cpp
Compiled file name?
yes
./comp.sh: line 16: g++: command not found

Please help?

Edit: if I compile in terminal, it works and which g++ gives me /user/bin/g++

  • Check your installation with which g++. What is displayed? – A.B. Apr 2 '15 at 10:57
1

You should not overwrite $PATH. Use another name for this.

In your special case, the following should work:

/usr/bin/g++ -o "$PATH/$filename/$filename.cpp /media/joris/LinuxStuff/C plus plus prog/$filename/$filename"
  • Almost it. Problem: g++: error trying to exec 'as': execvp: No such file or directory – Joris Pevcevicius Apr 2 '15 at 11:17
  • This is another problem. Open a new question. – A.B. Apr 2 '15 at 11:31

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.