Thread: Some Compiling Problems

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    7

    Some Compiling Problems

    Hey all,

    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?

  2. #2
    Novice
    Join Date
    Jul 2009
    Posts
    568
    Mm. Wild guess -- your compiler is looking for the header/library files in the wrong place.

    Show us your includes, maybe?

  3. #3
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    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).

  4. #4
    Registered User
    Join Date
    May 2010
    Posts
    7
    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!

  5. #5
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    The quick-and-dirty solution would be to type
    Code:
    -I/path/to/libraries
    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.

  6. #6
    Novice
    Join Date
    Jul 2009
    Posts
    568
    Quote Originally Posted by tabstop View Post
    The quick-and-dirty solution would be to type
    Code:
    -I/path/to/libraries
    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.

  7. #7
    Registered User
    Join Date
    May 2010
    Posts
    7
    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

  8. #8
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    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.

  9. #9
    Registered User
    Join Date
    May 2010
    Posts
    7
    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?

  10. #10
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    No the solution is to redo the sudo command.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Rendering problems (DirectX?)
    By OnionKnight in forum Tech Board
    Replies: 0
    Last Post: 08-17-2006, 12:17 PM
  2. problems with including headers
    By l2u in forum C++ Programming
    Replies: 3
    Last Post: 07-23-2006, 08:06 AM
  3. Problem Compiling
    By Flakster in forum C++ Programming
    Replies: 4
    Last Post: 06-13-2006, 01:09 AM
  4. Linking problems, class problems
    By Kheila in forum C++ Programming
    Replies: 12
    Last Post: 11-22-2005, 01:47 AM
  5. compiling problems LNK2019 error
    By sugie in forum C++ Programming
    Replies: 2
    Last Post: 10-19-2005, 05:25 PM

Tags for this Thread