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 > Using Mac OS X for "standard, unix-like" c development

Using Mac OS X for "standard, unix-like" c development
Thread Tools
jakobf
Guest
Status:
Reply With Quote
Oct 16, 2000, 04:56 PM
 
I'm a computer sciense student wanting to use my new Mac OS X box for developing "standard", command-line programs in c.

I've downloaded and installed the developer tools from Apple ADC and I'm able to compile c code from the Project Builder.

However, as the decelopment I want to do is taking place in a group and some of it happens on "standard" Unix boxes, I'd like to develop in a more text/command line oriented way, i.e. using
- Makefiles
- make
- gcc from the command line
- cvs source control over ssh to a remote server

The header files included when I just use cc plain doesn't seem to be very ansi c. For example, when compiling a minimal "hello world" program, the compiler exits cleanly, producing executable binary code. However, no output occurs.
Also, many files seems missing - for example, stdio.h and memory.h seems to be there, but malloc.h produces an error.

So my question is: Have any one got information about setting up an environment as this - or am I bound to use the Project Builder - and thus disabled from integrating my OS X into a standard workflow?
     
Forum Regular
Join Date: Sep 2000
Status: Offline
Reply With Quote
Oct 16, 2000, 10:29 PM
 
Well, malloc.h is certainly there...and I just now wrote a simple "Hello world" app in vi and compiled it using cc, and it executed flawlessly.

I've had no problems working from the command line. Project Builder is actually just a front-end for the command-line tools, so there's no reason you would be forced to use it (although I rather like it myself).

Can you give examples of what you're trying to do and the errors you're receiving?
     
jakobf
Guest
Status:
Reply With Quote
Oct 17, 2000, 03:41 AM
 
I like the ProjectBuilder too. The only reason for using the commandline tools is that I need to cooperate with the Unix-world, and they don't know much about the ProjectBuilder :-)

When I try to compile e.g. memory.c containing this code:
---

#include <stdio.h>
#include <malloc.h>

void *Malloc(unsigned n)
{ void *p;

if (!(p = malloc(n))) {
fprintf(stderr,"Malloc(%d) failed.\n",n);
fflush(stderr);
abort();
}
return p;
}

---
using
gcc -Wall -ansi -pedantic -c -o memory.o memory.c
(of course, my gcc is just an alias to the cc; used for compability with Unix makefiles)


I get the following error:
memory.c:2: header file 'malloc.h' not found

I guess my install just went wrong somehow; do you know whether it's necesarry to login as root (uid 0) when installing, or will it suffice to be logged in as an administrative user?

Thanks for your help so far
     
Junior Member
Join Date: Oct 2000
Status: Offline
Reply With Quote
Oct 17, 2000, 10:24 AM
 
try:

#include <sys/malloc.h>

I did a 'locate malloc' and it shows it in the sys directory.

later,

bob
     
jakobf
Guest
Status:
Reply With Quote
Oct 18, 2000, 08:40 AM
 
It seems I was the one who made a mistake :-) Biiig surprise ;-)

Reading my documentation, it appears malloc.h is not part of the ANSI C standard library; that's why
#include <malloc.h>
doesn't work, whereas
#include <sys/malloc.h>
does work.

The problem is that the UNIX system I will have to cooperate with is set up in such a way that gcc include path for header files contain the sys-directory. That means, that in the source files I need to compile (without having to modify them) do allow the
#include <malloc.h>
directive - i.e., without the sys/ prefix.


My question is, which version of the c header files does gcc use?
I can find at least 3 different places containing stdio.h and the other header files from the standard library. If I know which one of these directories the cc compiler uses, I could setup the environment variable telling cc to add the sys-directory in the standard c directory to the search path for header files - and that would get me going, I guess.

To recap:
Does anyone know the correct path of the directory used by cc for standard header files?

Kindly,
Jakob
     
   
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:47 PM.
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