Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

unknown.exe

macrumors member
Original poster
Sep 22, 2007
67
0
Somewhere on Earth
This is soooooo frustrating!This is the situation:
I just made a C++ tool (because it was the only C++ thing in the "new project" window), then i wrote my code, and when i build it, it works fine. The program does what i want it to do. But now i want to turn the program into a stand-alone application. I already have the .icns file and i know how to add an icon to my program. I made a new target, and when it asked me what type of target i wanted, i chose a carbon application (because there was no "C++ application", and carbon is C++ isnt it?). So it made a new target, and in the panel below my original target (the one that looks like a lego block), it made a new target. So i put the source code from the first target into the new one, and the frameworks and my .icns file for the icon. When i click build it says that it was successful! Yippee!!! Im all happy thinking that i have made my stand-alone app! But when i go to the build folder for my program and open the application... the icon bounces up and down in the dock like it's starting, then goes away. Please someone tell me what i am doing wrong!!! This xcode thing is really confusing. Do i need to make a .nib (interface) file? Cause if I do, then i know how to DESIGN the interface... but i have no idea how to program it so that it works with my program. How do i do it?
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
You can't just take some random C++ and hope that it will work as a full Mac app that you can launch via double clicking. Double clickable apps must conform to the expected interface, either via Carbon or Cocoa startup routines. If you want an app that you can double click you are better starting with the correct target: Cocoa or Carbon app.

And from my understanding a lot of Carbon is procedural C, not C++...
 

Soulstorm

macrumors 68000
Feb 1, 2005
1,887
1
Carbon can be used with C and C++, as long as the main files are named .cpp. The compiler will use the proper language according to file extensions.

As for the original quetsion... you can't just throw a .nib file into a C++ tool and expect it will work. In order to make a Carbon application, you will need to make a Carbon Application in the New Project dialog, then assiciate your code with the .nib interface (yes, you will have to design that, too).

What type is your program? Do you really need an interface? Do you know how to make one? Have you ever made one in any platform?

I suggest you read Apple's documentation on Carbon and XCode before you start walking blindly.
 

unknown.exe

macrumors member
Original poster
Sep 22, 2007
67
0
Somewhere on Earth
Reply

Carbon can be used with C and C++, as long as the main files are named .cpp. The compiler will use the proper language according to file extensions.

As for the original quetsion... you can't just throw a .nib file into a C++ tool and expect it will work. In order to make a Carbon application, you will need to make a Carbon Application in the New Project dialog, then assiciate your code with the .nib interface (yes, you will have to design that, too).

What type is your program? Do you really need an interface? Do you know how to make one? Have you ever made one in any platform?

I suggest you read Apple's documentation on Carbon and XCode before you start walking blindly.

My program asks about 8 or 9 questions which you answer. All I want is a window to open with a text box that my program's questions and the users answers appear in... thats all. Yes I need an interface because I am trying to get the hang of doing everything with xcode (I have used Visual C++ for the past 6 years). I have already DESIGNED an interface using the prog that came with xcode, and I've already got an icon. So all I need is a little instruction on the matter.:apple:
 

Soulstorm

macrumors 68000
Feb 1, 2005
1,887
1
I wish I could help you more on how to connect the interface elements with the actual code, but it's been a while since I gave up on Carbon in favor of Cocoa... Maybe Apple's documentation can help.
 

Littleodie914

macrumors 68000
Jun 9, 2004
1,813
8
Rochester, NY
If you're trying to get used to doing everything in XCode, why use C++?

It sounds like your program would be much easier to write if you wrote it in Objective-C, as a Cocoa Application. :)
 

HiRez

macrumors 603
Jan 6, 2004
6,265
2,630
Western US
If you're trying to get used to doing everything in XCode, why use C++?

It sounds like your program would be much easier to write if you wrote it in Objective-C, as a Cocoa Application. :)
I agree, using C++ with Cocoa is like trying to eat soup with a fork. You'll probably get fed eventually, but it won't be fun getting there.
 

unknown.exe

macrumors member
Original poster
Sep 22, 2007
67
0
Somewhere on Earth
I agree, using C++ with Cocoa is like trying to eat soup with a fork. You'll probably get fed eventually, but it won't be fun getting there.
very funny... but ive been learning how to program in c++ and java simutaniously for the past few weeks, and i dont feel like learning c at all. yes i know that c is like c++, but ill have to learn a lot of different stuff. is there a way to program a .nib file to work w/ a prog? how?
 

Eraserhead

macrumors G4
Nov 3, 2005
10,434
12,250
UK
I agree, using C++ with Cocoa is like trying to eat soup with a fork. You'll probably get fed eventually, but it won't be fun getting there.

Can't you use Objective C++ to do it?

very funny... but ive been learning how to program in c++ and java simutaniously for the past few weeks, and i dont feel like learning c at all. yes i know that c is like c++, but ill have to learn a lot of different stuff. is there a way to program a .nib file to work w/ a prog? how?


You may be able to use Objective C++ but unfortunately you'll probably need to write some Objective C as well. To do that I suggest you pick up Aaron Hillegasses Cocoa Programming for Mac OS X to learn the basics of Cocoa.

Its important to remember that once you know one language learning others isn't actually difficult.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.