Run the application with Debug error with static library
-
Hi,
I use Qt5.15 C++, for Tessaract application, I use static library, my .pro file :
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/mingw-w64-x86_64-static-tesseract-master/lib/ -ltesseract else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/mingw-w64-x86_64-static-tesseract-master/lib/ -ltesseractd INCLUDEPATH += $$PWD/mingw-w64-x86_64-static-tesseract-master DEPENDPATH += $$PWD/mingw-w64-x86_64-static-tesseract-master win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/mingw-w64-x86_64-static-tesseract-master/lib/libtesseract.a else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/mingw-w64-x86_64-static-tesseract-master/lib/libtesseractd.a else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/mingw-w64-x86_64-static-tesseract-master/lib/tesseract.lib else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/mingw-w64-x86_64-static-tesseract-master/lib/tesseractd.lib win32:CONFIG(release, debug|release): LIBS += -L$$PWD/mingw-w64-x86_64-static-tesseract-master/lib/ -llept else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/mingw-w64-x86_64-static-tesseract-master/lib/ -lleptd INCLUDEPATH += $$PWD/mingw-w64-x86_64-static-tesseract-master DEPENDPATH += $$PWD/mingw-w64-x86_64-static-tesseract-master
but when running the program I get Debug error message, although I have run in Debug mode, can someone help me?
Thanks !
-
@DQUY05 said in Run the application with Debug error with static library:
-L$$PWD/mingw-w64-x86_64-static-tesseract-master/lib/ -ltesseract
If you want a static build then also all dependencies have to be static. Currently you're linking a shared version of the tesseract lib. Build it as static.
-
@jsulm said in Run the application with Debug error with static library:
@DQUY05 said in Run the application with Debug error with static library:
-L$$PWD/mingw-w64-x86_64-static-tesseract-master/lib/ -ltesseract
If you want a static build then also all dependencies have to be static. Currently you're linking a shared version of the tesseract lib. Build it as static.
Thank Sir !
When I switch to this option,
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/mingw-w64-x86_64-static-tesseract-master/lib/ -ltesseract else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/mingw-w64-x86_64-static-tesseract-master/lib/ -ltesseractd INCLUDEPATH += $$PWD/mingw-w64-x86_64-static-tesseract-master DEPENDPATH += $$PWD/mingw-w64-x86_64-static-tesseract-master win32:CONFIG(release, debug|release): LIBS += -L$$PWD/mingw-w64-x86_64-static-tesseract-master/lib/ -llept else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/mingw-w64-x86_64-static-tesseract-master/lib/ -lleptd INCLUDEPATH += $$PWD/mingw-w64-x86_64-static-tesseract-master DEPENDPATH += $$PWD/mingw-w64-x86_64-static-tesseract-master
Then I got an error, I tried to find out but there is very little documentation about tesseract static library, can you help me see where the error is? Thanks!
I used the static library at this path https://github.com/bradosia/mingw-w64-x86_64-static-tesseract -
@DQUY05 said in Run the application with Debug error with static library:
I used the static library at this path https://github.com/bradosia/mingw-w64-x86_64-static-tesseract
OK, forget my previous post.
The problem is that this static build does not contain debug versions of the libs (like libtesseractd.a).
Try to change:-ltesseractd
to
-ltesseract
And same for the other libs.
-
@jsulm said in Run the application with Debug error with static library:
Được rồi, quên bài đăng trước của tôi đi.
Vấn đề là bản dựng tĩnh này không chứa phiên bản gỡ lỗi của libs (như libtesseractd.a).
Hãy thử thay đổi:Dear Sir !
I tried as you said, but it seems the problem is that the other path is missing the file?I am a newbie, not proficient in installing libraries, I hope you can guide me, this project is very interesting to me, Thanks!
-
@DQUY05 After changing the pro file do a complete rebuild:
- Delete build folder
- Run qmake
- build
If you still get "undefined reference" errors it means that a library was not found. Look for the very first error message or warning. You can also post the build log so we can check what library was not found.
The problem could be that Tesseract is written in C++ and you cannot mix debug and release binaries. In this case you will have to build Tesseract statically for debug and release by yourself.
-
@jsulm said in Run the application with Debug error with static library:
Delete build folder
Run qmake
buildI followed this sequence, but the error still appears,
My account can't attach Log file, I'm still used to using static library and environment variable type library like OpenCv, besides I don't know other approachINCLUDEPATH += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/include LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_core452.dll LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_highgui452.dll LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_imgproc452.dll LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_videoio452.dll LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_imgcodecs452.dll LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_features2d452.dll LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_video452.dll LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_objdetect452.dll
-
@DQUY05 said in Run the application with Debug error with static library:
LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_core452.dll
LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_highgui452.dll
LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_imgproc452.dll
LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_videoio452.dll
LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_imgcodecs452.dll
LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_features2d452.dll
LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_video452.dll
LIBS += C:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin/libopencv_objdetect452.dllThis is all wrong. If you want static build why do you link DLLs?
And on Windows you do not link DLLs, you link *.lib files (like libopencv_objdetect452.lib). It should be like:LIBS += -LC:/OpenCV-MinGW-Build-OpenCV-4.5.2-x64/x64/mingw/bin -lopencv_core452
-
Hi,
Now I run without any errors, until calling this functiontesseract::TessBaseAPI *api = new tesseract::TessBaseAPI();
Then the error appeared.
error: undefined reference to `tesseract::TessBaseAPI::TessBaseAPI()'
Is there something wrong with the static library add operation, I'm really confused,
-
@DQUY05 said in Run the application with Debug error with static library:
Is there something wrong with the static library add operation
You're not linking the library which contains tesseract::TessBaseAPI.
Check the build log for warnings about incompatible library.