QT Error with Twain Data Source



  • Hi , I have been using Sample Twain Data Source from Twain .org. QT is a prerequisite for this application which is in C++. I am getting below errors when i try to compile Twain data source.

    Any help with these error is appreciated

    Error 4 fatal error C1083: Cannot open source file: '..\src\GeneratedFiles\Win32\Debug\moc_Qt_About.cpp': No such file or directory c1xx

    Error 5 fatal error C1083: Cannot open source file: '..\src\GeneratedFiles\Win32\Debug\moc_Qt_MainForm.cpp': No such file or directory c1xx

    Error 6 fatal error C1083: Cannot open source file: '..\src\GeneratedFiles\Win32\Debug\moc_Qt_ProfileName.cpp': No such file or directory c1xx

    Error 7 fatal error C1083: Cannot open source file: '..\src\GeneratedFiles\qrc_qtresources.cpp': No such file or directory c1xx
    Error 8 error BK1506 : cannot open file '.\Debug32\Qt_About.sbr': No such file or directory BSCMAKE

    Error 1 fatal error C1083: Cannot open include file: 'ui_About.h': No such file or directory c:\odiimages\source\twain\twain-samples\twain_ds_sample01\src\qt_about.cpp 2

    Error 2 fatal error C1083: Cannot open include file: 'ui_MainForm.h': No such file or directory c:\odiimages\source\twain\twain-samples\twain_ds_sample01\src\qt_mainform.cpp 2

    Error 3 fatal error C1083: Cannot open include file: 'ui_ProfileName.h': No such file or directory c:\odiimages\source\twain\twain-samples\twain_ds_sample01\src\qt_profilename.cpp 2

    The Twain Data source project is availabel at https://sourceforge.net/projects/twain-samples/files/TWAIN 2 Sample Data Source/TWAIN DS 2.1.3/


  • Qt Champions 2017

    Hi and welcome
    What do you compile it with ?
    Seems not be setup running the moc tool an ui tool.
    http://doc.qt.io/archives/qt-4.8/moc.html
    Are you using Qt Creator?

    Its very old. QT 4.5.3. For newer Qt you will have to port some of the classes.



  • @mrjj said in QT Error with Twain Data Source:

    What do you compile it with ?

    I m compiling it with Visual Studio 2008 and not using QT Creator. Can you please guide me where i can get moc tool and ui tool?


  • Qt Champions 2017

    @bhim

    Hi
    They are included but visual studio knows nothing about it.
    Often a plugin for VS is used to help make this happen.
    Not sure there is plugin for 2008.
    2013 seems to be the oldest
    https://download.qt.io/official_releases/vsaddin/
    but it seems to have existed
    https://forum.qt.io/topic/5722/solved-how-generate-moc-files-automatically-using-visual-studio-2008

    so maybe i just need more coffee ;)

    also this seems the newest Qt that works with vs2008
    https://download.qt.io/official_releases/qt/4.8/4.8.7/



  • Thanks for your help. I have download and use said version of QT. However it dont let me configure this project. Its complaining abut the Kit not found. Also when i go to configure default Kit, QT version is ot populating. Can you please llo at attached and help me?

    0_1513798961034_3ac45dc0-c19e-4f4d-a96c-836908e9c8ea-image.png

    0_1513799034167_4322bffb-2a7b-4896-a12b-8813ead562b6-image.png
    Thanks
    Bhim


  • Qt Champions 2017

    Hi
    you installed
    qt-opensource-windows-x86-vs2008-4.8.7.exe ?
    and you had vs 2008 already installed?

    what does it list in Qt versions tab?



  • Yes, i installed and used qt-opensource-windows-x86-vs2008-4.8.7.exe

    It list only None in QT Version tab.

    I had vs 2008 also already installed.

    Please help.


  • Qt Champions 2017

    @bhim
    Hi
    It should have picked it up.
    Not sure what went wrong.
    Sadly i dont have any vs 2008 to test with and not sure why no Qt is listed.

    Give some time. Maybe someone is still using vs2008 :)



  • Also this is what i have installed, can this be the culprit?

    0_1513799635064_17aeedfa-7447-44a1-b2d3-2051839c272c-image.png

    Meantime i will also try on a machine where vs2008 is not installed.


  • Qt Champions 2017

    @bhim
    Did you also install a QT binary ?
    That is only the editor
    named something like Qt 2008 visual studio 2008

    can you show image of all that can be selected?



  • I am not sure if i installed QT binary. Can you please provide me download path? Also the QT Version drop down is only show None.



  • Hi ,

    Thanks for your help. I m able to open and configure the project now. But getting below error when i build it. Can you please have a look and help.

    0_1513803176191_8ae67440-c489-4b3f-b3b6-6fdbf8954d33-image.png


  • Qt Champions 2017

    @bhim
    seem to be kinda old/invalid .pro file
    can you show what is inside?



  • Below is the content of pro file

    unix {
    TEMPLATE = subdirs
    VERSION = 1.0
    DEFINES += UNIX
    }

    SUBDIRS = src

    I have also shared entire project at below location for you.

    https://drive.google.com/drive/folders/1gj69Kh7Xy8-p91uE3QUao673wqxoHidx?usp=sharing


  • Qt Champions 2017

    @bhim
    its wrong project file
    there is
    src.pro
    in src

    that seems better



  • Thanks It much better now. Though i am still getting lot of errors but these are datatype error and seems like code specific.

    Thanks a lot for your help.

    Bhim


  • Qt Champions 2017

    @bhim
    Np.
    I noticed there are some FreeImage lib files.
    Not sure it uses it but make sure they are compatible with vs 2008 if it does.

    Its pretty old project. there are no newer twain samples?



  • This is the latest sample they have. With this i m getting below error , would you be able to help with this one as well?

    I know how to take care of these in VS but not in QT.

    0_1513807832766_fe2a45f3-5e33-45ca-984a-82710a9c14af-image.png


  • Qt Champions 2017

    @bhim
    Well Qt is just a normal c++ LIB
    and those are normal windows API calls so fix them like you normal would.
    seems to be unicode related.
    Didnt it later become common to put _TCHAR or something in front ?
    or use wchar_t* and not char * ?
    maybe you can just use the A version of the API and not W version


  • Qt Champions 2017

    Hi
    I wondered if
    https://github.com/twain/twain-samples
    is something else than the twain you try ?



  • I tried the exact same exact same Twain.


  • Qt Champions 2017

    @bhim
    Ok but it didnt work or was not what you wanted?



  • It did not work. However i am able to resolve most of the error for data type conversion. I am now stuck at below, i am not able to go to definition\declaration of this method to make any change. I know how to do it in Visual Studio but not in QT. Can you please help

    0_1513870545958_2d8762fa-efe9-42b6-9bcb-a13c435fa223-image.png



  • Hi,

    I have resolved all string related error. Now my project is showing this :-1: error: LNK1104: cannot open file 'freeimage.lib' . If i could find the Visual Studio equivalent or Project property in QT, that would be very helpful to very file the linker paths.


  • Qt Champions 2017

    @bhim
    you mean to link the LIB file to the project ?
    http://doc.qt.io/qt-5/third-party-libraries.html
    http://doc.qt.io/qtcreator/creator-project-qmake-libraries.html

    Basically you need a
    LIBS += -L"3rdparty/CatWhisperer/lib" -lCatWhisperer
    (with correct names of course)



  • Thanks , this resolve the lib issue. Now below 2 error

    14:31:45: Running steps for project src...
    14:31:45: Configuration unchanged, skipping qmake step.
    14:31:45: Starting: "C:\Qt\qtcreator-4.5.0\bin\jom.exe"
    c:\Qt\4.8.7\bin\qmake.exe -spec c:\Qt\4.8.7\mkspecs\win32-msvc2008 CONFIG+=release -o Makefile ..\src\src.pro
    C:\Qt\qtcreator-4.5.0\bin\jom.exe -f Makefile.Debug
    link /LIBPATH:"c:\Qt\4.8.7\lib" /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /DLL /MANIFEST /MANIFESTFILE:"debug\TWAINDS_FreeImage.intermediate.manifest" /OUT:debug\TWAINDS_FreeImage.dll @C:\Users\rathorb\AppData\Local\Temp\TWAINDS_FreeImage.dll.13524.62.jom
    TWAIN_UI.obj : error LNK2019: unresolved external symbol __imp__SHGetSpecialFolderPathA@16 referenced in function "public: __thiscall CTWAIN_UI::CTWAIN_UI(class CTWAINDS_FreeImage *)" (??0CTWAIN_UI@@QAE@PAVCTWAINDS_FreeImage@@@Z)
    debug\TWAINDS_FreeImage.dll : fatal error LNK1120: 1 unresolved externals
    jom: C:\ODIImages\Source\Twain\twain-samples-master\twain-samples-master\TWAIN-Samples\Twain_DS_sample01\build-src-Unnamed-Release\Makefile.Debug [debug\TWAINDS_FreeImage.dll] Error 1120
    jom: C:\ODIImages\Source\Twain\twain-samples-master\twain-samples-master\TWAIN-Samples\Twain_DS_sample01\build-src-Unnamed-Release\Makefile [debug] Error 2
    14:31:51: The process "C:\Qt\qtcreator-4.5.0\bin\jom.exe" exited with code 2.
    Error while building/deploying project src (kit: Unnamed)
    The kit Unnamed has configuration issues which might be the root cause for this problem.
    When executing step "Make"
    14:31:51: Elapsed time: 00:06.

    debug\TWAINDS_FreeImage.dll:-1: error: LNK1120: 1 unresolved externals


  • Qt Champions 2017



  • Thanks. I m able to build and run it now. But not able to find the output file, a .ds file anywhere? Can you please help me find where project is generating this file.

    Below is pro file code

    unix {
    TEMPLATE = lib
    VERSION = 1.0
    DEFINES += UNIX
    }
    PROJECT_FILE_NAME = TWAINDS_FreeImage
    TARGET = $$PROJECT_FILE_NAME
    LIBS += -lfreeimage

    TWAIN datasources end with a .ds instead of .so

    QMAKE_POST_LINK = cp
    $(TARGET)
    $${PROJECT_FILE_NAME}.ds
    ds.path = /usr/local/lib/twain/FreeImage
    ds.files = $${PROJECT_FILE_NAME}.ds
    TWAIN_logo.png
    INSTALLS += ds
    QMAKE_CLEAN = $${PROJECT_FILE_NAME}.ds
    INCLUDEPATH = /usr/local/include
    ../../pub/external/include
    ../../pub/include
    ../../visual_studio/Debug32
    ../../common
    LIBS += -L"../../pub/external/lib" -lFreeImage
    SOURCES += ../../common/CTiffWriter.cpp
    ../../common/CommonTWAIN.cpp
    CommonDS.cpp
    CScanner_FreeImage.cpp
    CTWAINDS_Base.cpp
    CTWAINDS_FreeImage.cpp
    DSMInterface.cpp
    TWAINContainer.cpp
    TWAINContainerFix32.cpp
    TWAINContainerFrame.cpp
    TWAINContainerInt.cpp
    CTWAINDS_Sample1.cpp
    TWAIN_UI.cpp
    TWAINContainerString.cpp
    TWAINContainerFix32Range.cpp
    TWAINContainerBool.cpp
    QT_UI.cpp
    Qt_MainForm.cpp
    Qt_About.cpp
    Qt_ProfileName.cpp
    HEADERS += ../../common/Common.h
    ../../common/CommonTWAIN.h
    ../../common/CTiffWriter.h
    CScanner_FreeImage.h
    CTWAINDS_Base.h
    CTWAINDS_FreeImage.h
    CommonDS.h
    DSMInterface.h
    TWAINContainerFix32.h
    TWAINContainerFrame.h
    TWAINContainer.h
    TWAINContainerInt.h
    CTWAINDS_Sample1.h
    TWAIN_UI.h
    TWAINContainerString.h
    TWAINContainerFix32Range.h
    TWAINContainerBool.h
    QT_UI.h
    Qt_MainForm.h
    Qt_About.h
    Qt_ProfileName.h
    ui_About.h
    ui_MainForm.h
    ui_About.h
    TEMPLATE = lib
    CONFIG += warn_on
    debug
    x86 ppc

    QMAKE_BUNDLE_EXTENSION = ds

    this project doesn't need any QT libs.

    QMAKE_LIBS_QT =
    QMAKE_LIBS_QT_THREAD =
    FORMS += MainForm.ui
    About.ui
    ProfileName.ui
    RESOURCES += qtresources.qrc

    unix|win32: LIBS += -lshell32


  • Qt Champions 2017

    @bhim
    Its not in build folder?



  • Its there, but its in dll extension, its supposed to be .ds extension.


  • Qt Champions 2017

    @bhim
    What is a .ds file ?



  • ds is Twain data source, OR Twain Driver. See below from my pro file, based on this it should have generated

    TWAIN datasources end with a .ds instead of .so

    QMAKE_POST_LINK = cp
    $(TARGET)
    $${PROJECT_FILE_NAME}.ds
    ds.path = /usr/local/lib/twain/FreeImage
    ds.files = $${PROJECT_FILE_NAME}.ds
    TWAIN_logo.png
    INSTALLS += ds
    QMAKE_CLEAN = $${PROJECT_FILE_NAME}.ds


  • Qt Champions 2017

    @bhim
    Ok but a SO file is a DLL.
    so being on windows, i wonder if the DS is just a DLL.

    Is that to load into the sample project ?



  • I change the DLL extension to ds and replaced with original DS file. It dd not work, it was not even detected. I think if somehow i could emit a .ds file , it will work. Below is the project property of visual studio project which generated original ds file

    0_1513895238850_1e6725b3-35b3-43c1-8cc2-32666e9a61cf-image.png


  • Qt Champions 2017

    Sorry i have no idea what / how a ds file should be produced.
    Site says
    copy TWAINDS_Sample[32|64].ds to /Windows/twain_[32|64]/sample2
    so it looks like a DLL. but sadly i cant find out more.



  • Coding wise everything looks fine, I am trying to debug ds file using a sample connection application. But connection application itself is giving below error. Can you please help.

    0_1513898201339_529f0520-4c9a-47d1-9056-e064c3587660-image.png


  • Qt Champions 2017

    HI
    The UNUSED ARG ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.