Quick questions with linking?

This is a discussion on Quick questions with linking? within the C Programming forums, part of the General Programming Boards category; I was just wondering if you were compiling to get a header? like /home/Desktop main.c and the header for that ...

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    192

    Quick questions with linking?

    I was just wondering if you were compiling to get a header? like

    /home/Desktop main.c
    and the header for that was in
    /home/Desktop/h

    i would probably have to

    gcc -I./h main.c main

    Something like that but I was wondering if i just added in the path

    export PATH=$PATH:/home/Desktop/h

    Would that be the same thing as linking in the compile line so i would only have to

    gcc -o main.c main

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,931
    I do not think that the compiler will check the system path for include locations, but it depends on the compiler implementation.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Not the system path, but gcc does follow $C_INCLUDE_PATH, which is undefined by default.

    C_INCLUDE_PATH=$HOME/C/include

    The g++ equivalent is CPLUS_INCLUDE_PATH.
    Also, gcc/g++ or ld (the GNU linker) follows this one:

    LIBRARY_PATH=$HOME/lib

    You can export those from your .bashrc. Then you can compile yer libraries, put them ~/lib, put the headers in ~/C/include, and use:

    Code:
    #include <myheader.h>
    gcc whatever.c -lmylib
    Last edited by MK27; 04-16-2010 at 01:03 PM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A few quick questions
    By Brodie337 in forum C Programming
    Replies: 12
    Last Post: 04-06-2009, 01:00 AM
  2. Several Questions, main one is about protected memory
    By Tron 9000 in forum C Programming
    Replies: 3
    Last Post: 06-02-2005, 07:42 AM
  3. two quick questions
    By procyon4476 in forum Tech Board
    Replies: 6
    Last Post: 03-24-2003, 09:24 AM
  4. 2 quick questions
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 03-02-2002, 09:37 AM
  5. Couple Quick Questions.
    By Darkflame in forum C++ Programming
    Replies: 2
    Last Post: 09-15-2001, 03:44 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21