Some Compiling Problems
I'm trying to compile a C program (something that writes a table, the code is fine, and not the issue) in my terminal (on an Apple). However, whenever I try to execute "gcc temp.c", "bash: cd: /usr/local/include: Not a directory" is returned. I've tried to use "mkdir /usr/local/include" to remedy the problem, which may have been the completely wrong approach, but it's not working. Any advice?
Mm. Wild guess -- your compiler is looking for the header/library files in the wrong place.
Show us your includes, maybe? :)
Somehow you've gotten things mis-configured, then. You'll have to look where your include files are (/usr/include, maybe?) and either re-configure gcc to look there, or move everything to the new place where gcc is looking (I highly suggest the first option).
Alright, I've located all of my include files, but am now having a hard time figuring out how to get gcc to redirect its path to that particular folder. I'm obviously a newbie (a couple days of this), and am sorry to litter the threads with these questions, but I figure it's one of my best resources. Thanks again!
The quick-and-dirty solution would be to type
every time you compile, but that gets real annoying real fast.
Did you install this yourself, or did you get Xcode? If you built yourself, how did you do it, and what went wrong? (As autotools shouldn't have gotten us this wedged up.) I'm not sure what the system path is on BSD, and I'm not on the Mac at the moment, so I don't know whether or not your files are in the right place and the system is misconfigured, or the system is configured normally but your files ended up somewhere else.
Another solution is to dump the stats file and modify that. Could get hairy.
Originally Posted by tabstop
I got Xcode, which should have made this all easier, but I clearly messed something up. Could any of these commands have been potentially damaging?
gcc -c -ggdb -std=c99 cs50.c -o cs50.o
ar rcs libcs50.a cs50.o
sudo cp cs50.h /usr/local/include
sudo cp libcs50.a /usr/local/lib
Another MIT CS50 person I see.
So: since /usr/local/include wasn't a library, you copied cs50.h to have that name. And ditto for libcs50.a -- it is now the file /usr/local/lib.
Wherever your real directory is, you should have used that at the end of each of your sudo cp lines.
So I'm sure the solution isn't as easy as redoing the sudo command (not that I'd be sure what to include with them anyway), so am I in more trouble than a novice can handle? Or, ideally, is there a reachable solution?
No the solution is to redo the sudo command.