PDA

View Full Version : Problem with NCReport : can't link shared library !



QAmazigh
4th June 2009, 18:32
hello everyone :)
i am using Qt4.4.0 on Ubuntu Hardy.
i want to make some report to print from my application so i get the NCReport (NCReport_2.1.1_Linux_bin_Qt4.4.1.tar.gz) from http://nocisoft.com/?id=down&lang=en .

i made a small report with NCReportDesigner & everything is good !
but when i try to run it from my application i get the error :

error while loading shared libraries: libncreport.so.2: cannot open shared object file: No such file or directory

i followed the documentation so in my .pro i added :

INCLUDEPATH = NCReport2/include

win32 {
LIBS += NCReport2/lib/ncreport2.lib
}
unix {
LIBS += -lncreport -L NCReport2/lib -L/usr/local/bin
target.path = /usr/local/bin
}

include contains the header files
and lib contains libraries

in lib folder i have :

libncreportdesigner.so -> libncreportdesigner.so.2.1.1
libncreportdesigner.so.2 -> libncreportdesigner.so.2.1.1
libncreportdesigner.so.2.1 -> libncreportdesigner.so.2.1.1
libncreportdesigner.so.2.1.1
libncreport.so -> libncreport.so.2.1.1
libncreport.so.2 -> libncreport.so.2.1.1
libncreport.so.2.1 -> libncreport.so.2.1.1
libncreport.so.2.1.1

i tried to change the name libncreport.so.2.1.1 to libncreport.so.2 as the error say and i put it in /usr/lib , the error disappear but the report doesn't run , so i think changing name was not a good idea :(

code genarating report :


NCReport *report = new NCReport();
report->reset();
report->setReportFile("reports/report1.xml"); // report file
report->addItemModel(model,"model1");
report->runReportToPrinter();


anyone can help please ??
or if anyone has NCReport sources(.cpp) , so we don't need libraries ...

thanks :o

wysota
4th June 2009, 21:46
Your code is fine. The library can't be found when the dynamic linker is asked to resolve all the missing symbols when you execute the application. Compilation has nothing to do with it - the linker there was able to find the library because you pointed it to it using the "-L" option. Now you have to point it to the linker during runtime. Either place the library in a directory where the linker looks for it (like /usr/lib) or set the LD_LIBRARY_PATH environment variable to the directory containing the library.

QAmazigh
5th June 2009, 12:00
thanks for informations wysota
i copied all the contents of lib directory to /usr/lib and it's working pefect ;)
i loved this ncreport , it's better than Crystal !

but i want to make application portable , so i need to put libraries in my application folder :/

"set the LD_LIBRARY_PATH environment variable to the directory containing the library. "
how ?? what to add in .pro ??

thanks !

wysota
5th June 2009, 14:21
Adding anything to the pro file will not help. The "problem" is not related to compilation, I already told you that. Please google for LD_LIBRARY_PATH.

QAmazigh
5th June 2009, 23:38
ah oké , thanks
i read an article about this variable , i can add my directory to LD_LIBRARY_PATH.