I want to use the Discount C-library to convert Markdown text into HTML. I have already successfully compiled and installed the library (version 2.1.3).
I tried to compile this code
#include <mkdio.h>
int main(void)
{
FILE *in, *out;
MMIOT *doc;
in = fopen("sample.md", "r");
out = fopen("out.html", "w");
doc = mdk_in(in, 0);
markdown(doc, out, 0);
...
}
Explanation: mkd_in()reads the input file ininto the library working-type MMIOT doc and markdown() should convert doc to HTML and writes is to the out file.
with the command gcc -Wall -lmarkdown -o FILE FILE.c and I always get the following output:
undefined reference to `mkd_in(_IO_FILE*, unsigned int)'
undefined reference to `markdown(void*, _IO_FILE*, unsigned int)'
Note: I’ve run the configuration tool of Discount with the --shared option to build a dynamic library. Default is a static library but with that I’ve got the same problem.
Try this instead:
The placement of
-lis significant in that many linkers will only use libraries to satisfy unresolved references if they exist at the time when the-lis parsed. This can cause all sorts of problems with circular dependencies, for example.Where you have it originally, those functions aren’t unresolved since you haven’t yet compiled
FILE.c. When you do compileFILE.c, there’s no-lfollowing that point to satisfy the references.From the
gccman-page:And, later, under
-l: