Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > C++, Cocoa, and Project builder not getting along

C++, Cocoa, and Project builder not getting along
Thread Tools
Fresh-Faced Recruit
Join Date: Jul 2001
Status: Offline
Reply With Quote
Jul 24, 2001, 03:12 PM
 
For the life of me, I CANNOT get project builder to either interprit C++ code in a cocoa application or use cocoa libraries in a C++ application (ie, from the new project menu). I've added libc++.a or whatever to the cocoa application and Foundation, AppKit, and cocoa frameworks to the C++ project, but the cocoa project says undefined "class" and the C++ application says error, Undefined symbols. I just want to use C++!! I can't even get C++ to work in a carbon application (it says class undefined). What's going on here!?
     
Admin Emeritus
Join Date: Oct 2000
Location: Boston, MA
Status: Offline
Reply With Quote
Jul 24, 2001, 06:14 PM
 
LOL. Odd, I was just going to ask a question regarding the progress of Objective-C++.

Objective-C is an extension to C, not C++, so C++ syntax won't work there.
Objective-C++, though, will accept C++ in Objective-C code. Files that end in ".M" (as opposed to the lower-case variant) are Objective-C++ files, but Apple hasn't included the Objective-C++ compiler in OS X, so you'll get an error about the pipe being closed, ccobj1plus not existing, or something.

We can only wait. :-)

[ 07-24-2001: Message edited by: parallax ]
"Against stupidity, the gods themselves contend in vain" (Schiller)
     
Fresh-Faced Recruit
Join Date: Jul 2001
Status: Offline
Reply With Quote
Jul 24, 2001, 10:25 PM
 
NO!!!!! Say it isn't so!
heh, I knew it was something along those lines.
There's no option when you create a new file to create an Objective-C++ file, but there IS an option to save a copy of a file as an Objective-C++ file, thus my confusion as to why it wasn't working either way. (I actually got a file with a .mm extension when I saved as objective-c++ file, I'll try adding a .M extension to see if the 1.0.1 version of project builder did anything. I doubt it. ) Well, as an easy workaround, is it possible to get the project builder to build an objective C file and a C++ file seperately and then link them together? I have a group of objects and class methods in the C++ file, but in the main file, I only need to call a C function from that C++ file to initiate the program. Otherwise, how do I create a cocoa project in CodeWarrior pro 6 (the osx version).
     
Fresh-Faced Recruit
Join Date: Jul 2001
Status: Offline
Reply With Quote
Jul 25, 2001, 12:21 AM
 
AHA! I discovered a workaround for my situation. I'm actually working on a GLUT project, and I'm not really using cocoa libraries. I'm using a cocoa project to avoid the hastle of setting up all the windows and stuff in Carbon. So, here's how I made a project where I could use C++ code to make an OpenGL Glut game.
1) New project
2) Select Cocoa Application
3) Select File>New File
4) Select C++ file
5) Name it main.cpp or something similar, make sure you add it to the current target
6) delete main.m from your project
7) Add Framework GLUT.framework
8) type code in main.cpp

Header files seem to default to objective C in my configuration, so you may have to use only .cpp files for additional C++ files instead of headers.
     
Admin Emeritus
Join Date: Oct 2000
Location: Boston, MA
Status: Offline
Reply With Quote
Jul 25, 2001, 10:24 AM
 
Naw, you can also use Carbon, since GLUT manages the hassle of setting up windows (it's completely platform-independent, so all GLUT code will work no matter what libraries use... Carbon... Cocoa... X... Win32, &c)
"Against stupidity, the gods themselves contend in vain" (Schiller)
     
Dedicated MacNNer
Join Date: Jan 2001
Location: Virginia, US
Status: Offline
Reply With Quote
Jul 25, 2001, 10:44 AM
 
On Objective-C++, recent posts to the darwin-development mailing list suggest that it will be part of the developer tools that come out concurrently with the 10.1 release.

(darwin-development archives are on www.darwinfo.org)
     
   
Thread Tools
Forum Links
Forum 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 On
Top
Privacy Policy
All times are GMT -5. The time now is 09:44 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2