Author Topic: Build and Run results in error in Termnial  (Read 8695 times)

Offline fadetoben

  • Single posting newcomer
  • *
  • Posts: 4
Build and Run results in error in Termnial
« on: August 26, 2014, 11:41:07 pm »
Ahoy folks,
As I am unsure whether this is a compiler or code::blocks issue I will post here.

I have recently installed Code::Blocks 13.12 on my computer running OS X 10.9.4 (Mavericks).

I have GNU GCC as my compiler. I have copied down code from my book, that is supposed to be a demo first program:
//
// Conversion - Program to convert temperature from Celsius degrees into Fahrenheit:
//                          Fahrenheit = Celsius * (212 - 32)/100 + 32
//
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

int main (int nNumberofArgs, char* pszArgs[])
{
    //enter the temperature in Celsius
    int celsius;
    cout << "Enter the temperature in Celsius:";
    cin >> celsius;

    //calculate conversion factor for Celsius
    //to Fahrenheit
    int factor;
    factor = 212 - 32;

    //use conversion factor to convert Celsius
    // into Fahrenheit Values
    int fahrenheit;
    fahrenheit = factor * celsius/100 + 32;

    //output the results (folloed by a NewLine)
    cout<< "Fahrenheit value is:";
    cout<< fahrenheit << endl;

    //wait until user is ready before terminating program
    // to allow the user to see the program results
    cout << "Press Enter to continue..." << endl;
    cin.ignore(10, '\n') ;
    cin.get() ;
    return 0 ;
}

When i click build and run my terminal opens and i get the following:

Last login: Tue Aug 26 17:33:44 on ttys000
Benjamins-MacBook-Pro:~ Ben$ /Applications/CodeBlocks.app/Contents/MacOS/cb_console_runner DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:. /Users/Ben/Google Drive/CPP Programs from Book/Conversion/bin/Debug/Conversion
sh: /Users/Ben/Google: No such file or directory

Process returned 127 (0x7F)   execution time : 0.002 s
Press ENTER to continue.

I am very new to C++, I was hoping to get it to run a program so i can begin my adventures with it, just hoping somebody can help me out so i can get it running.

Thanks ahead of time


Offline pirx67

  • Multiple posting newcomer
  • *
  • Posts: 40
Re: Build and Run results in error in Termnial
« Reply #1 on: August 26, 2014, 11:52:45 pm »
In short without explaining the things behind the scenes: You have put your program example in a path with blanks in it. The shell can't handle it right.

Your path is now: "/Users/Ben/Google Drive/CPP Programs from Book/Conversion/bin/Debug/Conversion"

Stop Code::Blocks, replace all blanks in the path by underscores and try build and run again. The path will
then look like: "/Users/Ben/Google_Drive/CPP_Programs_from_Book/Conversion/bin/Debug/Conversion"

YMMV

You may Google also why having blanks in paths on your disk may be harmful.

Hope that helps,
    pirx67

Edit: A more thorough explanation can be found http://forums.codeblocks.org/index.php/topic,14054.msg94615.html#msg94615.
    That user was using "bash" instead of "sh" as you do.

« Last Edit: August 27, 2014, 12:32:54 am by pirx67 »

Offline fadetoben

  • Single posting newcomer
  • *
  • Posts: 4
Re: Build and Run results in error in Termnial
« Reply #2 on: August 27, 2014, 04:52:02 am »
Good call, I moved it to documents so it no longer contains spaces. I am now getting an error in the terminal saying permission is denied. Any ideas?

Offline pirx67

  • Multiple posting newcomer
  • *
  • Posts: 40
Re: Build and Run results in error in Termnial
« Reply #3 on: August 27, 2014, 11:28:05 pm »
Well, I'm not a Mac user. If you were on a Windows machine I would guess that the virus scanner interferes with the generation of the new executable program.

But on a Mac you should familiarize yourself with the Unix permission concept. Without a build log or at least the terminal output I could only guess whether you
need read, write or execute permission for the operation tried at the moment.

If you would provide more information the response could be more informative.

Cu,
    pirx67