February 2nd, 2018, 10:36 AM
-
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
February 2nd, 2018, 12:24 PM
-
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 theoption 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!
February 2nd, 2018, 02:42 PM
-
This gives me something to go from thank you.
Are there any tools to manage c libraries?
February 3rd, 2018, 03:25 PM
-
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!
February 7th, 2018, 08:31 AM
-
Great, thanks! I'll check those out.