I have a library in my .c
:
#include "Madlib.h"
I know that now I gotta link it, otherwise it doesn't work. My trouble is understanding HOW do I link it. Every post I see talks about .a
libraries or with a lib
prefix. I got none of that. I have the header obvisouly and then a .lib
.
Anyways, I tried to make my way into those posts, and got here:
Although, when I try to compile, I get this:
Invoking: Cygwin C Linker
gcc -o "MCL.exe" ./src/example.o -lMADLib.lib
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lMADLib.lib: No such file or directory
collect2: error: ld returned 1 exit status
What exactly is that path? How can I expand it? Should I place the .lib
and .h
inside the folder that it refers to? Or should I add some kind of path to the library -I
entry?
You may have to do 2 things:
-lMADLib
instead of -lMADLib.lib
-L<path to library folder>
See here: https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html