PDA

View Full Version : Problem using discount library



Abdeljalil
1st November 2014, 18:57
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.
any help?

anda_skoa
1st November 2014, 19:52
The LIBS variant is the right one, but this will only find the library if it is in the compiler/linker's search path.
Usually the LIBS string also needs and -L directive to add the library's path to that.

Cheers,
_

Abdeljalil
1st November 2014, 20:46
welcom,
i tried this

LIBS += -L/usr/local/lib/ -lmarkdown

but didn't work either :-(
and the result is : undefined reference to ...

ChrisW67
1st November 2014, 20:59
Is /usr/local/lib where you installed the library?
Did you rerun qmake after making that change?
Is the "undefined reference to ..." Error message even related to the discount library? ... We cannot see.

Abdeljalil
1st November 2014, 21:31
the path is:
/usr/local/lib/libmarkdown.a
i'm using QtCreator and qmake should update automaticlly
sure :-) , undefined reference to mkd_string() mkd_compile() mkd_document()

anda_skoa
2nd November 2014, 13:01
Does the library contain the symbol?



objdump -t /usr/local/lib/libmarkdown.a | grep mkd_compile


Cheers,
_

Abdeljalil
3rd November 2014, 18:54
Thank you guys :)
i solved it, just used:



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