1

i’m working on project that uses discount library. http://www.pell.portland.or.us/~orc/Code/discount/ i installed the library on my machine and included:

#include <mkdio.h>

and i have this piece of code:

MMIOT* document = 0;
char* result;
QString sourceMarkdown(markdown);
if (!sourceMarkdown.endsWith('\n'))
    sourceMarkdown.append('\n');
QByteArray data = sourceMarkdown.toUtf8();
document = mkd_string(data,data.length(),MKD_NOPANTS);
mkd_compile(document,MKD_NOPANTS);
mkd_document(document,&result);
QString renderedHtml = QString::fromUtf8(result);
return renderedHtml;

usualy i use “-lmarkdown” flag to compile it (for discount shared library). but in Qt i dont know how. i tried

QMAKE_LFLAGS += -lmarkdown

and

unix|win32: LIBS += -lmarkdown

but didn’t work. Error messages:

undefined reference to `mkd_string(char const*, int, unsigned int)'
undefined reference to `mkd_compile(void*, unsigned int)'

etc...

any help?

Abdeljalil
  • 23
  • 3

1 Answers1

0

It looks like the authors of the markdown library did not consider C++ users like yourself.

Step 1: verify that libmarkdown exports the symbols you are looking for:

nm /path/to/libmarkdown.{a,so} | grep 'mkd_string'

If you see something like

0x123456 T mkd_string

my guess is correct. If you see something like this instead:

0x123456 T  _Z10mkd_stringPKcij

my guess is wrong.

Step 2: if my guess is correct, you'll need to modify the way you #include <mkdio.h> to this:

extern "C" {
#include <mkdio.h>
}

You may also wish to contact developers of the library and let them know that they can fix this problem pretty easily by putting equivalent code into mkdio.h itself.

P.S. More info on C++ name mangling here.

Employed Russian
  • 199,314
  • 34
  • 295
  • 362