Results 1 to 19 of 19

Thread: NCreport2 help?

  1. #1
    Join Date
    Dec 2007
    Posts
    129
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Question NCreport2 help?

    here are my steps following the use guide:

    i include the includes of ncreport2 to INCLUDEPATH = ../include

    i add the ncreport2.lib as LIBS+= ..lib/ncreport2.lib

    i include them to my project as

    #include "../preview/ncreportpreviewwindow.h"
    etc..

    after these three procedure i have no errors but after i add this line to my project

    NCReport *report = new NCReport();

    i got "undefined reference to `NCReport::NCReport(QObject*)'"

    what ya think bout my error?
    Last edited by triperzonak; 14th June 2008 at 04:41.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: NCreport2 help?

    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

  3. #3
    Join Date
    Dec 2007
    Posts
    129
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: NCreport2 help?

    Quote Originally Posted by jpn View Post
    I'm afraid the content of LIBS variable is not correct. For a reason or another the lib is not getting linked.
    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

  4. #4
    Join Date
    Dec 2007
    Posts
    129
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: NCreport2 help?

    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"?

  5. #5
    Join Date
    Jul 2006
    Location
    Catalunya - Spain
    Posts
    117
    Thanks
    16
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: NCreport2 help?

    Add this line to your .pro file :

    DEFINES += NCREPORT_IMPORT

    And test. I think this may solve your problem...

  6. #6
    Join Date
    Dec 2007
    Posts
    129
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: NCreport2 help?

    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

    #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
    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?

    in the ifdef Q_WS_WIN do i need to specify that im using WIN OS or it is automatically detected?

    tnx

  7. #7
    Join Date
    Jul 2006
    Location
    Catalunya - Spain
    Posts
    117
    Thanks
    16
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: NCreport2 help?

    Quote Originally Posted by triperzonak View Post
    tnx for the reply.. quite close but still far..
    "undefined reference to `_imp___ZN8NCReportC1EP7QObject'"
    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 )

    LIBS += ncreport2.lib ? is this right?
    No, you have to put something like this :

    LIBS += -L"/path/to/ncreport2.lib" -lncreport2

    It must be enough. Test it...

    plus i also copied the dll to the same path where my project is? again.. is this right?
    At runtime, probably you will need it if the directory where resides the DLL is not in the PATH, as you're running windows.

    At compile/link time you only have to set correct paths on the LIBS section and everything must compile and link.

    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?
    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.

    in the ifdef Q_WS_WIN do i need to specify that im using WIN OS or it is automatically detected?

    tnx
    Q_WS_WIN is defined by QT, don't worry about it...

    I hope this will be useful for you.

  8. #8
    Join Date
    Dec 2007
    Posts
    129
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: NCreport2 help?

    i try your post but still got errors.. jpujolf

    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
    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
    i add this line to my project.pro

    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..

  9. #9
    Join Date
    Jul 2006
    Location
    Catalunya - Spain
    Posts
    117
    Thanks
    16
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: NCreport2 help?

    Quote Originally Posted by triperzonak View Post
    INCLUDEPATH += "C:/Program Files/NCReport2/include"

    #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"
    So no need for the complete path in includes, only :

    #include <ncreport.h>
    #include <ncreportoutput.h>
    #include <ncreportpreviewoutput.h>
    #include <ncreportpreviewwindow.h>

    DEFINES += NCREPORT_IMPORT
    That's right...

    LIBS += "C:/Program Files/NCReport2/lib/ncreport2.lib" or
    -L"C:/Program Files/NCReport2/lib" -lncreport2 or -L"C:/Program Files/NCReport2/lib"
    -lncreport2
    Put EXACTLY this :

    LIBS += -L"C:\Program Files\NCReport2\lib" -lncreport2

    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
    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...

    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.

  10. #10
    Join Date
    Dec 2007
    Posts
    129
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: NCreport2 help?

    heres my .pro
    Qt Code:
    1. TEMPLATE = app
    2. QT = gui core sql xml
    3. CONFIG += qt \
    4. release \
    5. warn_on \
    6. thread \
    7. no_lflags_merge \
    8. dll \
    9. console
    10. DESTDIR = bin
    11. OBJECTS_DIR = build
    12. MOC_DIR = build
    13. UI_DIR = build
    14. TARGET = mync
    15. FORMS = ui/dialog.ui
    16. HEADERS += src/dialogimpl.h
    17. SOURCES += src/dialogimpl.cpp src/main.cpp
    18. INCLUDEPATH += "C:/Program Files/NCReport2/include"
    19. DEFINES = NCREPORT_IMPORT
    20. LIBS += [B]-L "C:\Program Files\NCReport2\lib" -lncreport2[/B]
    To copy to clipboard, switch view to plain text mode 

    same error:
    g++ -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
    if you notice i put -L<space>"<dir>" i cant do this -L"<dir>" (without space) same error
    "-Lc:\Program Files\NCReport2\lib" -lncreport2
    tnx for your time..

  11. #11
    Join Date
    Jul 2006
    Location
    Catalunya - Spain
    Posts
    117
    Thanks
    16
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: NCreport2 help?

    Quote Originally Posted by triperzonak View Post
    LIBS += -L "C:\Program Files\NCReport2\lib" -lncreport2

    same error:

    if you notice i put -L<space>"<dir>" i cant do this -L"<dir>" (without space) same error
    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 ?

  12. #12
    Join Date
    Dec 2007
    Posts
    129
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: NCreport2 help?

    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 ?
    nope.. i did build "ncreport2.a" and link it to my project but i guess is for python..

    i still got the same error.. maybe ill try your first option but i think it will took more time..

  13. #13
    Join Date
    Jul 2006
    Location
    Catalunya - Spain
    Posts
    117
    Thanks
    16
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: NCreport2 help?

    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 )

  14. #14
    Join Date
    Jul 2006
    Location
    Catalunya - Spain
    Posts
    117
    Thanks
    16
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: NCreport2 help?

    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 )

  15. #15
    Join Date
    Dec 2007
    Posts
    129
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: NCreport2 help?

    Run : pexports ncreport2.dll > ncreport2.def
    then

    Run : dlltool --dllname ncreport2.dll --def ncreport2.def --output-lib ncreport2.a

    then it generate ncreport2.a i copyed it and paste bedside my .pro

    i add to LIBS+= ncreport2.a, (in ncreport1 it works but not in ncreport2..)

    same error after build..

  16. #16
    Join Date
    Jul 2006
    Location
    Catalunya - Spain
    Posts
    117
    Thanks
    16
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: NCreport2 help?

    Quote Originally Posted by triperzonak View Post
    Run : pexports ncreport2.dll > ncreport2.def
    OK
    then

    Run : dlltool --dllname ncreport2.dll --def ncreport2.def --output-lib ncreport2.a
    OK too...

    then it generate ncreport2.a i copyed it and paste bedside my .pro
    Unnecessary, so ncreport2.a is generated at the same directory as DLL resides. No need to do it

    i add to LIBS+= ncreport2.a, (in ncreport1 it works but not in ncreport2..)
    same error after build..
    Incorrect !!

    You have to put EXACTLY this in your LIBS entry at .pro file :

    LIBS += -L"<path-to-library>" -lncreport2

    As explained in mingw documentation, -L option is for adding a path to the library search, and -l option is for adding libraries, without extension.

    Where <path-to-library> is only the path, not the complete name, and -lncreport means "library name is ncreport.a"

    Do you understand now what I'm trying to explain ?

  17. #17
    Join Date
    Dec 2007
    Posts
    129
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: NCreport2 help?

    i follow this from documentation:
    unix:LIBS += -L/usr/local/lib -lmath
    win32:LIBS += c:/mylibs/math.lib
    im using windows so win32 is the right way to follow and it has note that says
    Note: On Windows, specifying libraries with the -l option, as in the above example, will cause the library with the highest version number to be used; for example, libmath2.lib could potentially be used instead of libmathlib. To avoid this ambiguity, we recommend that you explicitly specify the library to be used by including the .lib file name suffix.
    and last.. i already use it and works in ncreport1 it uses libncreport.a too but i successfully link it..

  18. #18
    Join Date
    Jul 2006
    Location
    Catalunya - Spain
    Posts
    117
    Thanks
    16
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: NCreport2 help?

    So, no more ideas from me

    It works for me as I explained to you...

    Perhaps you may ask Norbert Szabo to find an answer.

  19. #19
    Join Date
    Dec 2007
    Posts
    129
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: NCreport2 help?

    my problem is now solve..

    tnx nocisoft for releasing MinGW version of the reporting tool..

    http://www.nocisoft.com/?id=down


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.