Find the answer to your Linux question:
Results 1 to 3 of 3
hi, suppose I am in a subdirectory within /home/usr as Code: /home/usr/dir1 and i can compile as Code: gcc -c file.c This works.however, suppose i am at root and want ...
  1. #1
    Just Joined!
    Join Date
    Jun 2011
    Location
    dallas ,texas
    Posts
    18

    trouble compiling in predefined directory from root

    hi, suppose I am in a subdirectory within /home/usr
    as
    Code:
     /home/usr/dir1
    and i can compile as
    Code:
     gcc -c file.c
    This works.however, suppose i am at root and want to compile the same code. i use
    Code:
     gcc -c -I~/dir1 file.c
    or
    Code:
     gcc -c -I/home/usr/dir1 file.c
    i get the error : no such file or directory.
    where am i wrong? what is te right syntax for -I with gcc?
    thanks

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,970
    Quote Originally Posted by sed_y View Post
    hi, suppose I am in a subdirectory within /home/usr
    as
    Code:
     /home/usr/dir1
    and i can compile as
    Code:
     gcc -c file.c
    This works.however, suppose i am at root and want to compile the same code. i use
    Code:
     gcc -c -I~/dir1 file.c
    or
    Code:
     gcc -c -I/home/usr/dir1 file.c
    i get the error : no such file or directory.
    where am i wrong? what is te right syntax for -I with gcc?
    thanks
    Wrong syntax. Try:
    Code:
    gcc -c /home/usr/dire1/file.c -o file.o
    The -I option is to instruct the compiler where to find the include files, so if you have header files in /home/usr/dir1, you would include it as "-I /home/usr/dir1" in your compile line.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    Jun 2011
    Location
    dallas ,texas
    Posts
    18
    Thanks,
    so, with no header files, i can just give path w/o I directive.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...