Thread: Including header files outside of current dir (AVR GCC, Code::Blocks)

  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    6

    Including header files outside of current dir (AVR GCC, Code::Blocks)

    Environment:
    Operating System: Windows 7 x64
    IDE: Code::Blocks
    Compiler: GNU AVR GCC
    Simplified folder structure:
    D:\ProjectDir\src\main.c
    D:\MyAwesomeFuncs\Funcs.h
    D:\MyAwesomeFuncs\Funcs.c
    main.c
    Code:
    #include "..\..\MyAwesomeFuncs\Funcs.h"
    int main() {
        myFunc();
        return 0;
    }
    The error:
    Undefined reference to `myFunc'

    Besides not working, the #include looks ugly as hell.

    I've tried adding the MyAwesomeFuncs folder to "Settings >> Compiler and debugger... >> GNU AVR GCC Compiler >> Search directories >> Compiler" to try to simulate the -I flag I found about when searching for an answer.

    I have no interest in building my projects by hand on the Command Prompt.


    So how do I do this?
    Thanks!

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Read about and learn to use CB Global Variables Global compiler variables - CodeBlocks

    The "Undefined reference" error is a linking error.

    Also read this CB FAQ http://wiki.codeblocks.org/index.php...files_exist.3F

    Tim S.
    Last edited by stahta01; 02-01-2012 at 03:30 PM.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  3. #3
    Registered User
    Join Date
    Oct 2011
    Posts
    6
    Like I said in the OP, I've already tried this without success.

    Read about and learn to use CB Global Variables Global compiler variables - CodeBlocks
    I read it and tried it... I don't think I really understood it, to be honest.

  4. #4
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Quote Originally Posted by Pulse Cloud View Post
    Like I said in the OP, I've already tried this without success.
    No where in your posts mentions adjusting the linker search paths and linking to the correct object file/library file.

    I have little to add CB Global Variables FAQ.

    Tim S.
    Last edited by stahta01; 02-01-2012 at 05:29 PM.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  5. #5
    Registered User
    Join Date
    Oct 2011
    Posts
    6
    Quote Originally Posted by stahta01 View Post
    No where in your posts mentions adjusting the linker search paths and linking to the correct object file/library file.
    So I need object files and library files?
    I've never even heard of the latter!

    I'll do some research.

  6. #6
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Quote Originally Posted by Pulse Cloud View Post
    So I need object files and library files?
    I've never even heard of the latter!

    I'll do some research.
    object files or library files
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Including header files
    By 127.0.0.1 in forum C Programming
    Replies: 2
    Last Post: 06-13-2011, 08:48 AM
  2. Header Files / Including
    By FlamingAhura in forum C Programming
    Replies: 2
    Last Post: 11-03-2010, 09:03 PM
  3. Including my own header files
    By bushymark in forum C Programming
    Replies: 17
    Last Post: 11-03-2009, 09:09 PM
  4. including linux header files
    By jacobh in forum Linux Programming
    Replies: 7
    Last Post: 10-19-2009, 03:17 PM
  5. Including header files
    By Emeighty in forum C++ Programming
    Replies: 5
    Last Post: 08-09-2008, 03:02 PM