#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2009
    Posts
    154
    Rep Power
    19

    Including external Library GCC & Atom


    Hi,

    I'm very new to C and I need to include an external library in a program i'm writing. I'm struggling to figure out how to do this though. I'm using Atom and it's built in GCC compiler.

    So in my code i've added my include:
    Code:
    #include <tomcrypt.h>
    But when i try to compile i get the error:
    D:\c\Encryption\BasicEncrpytion\fileEncrypt.c:4:21: fatal error: tomcrypt.h: No such file or directory
    compilation terminated.
    So do i need to let the compiler know to reference this library? I've tried to find some documentation on it but find it spotty at best. Any advice would be great!

    Thanks,
    DSFX
  2. #2
  3. Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Aug 2011
    Posts
    5,920
    Rep Power
    509
    The linker will need to find the library having the necessary tomcrypt objects, which might be tomcrypt.dll.
    However, this error takes place in the preprocessing step of compilation in which gcc is collecting the entire source and expanding preprocessor macros.
    You'll need some way to tell gcc where to find tomcrypt.h, and you might also need to change
    #include <tomcrypt.h>
    to
    #include "tomcrypt.h"

    I don't know about this Atom environment. You could put the tomcrypt.h file in your current directory---almost certainly a bad idea, you could include the path to tomcrypt as in

    #include "d:\some\path\tomcrypt.h"

    This is another bad idea.

    Or you could figure out how to pass the
    Code:
    -Id:\some\path
    option to gcc. To complete the compilation you'll need to move files into your current directory (unsustainable!) or learn about the -L and -l compiler options.

    You might even need to learn about some form of `make'. Good luck.
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2009
    Posts
    154
    Rep Power
    19
    This gives me something to go from thank you.

    Are there any tools to manage c libraries?
  6. #4
  7. Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Aug 2011
    Posts
    5,920
    Rep Power
    509
    yes. ranlib, ar, libtool and make on unix, the compilers, microsoft lib command: https://msdn.microsoft.com/en-us/library/0xb6w1f8.aspx ,
    LD_LIBRARY_PATH (unix) is a runtime environment variable storing paths to find dynamic libraries,
    and in DOS I suppose the PATH should include locations of dlls.
    [code]Code tags[/code] are essential for python code and Makefiles!
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2009
    Posts
    154
    Rep Power
    19
    Great, thanks! I'll check those out.

IMN logo majestic logo threadwatch logo seochat tools logo