CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2010
    Posts
    6

    directory references for included header files (gifsicle)

    I am trying to include some code from a Debian package in a program that I am writing. The package code compiles fine on its own, but when I try to include it, it is unable to find some of the files that it includes within itself.

    The package is gifsicle, and I'm trying to include a header file gif.h in my own program. gif.h has the include line at the top "#include <lcdf/inttypes.h>" which causes an error when included in my file, but results in no error when the gifsicle package is compiled by itself. To some degree, I see the problem: the inttypes.h file is more correctly referenced as "../lcdf/inttypes.h" relative to where gif.h is in the directory structure, and not as "lcdf/inttypes.h". A subtle, but important difference! At the moment, I actually have a hard time understanding why the gifsicle package compiles at all, because of this reference, but it does.

    One solution might be to modify the include lines within the Debian package, something that I really don't want to do.

    Is there a way to override where it is the compiler looks for this file without modifying the package source code? Or is it possible to precompile the gifsicle code somehow before the functions are referenced by my code so that all I need is a library reference or the like? Is there some detailed reference material that might explain why the Debian package is able to compile without an exact reference to the location of the header file that it includes?

  2. #2
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: directory references for included header files (gifsicle)

    Add more include "roots" to your compilation command line like g++ -I path1 -I path2 (or in the makefile). Every "root" you add the compiler will use in order to find the header.

    For instance, say that /.../what/ever/lcdf/inttypes.h is the valid path.

    Then setting path1 to /.../what/ever/ will work for all the #include "lcdf/inttypes.h" but not for the #include "../lcdf/inttypes.h".

    Adding path2 as /.../what/ever/lcdf/ will do the trick since now the header can be found at /.../what/ever/lcdf/../lcdf/inttypes.h
    Last edited by S_M_A; March 25th, 2010 at 05:57 PM.
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  3. #3
    Join Date
    Mar 2010
    Posts
    6

    Re: directory references for included header files (gifsicle)

    Many thanks, S_M_A. That solved the problem!

  4. #4
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: directory references for included header files (gifsicle)

    You're welcome!
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured