I'm afraid the content of LIBS variable is not correct. For a reason or another the lib is not getting linked.
I'm afraid the content of LIBS variable is not correct. For a reason or another the lib is not getting linked.
J-P Nurmi
i suspect that too but after i read the qt documentation about sharing/linking of library i only got LIBS+= .lib file..
i only include that line to my .pro file and build. (am i missing something)
i try changing the path of .lib then error in building the file which mean it is really looking for the .lib
ncreport2 only have includes (which are .h) and lib that have ncreport2.lib, ncreport2.dll and ncreport2.exp
tnx for reply
i found the problem..
it is in the .h in importing the dll
#ifdef Q_WS_WIN
# if defined(NCREPORT_EXPORT)
# define NCREPORT_LIB_API __declspec(dllexport)
# elif defined(NCREPORT_IMPORT)
# define NCREPORT_LIB_API __declspec(dllimport)
# else
# define NCREPORT_LIB_API
# endif
#else
# define NCREPORT_LIB_API
#endif
i think its else if
but after i change elif to else if i got this warning
ncreport.h:50:8: warning: extra tokens at end of #else directive
ncreport.h:51:1: warning: "NCREPORT_LIB_API" redefined
is it wrong to use "else if"?
Add this line to your .pro file :
DEFINES += NCREPORT_IMPORT
And test. I think this may solve your problem...
tnx for the reply.. quite close but still far..
DEFINES += NCREPORT_IMPORT
yes i think i do need that.. but still got errors..
"undefined reference to `_imp___ZN8NCReportC1EP7QObject'"
i think the problem is in ncreport2.lib..
I copied the file to my project .pro
then add
LIBS += ncreport2.lib ? is this right?
plus i also copied the dll to the same path where my project is? again.. is this right?
as i posted earlier there is an error in syntax in defining the import/export class
do i need to edit that and make it "else if"? but i think the next line after else will be ignore#ifdef Q_WS_WIN
# if defined(NCREPORT_EXPORT)
# define NCREPORT_LIB_API __declspec(dllexport)
# elif defined(NCREPORT_IMPORT)
# define NCREPORT_LIB_API __declspec(dllimport)
# else
# define NCREPORT_LIB_API
# endif
#else
# define NCREPORT_LIB_API
#endif
plus this uses "__declspec(dllexport)" do i need to change that to "Q_DECL_EXPORT" and same with import?
in the ifdef Q_WS_WIN do i need to specify that im using WIN OS or it is automatically detected?
tnx
Simple : the library is not found at linking step. Check the syntax of LIBS part of .pro files ( documented here http://doc.trolltech.com/4.4/qmake-v...ence.html#libs )
No, you have to put something like this :LIBS += ncreport2.lib ? is this right?
LIBS += -L"/path/to/ncreport2.lib" -lncreport2
It must be enough. Test it...
At runtime, probably you will need it if the directory where resides the DLL is not in the PATH, as you're running windows.plus i also copied the dll to the same path where my project is? again.. is this right?
At compile/link time you only have to set correct paths on the LIBS section and everything must compile and link.
That line hasn't an error. #elif is a correct preprocessor reserved word. You don't have to touch nothing on header. Just make linker find the lib in the right place.as i posted earlier there is an error in syntax in defining the import/export class
do i need to edit that and make it "else if"? but i think the next line after else will be ignore
plus this uses "__declspec(dllexport)" do i need to change that to "Q_DECL_EXPORT" and same with import?
Q_WS_WIN is defined by QT, don't worry about it...in the ifdef Q_WS_WIN do i need to specify that im using WIN OS or it is automatically detected?
tnx
I hope this will be useful for you.
i try your post but still got errors.. jpujolf
i add this line to my project.probuild/dialogimpl.o(.text+0xa14):dialogimpl.cpp: undefined reference to `_imp___ZN8NCReportC1EP7QObject'
collect2: ld returned 1 exit status
mingw32-make.exe[1]: *** [bin\mync.exe] Error 1
C:\MinGW\bin\mingw32-make.exe: *** [release] Error 2
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -mthreads -Wl -Wl,-subsystem,windows -o bin\mync.exe build/dialogimpl.o build/main.o build/moc_dialogimpl.o -L"c:\Qt\4.3.5\lib" -lmingw32 -lqtmain c:/lib/ncreport2.lib -lQtSql4 -lQtXml4 -lQtGui4 -lQtCore4
INCLUDEPATH += "C:/Program Files/NCReport2/include"
LIBS += "C:/Program Files/NCReport2/lib/ncreport2.lib" or
-L"C:/Program Files/NCReport2/lib" -lncreport2 or -L"C:/Program Files/NCReport2/lib"
-lncreport2
DEFINES += NCREPORT_IMPORT
to my project.cpp i only include
#include <QSqlDatabase>
#include "C:/Program Files/NCReport2/include/ncreport.h"
#include "C:/Program Files/NCReport2/include/ncreportoutput.h"
#include "C:/Program Files/NCReport2/include/ncreportpreviewoutput.h"
#include "C:/Program Files/NCReport2/include/ncreportpreviewwindow.h"
then
NCReport *report =new NCReport(); (note: no other declaration of NCReport, is this ryt?)
then when i build it the error shows..
hayzzzzzzzzzzzzz..
So no need for the complete path in includes, only :
#include <ncreport.h>
#include <ncreportoutput.h>
#include <ncreportpreviewoutput.h>
#include <ncreportpreviewwindow.h>
That's right...DEFINES += NCREPORT_IMPORT
Put EXACTLY this :LIBS += "C:/Program Files/NCReport2/lib/ncreport2.lib" or
-L"C:/Program Files/NCReport2/lib" -lncreport2 or -L"C:/Program Files/NCReport2/lib"
-lncreport2
LIBS += -L"C:\Program Files\NCReport2\lib" -lncreport2
That's wrong !! As shown in the error you sent, you haven't put the LIBS line I wrote, or you haven't make qmake to generate a correct Makefile...Your compile output
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -mthreads -Wl -Wl,-subsystem,windows -o bin\mync.exe build/dialogimpl.o build/main.o build/moc_dialogimpl.o -L"c:\Qt\4.3.5\lib" -lmingw32 -lqtmain c:/lib/ncreport2.lib -lQtSql4 -lQtXml4 -lQtGui4 -lQtCore4
The link output must be something like this :
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -mthreads -Wl -Wl,-subsystem,windows -o bin\mync.exe build/dialogimpl.o build/main.o build/moc_dialogimpl.o -L"c:\Qt\4.3.5\lib" -L"C:\Program Files\NCReport2\lib" -lmingw32 -lqtmain -lncreport2 -lQtSql4 -lQtXml4 -lQtGui4 -lQtCore4
And again, take a look at qmake's / g++ documentation. I had initially the same problem and is well documented.
heres my .pro
Qt Code:
TEMPLATE = app QT = gui core sql xml CONFIG += qt \ release \ warn_on \ thread \ no_lflags_merge \ dll \ console DESTDIR = bin OBJECTS_DIR = build MOC_DIR = build UI_DIR = build TARGET = mync FORMS = ui/dialog.ui HEADERS += src/dialogimpl.h SOURCES += src/dialogimpl.cpp src/main.cpp INCLUDEPATH += "C:/Program Files/NCReport2/include" DEFINES = NCREPORT_IMPORT LIBS += [B]-L "C:\Program Files\NCReport2\lib" -lncreport2[/B]To copy to clipboard, switch view to plain text mode
same error:
if you notice i put -L<space>"<dir>" i cant do this -L"<dir>" (without space) same errorg++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -Wl,-subsystem,console -mthreads -Wl -Wl,--out-implib,bin\libmync.a -o bin\mync.exe build/dialogimpl.o build/main.o build/moc_dialogimpl.o -L"c:\Qt\4.3.5\lib" -L "C:\Program Files\NCReport2\lib" -lncreport2 -lQtSql4 -lQtXml4 -lQtGui4 -lQtCore4
mingw32-make.exe[1]: Leaving directory `C:/mync2'
build/dialogimpl.o(.text+0xa14):dialogimpl.cpp: undefined reference to `_imp___ZN8NCReportC1EP7QObject'
collect2: ld returned 1 exit status
mingw32-make.exe[1]: *** [bin\mync.exe] Error 1
C:\MinGW\bin\mingw32-make.exe: *** [release] Error 2
tnx for your time.."-Lc:\Program Files\NCReport2\lib" -lncreport2![]()
Why you can't ? "-Lc:\Program Files\NCReport2\lib" is wrong, -L"<path>" is correct, -L MUST be outside of quotes...
On the other hand, I've downloaded the windows version for NCReport2 and installed on a windows machine ( I work on a Linux box). I've been looking the documentation and I've found the origin of the error :windows package provides ONLY VC++ libraries. I was blind !! g++ libraries have a "<library_name>.a" naming convention
You have two options :
- Write Norbert Szabo ( the author ) and "suplicate" a g++ distribution ( if Qt Open is g++ based, it's a more logical option make a NCReport g++ based, I think )
- Generate yourself a g++ library ( ncreport2.a ). You've tro generate da def file from DLL, generate a .a file and link it against your program...
Here's a guide ( for a python library, but you only have to change library name and all may work ). Take a look at section 2
http://sebsauvage.net/python/mingw.html
It works ?
nope.. i did build "ncreport2.a" and link it to my project but i guess is for python..You have two options :
- Write Norbert Szabo ( the author ) and "suplicate" a g++ distribution ( if Qt Open is g++ based, it's a more logical option make a NCReport g++ based, I think )
- Generate yourself a g++ library ( ncreport2.a ). You've tro generate da def file from DLL, generate a .a file and link it against your program...
It works ?
i still got the same error.. maybe ill try your first option but i think it will took more time..![]()
Surely, You've made some error creating ncreport2.a file or haven't changed the .pro file properly.
What have you done exactly ? ( commands for creating the .a file & changes made to .pro file to point the correct library )
Surely, You've made some error creating ncreport2.a file or haven't changed the .pro file properly.
What have you done exactly ? ( commands for creating the .a file & changes made to .pro file to point the correct library )
Bookmarks