The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   OS X Developer (http://hintsforums.macworld.com/forumdisplay.php?f=27)
-   -   XCode C programming help (http://hintsforums.macworld.com/showthread.php?t=55647)

orangejuice 05-14-2006 11:38 AM

I need to use Xcode for basic C programing. I ve installed Xcode 2.0 but got some problems:

I run xcode, go to file>>>new project>>>command line utility>>>CPP tool.

After that i select main.cpp, edit it, build it but then comes this error:

Tool:0: Couldn't run '/usr/bin/gcc-3.3' because it does not refer to an accessible executable.


what's that error? i m really new to xcode and cant solve this problem...

hayne 05-14-2006 05:12 PM

That sounds like something is wrong with your Xcode installation. Did you do anything unusual with it?

What version of OS X do you have?
What model of Mac do you have? Is it an Intel-based Mac?

What do you get from the following commands (in a Terminal window):

which gcc
ls -l /usr/bin/gcc*

szymczyk 05-14-2006 05:18 PM

Quote:

Originally Posted by orangejuice
I need to use Xcode for basic C programing. I ve installed Xcode 2.0 but got some problems:

I run xcode, go to file>>>new project>>>command line utility>>>CPP tool.

For C programs you should use a Standard Tool project instead of a C++ Tool project. It won't solve the error message you're getting, but it will make C programming go smoother in Xcode.

orangejuice 05-14-2006 05:24 PM

i didnt download Xcode, i searched in spotlight and found the setup file for xcode, then installed it.

didnt do anything unsual during installation but maybe i should download it again?

i m using a 12' powerbook with 1.5 Ghz G4 processor and 512mb of ddr.
OS X version: 10.4.4

what i get is:

no gcc in /bin /sbin /usr/bin /usr/sbin


maybe the problem is here? i dont understand much at all, new to mac.. : (

hayne 05-14-2006 05:53 PM

Quote:

Originally Posted by orangejuice
i didnt download Xcode, i searched in spotlight and found the setup file for xcode, then installed it.

I don't understand. There is no Xcode in the standard OS X install.
Do you mean that you used Spotlight to search the Tiger DVD? I didn't think Spotlight worked with DVDs.
I'm not sure what you did.

Xcode is an optional part of the Tiger install. If you look on your Tiger DVD, you should find an optional (or maybe its called "Extras" or something) section. Under that you should find the installer for Xcode Tools.

Quote:

OS X version: 10.4.4
Is there some reason why you aren't up to the latest version (10.4.6)? You should update via SoftwareUpdate - there are lots of important security updates.

Quote:

what i get is:

no gcc in /bin /sbin /usr/bin /usr/sbin
tugrul-okans-powerbook-g4-12:~ tugrulokan$ ls -l /usr/

The first line seems to indicate that you haven't installed Xcode.
But you messed up the second command that I asked you to run.
Please try again. Copy and paste the 2 lines of commands that I mentioned in my previous post, then press Return, and then copy & paste the results back here.

orangejuice 05-14-2006 06:06 PM

Quote:

Originally Posted by hayne
I don't understand. There is no Xcode in the standard OS X install.
Do you mean that you used Spotlight to search the Tiger DVD? I didn't think Spotlight worked with DVDs.
I'm not sure what you did.

first, i learned that Xcode was the program i was looking for. my friend told me to download it, or look at my tiger dvd. before that i thought that it could be in the disk by default so i wrote xcode to spotlight, and reallt found it. it was the setup file for sure, and the installation was completed with success.

Quote:

Originally Posted by hayne
Is there some reason why you aren't up to the latest version (10.4.6)? You should update via SoftwareUpdate - there are lots of important security updates.

there is no reason, i know i should.. :o :o

Quote:

Originally Posted by hayne
The first line seems to indicate that you haven't installed Xcode.
But you messed up the second command that I asked you to run.
Please try again. Copy and paste the 2 lines of commands that I mentioned in my previous post, then press Return, and then copy & paste the results back here.

i m sorry for the mess :o
it should be:
which gcc>>>> no gcc in /bin /sbin /usr/bin /usr/sbin,
ls -l /usr/bin/gcc*>>>> lrwxr-xr-x 1 root wheel 7 May 13 17:32 /usr/bin/gcc -> gcc-3.3


EDITED:
it's really interesting that i had this xcode setup in my powerbook if it's not a default install.
a friend took my pbook when he went to london for 2 weeks... maybe he added xcode setup file, he uses such programs frequently. i dont know where it came from, thought it was default, but you say that it's not.. :confused:

hayne 05-14-2006 06:51 PM

Quote:

Originally Posted by orangejuice
ls -l /usr/bin/gcc*
lrwxr-xr-x 1 root wheel 7 May 13 17:32 /usr/bin/gcc -> gcc-3.3

If that's the only result from the command
ls -l /usr/bin/gcc*
then your Xcode installation is really messed up.
You should get something like this:
Code:

% ls -l /usr/bin/gcc*
lrwxr-xr-x  1 root  wheel      7 Nov 11  2005 /usr/bin/gcc -> gcc-4.0
-r-xr-xr-x  1 root  wheel  264712 Oct 31  2005 /usr/bin/gcc-3.3
-rwxr-xr-x  1 root  wheel  80484 Nov  1  2005 /usr/bin/gcc-4.0

I would recommend first using the script "/Developer/Tools/uninstall-devtools.pl" to uninstall Xcode and then re-install it from the Tiger DVD.

orangejuice 05-14-2006 07:21 PM

Quote:

Originally Posted by hayne
If that's the only result from the command
ls -l /usr/bin/gcc*
then your Xcode installation is really messed up.
You should get something like this:
Code:

% ls -l /usr/bin/gcc*
lrwxr-xr-x  1 root  wheel      7 Nov 11  2005 /usr/bin/gcc -> gcc-4.0
-r-xr-xr-x  1 root  wheel  264712 Oct 31  2005 /usr/bin/gcc-3.3
-rwxr-xr-x  1 root  wheel  80484 Nov  1  2005 /usr/bin/gcc-4.0

I would recommend first using the script "/Developer/Tools/uninstall-devtools.pl" to uninstall Xcode and then re-install it from the Tiger DVD.

yes thats the only result. i ll re-install from the dvd. thanks : )

orangejuice 05-15-2006 08:51 AM

reinstalling from the dvd solved the problem!

thanx! : )))

harwell 05-24-2006 10:32 PM

Really Simple C/C++ Plea
 
[QUOTE=orangejuice]I need to use Xcode for basic C programing. I ve installed Xcode 2.0 but got some problems:

:confused: Thus spake OJ, but my needs are really simple, folks. I just want to *start* programming in C (or C++) under 10.3. I've looked at the XCode Tools install package and it looks like a lot more than I need. I'd just like to follow examples in a textbook [such as C++ for Dummies] to write code and compile. And then see if it works -- nothing fancy.

The packages shown in Made4Mac at Apple's website seem to be for developers. I'm just not there yet. What can I get and what do I need to load? Sorry if this is posted out of sequence.

hayne 05-24-2006 11:07 PM

Quote:

Originally Posted by harwell
but my needs are really simple, folks. I just want to *start* programming in C (or C++) under 10.3. I've looked at the XCode Tools install package and it looks like a lot more than I need. I'd just like to follow examples in a textbook [such as C++ for Dummies] to write code and compile. And then see if it works -- nothing fancy.

The packages shown in Made4Mac at Apple's website seem to be for developers. I'm just not there yet. What can I get and what do I need to load? Sorry if this is posted out of sequence.

If you want to do any sort of C or C++ development (simple or complex) on OS X, you need to install the Xcode Tools.
Then create a new project in Xcode and choose "Standard Tool" (for C) or "C++ Tool" (for C++) as the project type. Type in your code and press the Build and Run buttons.

harwell 05-24-2006 11:25 PM

Thanks, hayne
 
It's worth a try -- thanks for the info re X Code tools.

hermasj 05-27-2006 11:31 AM

harwell,

Just to add a little to what hayne has said...

You don't really have to use Xcode to write C/C++ programs if you are starting out with small examples. You can write your programs in any text editor then compile, link and run them all from the command line in Terminal.

But...

You'll still need to install Xcode Tools because in addition to installing Xcode, Interface Builder and the other GUI development tools the Xcode Installer also installs all the basic compilers, linkers, libraries, header files, etc. that you need to do your work from the command line.

Steve

xesrever 05-28-2006 10:50 AM

Xcode speeds up the development process if you are building a complicated application, but I don't recommend using an IDE for the sole purpose of compiling examples from a book. Just install the Xcode Developer Tools so that you'll have GCC and G++ 4.0, and compile from the command line. To compile a C++ program with just a few source files, type:
Code:

g++ -g -Wall -o [executable name] [source file 1] [source file 2] ...

anurags 06-02-2006 07:11 AM

Help for Xcode version 2.2.1
 
Hi All

I am using Xcode version 2.2.1 for C Programming on MAC 10.4.5 intel based processor.

I want to get resource fork so I am using API's

FSpOpenResFile() , and

OSErr FSpOpenRF (
const FSSpec * spec,
SInt8 permission,
short * refNum
);


etc and want to use variable like FSSpec.

which library and header file i have to include for using these API's
and where is option to include library in Xcode environment.

thanx
anurags

hayne 06-02-2006 11:37 AM

Quote:

Originally Posted by anurags
I am using Xcode version 2.2.1 for C Programming on MAC 10.4.5 intel based processor

You should update to 10.4.6 (using Software Update) and Xcode 2.3 (by downloading from the Apple developer site).

Quote:

which library and header file i have to include for using these API's
and where is option to include library in Xcode environment.
I'm not sure, but I think these are Carbon library functions and so you should just add the Carbon framework to your project.
You need to read the Apple developer docs about Carbon and the Help pages for Xcode. The latter covers adding frameworks to your project.

anurags 06-06-2006 07:01 AM

About Framework Library
 
Hi All

I am using Xcode 2.3, and project type CoreServices.

why there are so many library..it's really very confusing for any user.
such as i want to add CorbanLib but i have seen it at so many places such as

1) /System/Library/Frameworks/Carbon.framework/Carbon
2) /System/Library/Frameworks/Carbon.framework/Versions/A/Corban

and for CoreServices.h, i have also seen it at so many places.

1) /System/Library/Frameworks/CoreServices.framework/Headers
2) /System/Library/Frameworks/CoreServices.framework/Versions/A/Headers

and similary Files.h exists at many places.


Act i want to know what it's mean /Vesions/A/Headers

why files are here and before it (in hierarchy)



anurags

hayne 06-06-2006 12:26 PM

Quote:

Originally Posted by anurags
why there are so many library..it's really very confusing for any user.
such as i want to add CorbanLib but i have seen it at so many places such as

1) /System/Library/Frameworks/Carbon.framework/Carbon
2) /System/Library/Frameworks/Carbon.framework/Versions/A/Corban

1) You don't need to worry about this. You don't need to know where the files for the libraries are located. Xcode will take care of this.

2) You need to read the docs on Xcode & Carbon as I said in my previous post. You aren't going to be successful without doing that.

3) As a beginner, you need to work on lots of small sample programs before you even start working on the program you want to create. Start with one of the examples that Apple has supplied under /Developer/Examples. Modify it slightly, compile & run. Modify again. Then go on to a different example.

anurags 06-13-2006 02:19 AM

About Xcode 2.3 /Developer/Tools/RezDet
 
Hi All

Anyone please help me to use Xcode 2.3 use the /Developer/Tools/RezDet utility to examine resource files (whether resource-fork resource files or data-fork resource files) for correctness.

Thanks
Anurag

hayne 06-13-2006 03:20 AM

I don't know anything about this, but googling for: RezDet
finds several pages with possibly useful info.
Otherwise, you are probably best to ask on the Carbon developers mailing list.

nitewing98 07-01-2006 04:26 AM

Xcode for simple C programs
 
Quote:

Originally Posted by xesrever
Xcode speeds up the development process if you are building a complicated application, but I don't recommend using an IDE for the sole purpose of compiling examples from a book. Just install the Xcode Developer Tools so that you'll have GCC and G++ 4.0, and compile from the command line.

I disagree. Most anyone learning to program is going to have to deal with an IDE sometime, whether Xcode, Visual C++, or the KDE developer tools. You might as well learn to function in that environment.

That being said, Xcode isn't that bad for writing simple C code, I used it when I was learning to program in C++ and it worked great. In fact, since the Apple programmer tools use gcc to compile, my code files were able to be ported to Linux with no problem. Of course, Visual C++ had some oddities (there's Microsoft for you) and the files needed minor tweaks to compile.

Nitewing '98
Nitewing '98's AppleScript Hideout


All times are GMT -5. The time now is 06:19 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.