• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 13:29
CET 19:29
KST 03:29
  • 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
RSL Revival - 2025 Season Finals Preview8RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12
Community News
ComeBackTV's documentary on Byun's Career !2Weekly Cups (Dec 8-14): MaxPax, Clem, Cure win1Weekly Cups (Dec 1-7): Clem doubles, Solar gets over the hump1Weekly Cups (Nov 24-30): MaxPax, Clem, herO win2BGE Stara Zagora 2026 announced15
StarCraft 2
General
ComeBackTV's documentary on Byun's Career ! Weekly Cups (Dec 8-14): MaxPax, Clem, Cure win Did they add GM to 2v2? RSL Revival - 2025 Season Finals Preview Weekly Cups (Dec 1-7): Clem doubles, Solar gets over the hump
Tourneys
Sparkling Tuna Cup - Weekly Open Tournament $5,000+ WardiTV 2025 Championship StarCraft2.fi 15th Anniversary Cup RSL Offline Finals Info - Dec 13 and 14! Tenacious Turtle Tussle
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 504 Retribution Mutation # 503 Fowl Play Mutation # 502 Negative Reinforcement Mutation # 501 Price of Progress
Brood War
General
How Rain Became ProGamer in Just 3 Months FlaSh on: Biggest Problem With SnOw's Playstyle [BSL21] RO8 Bracket & Prediction Contest BGH Auto Balance -> http://bghmmr.eu/ BW General Discussion
Tourneys
[Megathread] Daily Proleagues [BSL21] RO8 - Day 2 - Sunday 21:00 CET [ASL20] Grand Finals [BSL21] RO8 - Day 1 - Saturday 21:00 CET
Strategy
Simple Questions, Simple Answers Current Meta Game Theory for Starcraft Fighting Spirit mining rates
Other Games
General Games
Nintendo Switch Thread PC Games Sales Thread Stormgate/Frost Giant Megathread Path of Exile Dawn of War IV
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
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Mafia Game Mode Feedback/Ideas Survivor II: The Amazon Sengoku Mafia TL Mafia Community Thread
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine YouTube Thread European Politico-economics QA Mega-thread
Fan Clubs
White-Ra Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece Movie Discussion!
Sports
2024 - 2026 Football Thread Formula 1 Discussion
World Cup 2022
Tech Support
Employee Retention in Behavioral Health: Building Computer Build, Upgrade & Buying Resource Thread
TL Community
TL+ Announced Where to ask questions and add stream?
Blogs
How Sleep Deprivation Affect…
TrAiDoS
I decided to write a webnov…
DjKniteX
James Bond movies ranking - pa…
Topin
Thanks for the RSL
Hildegard
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1931 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
WardiTV 2025
12:00
Playoffs
uThermal vs ShamelessLIVE!
Nice vs YoungYakov
WardiTV1539
ComeBackTV 813
TaKeTV 491
IndyStarCraft 218
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
mouzHeroMarine 224
IndyStarCraft 218
ProTech133
BRAT_OK 75
JuggernautJason61
MindelVK 12
StarCraft: Brood War
Bisu 1452
Larva 583
Mini 281
EffOrt 220
hero 119
Dewaltoss 108
Hyun 78
yabsab 20
Mong 10
Dota 2
Gorgc8670
qojqva4727
Dendi1300
BananaSlamJamma365
XcaliburYe152
Other Games
FrodaN1348
Beastyqt673
ceh9490
Fuzer 371
DeMusliM351
hiko323
ToD228
ArmadaUGS193
Trikslyr80
QueenE58
C9.Mang046
minikerr42
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 17 non-featured ]
StarCraft 2
• Reevou 7
• LaughNgamezSOOP
• sooper7s
• AfreecaTV YouTube
• intothetv
• Migwel
• Kozan
• IndyKCrew
StarCraft: Brood War
• blackmanpl 30
• HerbMon 18
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• WagamamaTV889
League of Legends
• TFBlade1676
Other Games
• imaqtpie516
• Shiphtur194
Upcoming Events
PiGosaur Cup
6h 31m
WardiTV 2025
17h 31m
MaNa vs Gerald
TBD vs MaxPax
ByuN vs TBD
TBD vs ShoWTimE
OSC
20h 31m
YoungYakov vs Mixu
ForJumy vs TBD
Percival vs TBD
Shameless vs TBD
The PondCast
1d 15h
WardiTV 2025
1d 18h
Cure vs Creator
TBD vs Solar
WardiTV 2025
2 days
OSC
2 days
CranKy Ducklings
3 days
SC Evo League
3 days
Ladder Legends
4 days
[ Show More ]
BSL 21
4 days
Sparkling Tuna Cup
4 days
Ladder Legends
4 days
BSL 21
5 days
Replay Cast
5 days
Monday Night Weeklies
5 days
Liquipedia Results

Completed

Acropolis #4 - TS3
RSL Offline Finals
Kuram Kup

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
YSL S2
BSL Season 21
Slon Tour Season 2
WardiTV 2025
META Madness #9
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22

Upcoming

CSL 2025 WINTER (S19)
BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
Big Gabe Cup #3
ESL Pro League Season 23
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 2025
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.