• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 02:58
CEST 08:58
KST 15:58
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL19] Finals Recap: Standing Tall9HomeStory Cup 27 - Info & Preview18Classic wins Code S Season 2 (2025)16Code S RO4 & Finals Preview: herO, Rogue, Classic, GuMiho0TL Team Map Contest #5: Presented by Monster Energy6
Community News
Flash Announces Hiatus From ASL61Weekly Cups (June 23-29): Reynor in world title form?13FEL Cracov 2025 (July 27) - $8000 live event20Esports World Cup 2025 - Final Player Roster16Weekly Cups (June 16-22): Clem strikes back1
StarCraft 2
General
Statistics for vetoed/disliked maps Program: SC2 / XSplit / OBS Scene Switcher The SCII GOAT: A statistical Evaluation Weekly Cups (June 23-29): Reynor in world title form? PiG Sty Festival #5: Playoffs Preview + Groups Recap
Tourneys
FEL Cracov 2025 (July 27) - $8000 live event RSL: Revival, a new crowdfunded tournament series Korean Starcraft League Week 77 Master Swan Open (Global Bronze-Master 2) [GSL 2025] Code S: Season 2 - Semi Finals & Finals
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome Mutation # 478 Instant Karma Mutation # 477 Slow and Steady
Brood War
General
Flash Announces Hiatus From ASL Player “Jedi” cheat on CSL ASL20 Preliminary Maps SC uni coach streams logging into betting site BGH Mineral Boosts Tutorial Video
Tourneys
[BSL20] Grand Finals - Sunday 20:00 CET [Megathread] Daily Proleagues Small VOD Thread 2.0 [BSL20] GosuLeague RO16 - Tue & Wed 20:00+CET
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Path of Exile Stormgate/Frost Giant Megathread Nintendo Switch Thread What do you want from future RTS games? Beyond All Reason
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Trading/Investing Thread Things Aren’t Peaceful in Palestine The Games Industry And ATVI
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [\m/] Heavy Metal Thread
Sports
2024 - 2025 Football Thread Formula 1 Discussion NBA General Discussion TeamLiquid Health and Fitness Initiative For 2023 NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Blogs
Culture Clash in Video Games…
TrAiDoS
from making sc maps to makin…
Husyelt
Blog #2
tankgirl
StarCraft improvement
iopq
Trip to the Zoo
micronesia
Customize Sidebar...

Website Feedback

Closed Threads



Active: 537 users

XCode Help

Blogs > SilverSkyLark
Post a Reply
SilverSkyLark
Profile Blog Joined April 2008
Philippines8437 Posts
November 14 2010 04:04 GMT
#1
Ok, I downloaded XCode 2.5 for Mac OS X 10.4 because I need it for my algorithm class. We are using C++ but since there's no DevC++ that works for Mac I had to download it.

It has a different interface than DevC++, and I can't seem to make .cpp files run on their own. So far I have this code for my sample.cpp:

#include <stdio.h>
#include <cmath>
#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
cout << "Hi." << endl;
return 0;
}


I commented out #include <sample.h> because I forgot what to put there and how it works.

So I opened the thing that oversees the project, the window where you can see the .ccp and .h files along with a whole lot of things on the left side. I selected Build and Run but there's an outside code error:

Command/Developer/usr/bin/g++-4.0 failed with exit code 1



So, does anyone know how to work this code? Is there a way to make codes run by themselves? Like making them compile and run alone on as .cpp files like what you can do in Dev C++?

Uhm ok, I found that inside the Build Drop down menu, you have compile and from the window that opens (Build Results), you can run the code. I tried running the code but there's a problem, everything comes out well, along with the build and run log and a window opens. I guess the program is supposed to execute inside that Window but it's a white blank window.

Any ideas anyone? I think I found the way to make codes work but making them display the output it tricky. I'd really appreciate help.


"If i lost an arm, I would play w3." -IntoTheWow || "Member of Hyuk Hyuk Hyuk cafe. He's the next Jaedong, baby!"
fabiano
Profile Blog Joined August 2009
Brazil4644 Posts
November 14 2010 04:35 GMT
#2
Did you try to open the gdb window? Usually NSLog() outputs to there, probably the same for cout.
"When the geyser died, a probe came out" - SirJolt
zoombini
Profile Joined June 2010
United States67 Posts
November 14 2010 04:35 GMT
#3
In terminal, cd to the directory the cpp file is in.

If you want to use GNU C++ compiler,

g++ filename.cpp -o executable_name

To run:
./executable_name <arguments>
SilverSkyLark
Profile Blog Joined April 2008
Philippines8437 Posts
November 14 2010 04:41 GMT
#4
Sorry but how to you open the gdb window (what's gdb? sorry it's my first time working around this).

and I don't know how to open the terminal, it's not in the apple menu..
"If i lost an arm, I would play w3." -IntoTheWow || "Member of Hyuk Hyuk Hyuk cafe. He's the next Jaedong, baby!"
fabiano
Profile Blog Joined August 2009
Brazil4644 Posts
November 14 2010 04:50 GMT
#5
On November 14 2010 13:41 SilverSkyLark wrote:
Sorry but how to you open the gdb window (what's gdb? sorry it's my first time working around this).

and I don't know how to open the terminal, it's not in the apple menu..


gdb is the gnu debugger.

Usually when you compile and run your Xcode projects, a little bar pops up the coding area with some buttons. One of these buttons, which, if im not mistaken, has a terminal drawed on it, will open the gdb window.

Maybe compiling directly through the terminal is better. You find it on Applications -> Utility (not sure if its named Utility or System Tools, the Mac I am forced to use in the reasearch lab is in portuguese).
"When the geyser died, a probe came out" - SirJolt
inkblot
Profile Joined December 2004
United States1250 Posts
November 14 2010 04:54 GMT
#6
You may need to add a command to pause the program before it exits. Some IDEs add this automatically (depending on settings). Adding a getch() or something like that will force the program to wait before exiting.

Trying adding:
char c = getch();

between the cout line and return 0.

stdio should probably be included as <cstdio> as well, though it should work the way it is now.
Macavenger
Profile Blog Joined January 2008
United States1132 Posts
November 14 2010 04:57 GMT
#7
For simple assignments in an algorithms class, I'd strongly recommend just using GCC rather than trying to deal with any IDE. Just run it in the OS X Terminal as zoombini and fabiano said. It's in /Applications/Utilities.
SilverSkyLark
Profile Blog Joined April 2008
Philippines8437 Posts
Last Edited: 2010-11-14 05:06:37
November 14 2010 05:01 GMT
#8
I managed to open the terminal and get to open gdb by typing gdb in

ok more noob questions, how to I compile programs there? typed in help and I can't see anything that can specifically help me.


edit: I'll look for a gcc that would work in osx 10.4...if that doesn't give me anything, I'll borrow my dad's laptop and work there. thanks for the help guys..
"If i lost an arm, I would play w3." -IntoTheWow || "Member of Hyuk Hyuk Hyuk cafe. He's the next Jaedong, baby!"
zoombini
Profile Joined June 2010
United States67 Posts
November 14 2010 05:10 GMT
#9
GCC is the C compiler. G++ is the C++ compiler. They both should already be installed on your Mac OS X installation.

Like I said earlier, to compile your program
cd into the directory where the .cpp (or .cpp files are).

Type this into your terminal:
g++ your_cpp.cpp -o executable_name_you_want

If you have compile errors, it will tell you in terminal. If you do not get any errors, then you are golden.

If compile is successful, then type "ls" into terminal. This will list your current directory. If compile is successful, you will see executable_name_you_want listed. (Maybe type "ls | grep executable_name_you_want".)

To run the executable that you've compiled, type:
./executable_name_you_want

Your program should run.
Please log in or register to reply.
Live Events Refresh
Next event in 3h 2m
[ Submit Event ]
Live Streams
Refresh
StarCraft: Brood War
Leta 594
Larva 324
Barracks 53
Dota 2
XaKoH 608
League of Legends
JimRising 745
Counter-Strike
Stewie2K1027
Heroes of the Storm
Khaldor237
Other Games
WinterStarcraft650
SortOf103
kaitlyn77
ProTech53
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 17 non-featured ]
StarCraft 2
• Berry_CruncH367
• Hupsaiya 91
• Sammyuel 42
• Kozan
• LaughNgamezSOOP
• sooper7s
• AfreecaTV YouTube
• intothetv
• Migwel
• IndyKCrew
StarCraft: Brood War
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• lizZardDota2175
League of Legends
• Lourlo1363
• masondota2816
• Stunt507
Upcoming Events
RSL Revival
3h 2m
Clem vs Classic
SHIN vs Cure
FEL
5h 2m
WardiTV European League
5h 2m
BSL: ProLeague
11h 2m
Dewalt vs Bonyth
Replay Cast
1d 17h
Sparkling Tuna Cup
2 days
WardiTV European League
2 days
The PondCast
3 days
Replay Cast
3 days
RSL Revival
4 days
[ Show More ]
Replay Cast
4 days
RSL Revival
5 days
FEL
5 days
RSL Revival
6 days
FEL
6 days
FEL
6 days
Liquipedia Results

Completed

BSL 2v2 Season 3
HSC XXVII
Heroes 10 EU

Ongoing

JPL Season 2
BSL Season 20
Acropolis #3
KCM Race Survival 2025 Season 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
Championship of Russia 2025
RSL Revival: Season 1
Murky Cup #2
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025

Upcoming

2025 ACS Season 2: Qualifier
CSLPRO Last Chance 2025
2025 ACS Season 2
CSLPRO Chat StarLAN 3
K-Championship
uThermal 2v2 Main Event
SEL Season 2 Championship
FEL Cracov 2025
Esports World Cup 2025
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.