Running Windows (or anything else) on your Mac Discussion of Classic or running Windows, Linux and other OSes on the Mac.

cant execute compiled file with g++


Post Reply New Thread Subscribe

 
Thread Tools
loux

 
Member Since: Jan 27, 2012
Location: western colorado
Posts: 5
loux is on a distinguished road
Mac Specs: imac osx 10.6.8

loux is offline
using osx 10.6, installed xcode 3.1.2 and successfully used.
Then used Terminal, compiled very small pgm - using one cout statement. Cannot execute or find compiled pgm even by using command g++ name.cpp -o outstuff.
Compile seems to have been successful but I cannot find in any folder the output. I think that auto linking would be done - ?? Several net people said after compile - just type ./a.out to run. No workee.
Thanks for any help - loux
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Ottawa
Posts: 15,462
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
After you compile an app, unless you've specified a binary name, you should have an "a.out" binary. What are the commands you're executing?

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog :: M-F IRC Channel - Chats every Sunday at 8PM EST.
QUOTE Thanks
loux

 
Member Since: Jan 27, 2012
Location: western colorado
Posts: 5
loux is on a distinguished road
Mac Specs: imac osx 10.6.8

loux is offline
terminal: /developer/usr/bin g++ xtest.cpp.save -o stuff
terminal: ./stuff
error mess from bash: no such file or directory
QUOTE Thanks
Dysfunction

 
Dysfunction's Avatar
 
Member Since: Mar 17, 2008
Location: Tucson, AZ
Posts: 6,588
Dysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant future
Mac Specs: 2008 and 2011 15" mbps, late 11 iMac, iPhone 4s, and too many ipods and other stuff

Dysfunction is online now
Is your binary there when you do an ls? Your syntax is correct.

Code:
Mikes-iMac:foo mike$ g++ main.cpp -o foobar
Mikes-iMac:foo mike$ ls
foo.1    foobar   main.cpp
Mikes-iMac:foo mike$ foobar
-bash: foobar: command not found
Mikes-iMac:foo mike$ ./foobar
Hello, World!
Mikes-iMac:foo mike$

mike
This machine kills fascists
Got # ? phear the command line!
QUOTE Thanks
loux

 
Member Since: Jan 27, 2012
Location: western colorado
Posts: 5
loux is on a distinguished road
Mac Specs: imac osx 10.6.8

loux is offline
ls lists no file that I named in the g++ xtest.cpp.save -o stuff.
It does list the file xtest.cpp.save which I created with Pico.
stuff has disappeared and the xcode compiler just threw it away!
Loux
QUOTE Thanks
Dysfunction

 
Dysfunction's Avatar
 
Member Since: Mar 17, 2008
Location: Tucson, AZ
Posts: 6,588
Dysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant future
Mac Specs: 2008 and 2011 15" mbps, late 11 iMac, iPhone 4s, and too many ipods and other stuff

Dysfunction is online now
.. and you got no errors during compile, have full write permissions to the directory etc?

mike
This machine kills fascists
Got # ? phear the command line!
QUOTE Thanks
loux

 
Member Since: Jan 27, 2012
Location: western colorado
Posts: 5
loux is on a distinguished road
Mac Specs: imac osx 10.6.8

loux is offline
no errors during compile. full r w permission to source code. I do not know how to give full r/w permission the usr directory but I assume I am the only user the only admin on this personal mac in my home. Fantastic communications, Mike. I never knew that the forum would help this much - only signed on today.
Loux in Colo.
QUOTE Thanks
Dysfunction

 
Dysfunction's Avatar
 
Member Since: Mar 17, 2008
Location: Tucson, AZ
Posts: 6,588
Dysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant future
Mac Specs: 2008 and 2011 15" mbps, late 11 iMac, iPhone 4s, and too many ipods and other stuff

Dysfunction is online now
Try adding a -v switch, and post the output. Also you can try doing it as..

g++ xtest.cpp.save -o ~/stuff

at which point it should be in your home directory

mike
This machine kills fascists
Got # ? phear the command line!
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Ottawa
Posts: 15,462
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
You don't need the /Developer/usr/bin/ bit - gcc should be in your path.

The command you executed is no different than what Dysfunction or I execute which creates a binary in the current working directory. It's hard to tell you what might be wrong with this since there is absolutely nothing wrong with your command. My only suggestion would be to check what Dysfunction mentioned - privileges for the current working directory. Out of what directory are you trying to compile this code?

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog :: M-F IRC Channel - Chats every Sunday at 8PM EST.
QUOTE Thanks
loux

 
Member Since: Jan 27, 2012
Location: western colorado
Posts: 5
loux is on a distinguished road
Mac Specs: imac osx 10.6.8

loux is offline
I never succeeded in compiling with g++ in terminal. I do wish to correct myself: I had xcode3.2.1 and not 3.2.2. I uninstalled 3.2.1 and downloaded xcode 3.2.2 for Apple. This version has a very nice interface for beginners. Click in new project ( in the intro ), click on Application and command line and you have a nice setup for c prog - using the good editor and build and run. Now I see no reason to mess around with terminal and g++. Just thought people would like to know. Thanks for the help I did get - Loux

Last edited by vansmith; 02-03-2012 at 05:25 PM. Reason: Language
QUOTE Thanks

Post Reply New Thread Subscribe


« bootcamp-related data recovery problem | Native Resolution on PC Games/Bootcamp help... »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Differences; opening a file vs saving a file! fncos OS X - Operating System 14 03-24-2010 12:54 PM
Moving mp3's to your Audiobooks folder bobtomay iPod Hardware and Accessories 10 10-10-2009 12:02 PM
Info.plist to *open* a file gamblor01 OS X - Development and Darwin 2 03-22-2009 11:00 PM
Host file modification mastertag OS X - Operating System 4 07-11-2008 03:11 PM
Is .app the binary execute file? AlexN Switcher Hangout 3 09-23-2005 11:11 AM

All times are GMT -4. The time now is 06:32 PM.

Powered by vBulletin
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?