• Visitors can check out the Forum FAQ by clicking this link. You 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. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Having a mare with gcc compiler switches

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    Having a mare with gcc compiler switches

    Let's say for argument's sake I have some code that is structured like

    c:\projects\myapp - main.c global.h

    c:\projects\myapp\subsection\somemorecode.c somemorecode.h

    Now I want somemorecode.h to #include global.h, which is in the parent directory.

    I could use #include <c:\\projects\myapp\global.h> but I don't want hard coded paths

    rather I would like to add a search path to the compiler

    eg

    gcc -o -Ic:\projects\myapp\ main.exe main.c

    However it still can't find the header.

    What am I doing wrong? Why even though the search path is specified can it still not find the global.h?
    Knock first as I might be balancing my chakras.

    #2
    Just guessing really, but do you need to use #include "..." rather than #include <...> alongside the -I flag?
    Where are we going? And what’s with this hand basket?

    Comment


      #3
      Originally posted by voodooflux View Post
      Just guessing really, but do you need to use #include "..." rather than #include <...> alongside the -I flag?
      Yep, just spotted that, thanks. Still fooked tho.
      Knock first as I might be balancing my chakras.

      Comment


        #4
        got it

        bearing in mind this is windoze

        gcc -IC:\projects\myapp\ -o main.exe main.c

        The problem was apart from as was correctly mentioned using #include "" and not <> was that the -o switch was before the -I switch. Moving it to after the path did the trick.

        Thanks for your help mate.
        Knock first as I might be balancing my chakras.

        Comment

        Working...
        X