Using leptonica with qt 5.2.0 (vs2012) issues

480 Views Asked by At

I'm trying to get the Leptonica 1.68 to work with Qt 5.2.0 (vs2012) static libraries. So i decided to try out the static libraries first, i downloaded the following package leptonica-1.68-win32-lib-include-dirs.zip

And iclude it in my project like so:

LIBS += -L$$PWD\leptonica-1.68-win32-lib-include-dirs\lib -lliblept168-static-mtdll -lgiflib416-static-mtdll

I also use the opencv that i build myself using vc2012+cmake

LIBS += -L$$PWD\opencv\static_libs -llibjpegd -llibpngd -llibtiffd -lIlmImfd -llibjasperd -lopencv_calib3d246d -lopencv_contrib246d -lopencv_core246d -lopencv_features2d246d -lopencv_flann246d -lopencv_gpu246d -lopencv_highgui246d -lopencv_imgproc246d -lopencv_legacy246d -lopencv_ml246d -lopencv_nonfree246d -lopencv_objdetect246d -lopencv_photo246d -lopencv_stitching246d -lopencv_superres246d -lopencv_ts246d  -lzlibd

Opencv is built with /MTd and leptonica is built with /MTd too (i assume it from the library name "static-mtdll")

My qt is built with the following configuration:

configure -static -debug-and-release -opensource -confirm-license -platform win
32-msvc2012 -mp -qt-sql-sqlite -plugin-sql-mysql -I C:\MYSQL\include -L C:\QT\lib  -c++11 -no-opengl
-nomake tests -nomake examples  -no-crt -qt-zlib -qt-libpng -qt-libjpeg

When i'm trying to build my application i get

Qt5Cored.lib(zutil.obj) : error LNK2005: _z_errmsg already defined in zlibd.lib(zutil.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _malloc already defined in LIBCMTD.lib(dbgmalloc.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _free already defined in LIBCMTD.lib(dbgfree.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _calloc already defined in LIBCMTD.lib(dbgcalloc.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _fprintf already defined in LIBCMTD.lib(fprintf.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: ___iob_func already defined in LIBCMTD.lib(_file.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _rand already defined in LIBCMTD.lib(rand.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: __localtime64 already defined in LIBCMTD.lib(loctim64.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _sprintf already defined in LIBCMTD.lib(sprintf.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _strchr already defined in LIBCMTD.lib(strchr.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _strstr already defined in LIBCMTD.lib(strstr.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _fseek already defined in LIBCMTD.lib(fseek.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _ftell already defined in LIBCMTD.lib(ftell.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _fclose already defined in LIBCMTD.lib(fclose.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _srand already defined in LIBCMTD.lib(rand.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: __snprintf_s already defined in LIBCMTD.lib(sprintf.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _fread already defined in LIBCMTD.lib(fread.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _strrchr already defined in LIBCMTD.lib(strrchr.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _strncmp already defined in LIBCMTD.lib(strncmp.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _sscanf already defined in LIBCMTD.lib(sscanf.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _strftime already defined in LIBCMTD.lib(strftime.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _fopen already defined in LIBCMTD.lib(fopen.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _fwrite already defined in LIBCMTD.lib(fwrite.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _rewind already defined in LIBCMTD.lib(rewind.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _remove already defined in LIBCMTD.lib(unlink.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: __lseek already defined in LIBCMTD.lib(lseek.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _fputc already defined in LIBCMTD.lib(fputc.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _fgetc already defined in LIBCMTD.lib(fgetc.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _longjmp already defined in LIBCMTD.lib(longjmp.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _atof already defined in LIBCMTD.lib(atof.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _fgets already defined in LIBCMTD.lib(fgets.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _memmove already defined in LIBCMTD.lib(memmove.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _setvbuf already defined in LIBCMTD.lib(setvbuf.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _strncpy already defined in LIBCMTD.lib(strncpy.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _realloc already defined in LIBCMTD.lib(dbgrealloc.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: __isnan already defined in LIBCMTD.lib(ieeemisc.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: __fpclass already defined in LIBCMTD.lib(ieeemisc.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _toupper already defined in LIBCMTD.lib(toupper.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: __vsnprintf already defined in LIBCMTD.lib(vsnprint.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _vfprintf already defined in LIBCMTD.lib(vfprintf.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _getenv already defined in LIBCMTD.lib(getenv.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: __errno already defined in LIBCMTD.lib(dosmap.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: __wopen already defined in LIBCMTD.lib(wopen.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _fflush already defined in LIBCMTD.lib(fflush.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _floor already defined in LIBCMTD.lib(floor_pentium4.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _printf already defined in LIBCMTD.lib(printf.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: _strtol already defined in LIBCMTD.lib(strtol.obj)
MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)
MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: __getpid already defined in LIBCMTD.lib(getpid.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: __fileno already defined in LIBCMTD.lib(fileno.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: __setmode already defined in LIBCMTD.lib(setmode.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: __close already defined in LIBCMTD.lib(close.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: __open already defined in LIBCMTD.lib(open.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: __read already defined in LIBCMTD.lib(read.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: __write already defined in LIBCMTD.lib(write.obj)
MSVCRT.lib(MSVCR110.dll) : error LNK2005: __getcwd already defined in LIBCMTD.lib(getcwd.obj)
LIBCMTD.lib(wfopen.obj) : error LNK2005: __wfopen already defined in MSVCRT.lib(MSVCR110.dll)
   Creating library debug\test.lib and object debug\test.exp
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
fatal error LNK1169: one or more multiply defined symbols found

I tried to add /NODEFAULTLIBRARY:MSVCRT.LIB to my pro file but LIBCMTD errors still remain, and i get more warnings like this:

libxml2_a.lib(xmlmemory.obj) : warning LNK4217: locally defined symbol _malloc imported in function _xmlMallocBreakpoint
giflib416-static-mtdll.lib(gifalloc.obj) : warning LNK4049: locally defined symbol _malloc imported
giflib416-static-mtdll.lib(dgif_lib.obj) : warning LNK4217: locally defined symbol _malloc imported in function _DGifCloseFile
libxml2_a.lib(globals.obj) : warning LNK4049: locally defined symbol _malloc imported
libxml2_a.lib(threads.obj) : warning LNK4049: locally defined symbol _malloc imported
liblept168-static-mtdll.lib(pix1.obj) : warning LNK4217: locally defined symbol _malloc imported in function _pix_malloc
liblept168-static-mtdll.lib(jpegio.obj) : warning LNK4049: locally defined symbol _malloc imported
liblept168-static-mtdll.lib(fpix1.obj) : warning LNK4049: locally defined symbol _malloc imported

If i build that project dynamically using non-static qt version and opencv non-static libraries everything works just fine. (i guess that would be /MD). So i assume that leptonica is compiled with /MD and i need to recomplie it with /MTd (static debug). Please help, or maybe provide a faq or solution for building leptonica using vc2012.

0

There are 0 best solutions below