Coder Social home page Coder Social logo

Comments (10)

egorpugin avatar egorpugin commented on July 19, 2024

I receive linker warnings and errors when trying to build Leptonica and Tesseract with Visual Studio 2017.

  1. How do you build them?
    Please provide commands.

  2. What are you trying to achieve in the end?
    Link lept and tess into your app?

I suspect bad build type somewhere.

from sw.

rweldin avatar rweldin commented on July 19, 2024

Egor, thanks for your quick response. Below are my answers to your questions, but I only posted the linker commands for Leptonica. Please let me know if you need anything else.

1.)
mkdir win64 && cd win64
cmake -G "Visual Studio 15 2017 Win64" -DBUILD_SHARED_LIBS=1 -DSW_BUILD_SHARED_LIBS=0 ..
Then I use Visual Studio 2017 to build a release version of the DLL. The linker command line is as follows:

/OUT:"E:\src\repo\leptonica\win64\bin\Release\leptonica-1.80.0.dll" /MANIFEST /NXCOMPAT /PDB:"E:/src/repo/leptonica/win64/bin/Release/leptonica-1.80.0.pdb" /DYNAMICBASE "C:.sw\storage\pkg\89\dc\64e7\obj\bld\135497\lib\org.sw.demo.gif-5.2.1.lib" "C:.sw\storage\pkg\a9\0c\280b\obj\bld\135497\lib\org.sw.demo.jpeg-9.4.0.lib" "C:.sw\storage\pkg\28\39\9564\obj\bld\135497\lib\org.sw.demo.glennrp.png-1.6.37.lib" "C:.sw\storage\pkg\f5\fe\083c\obj\bld\135497\lib\org.sw.demo.tiff-4.1.0.lib" "C:.sw\storage\pkg\79\7b\0892\obj\bld\135497\lib\org.sw.demo.webmproject.webp-1.0.3.lib" "C:.sw\storage\pkg\f7\91\f458\obj\bld\135497\lib\org.sw.demo.uclouvain.openjpeg.openjp2-2.3.1.lib" "C:.sw\storage\pkg\ce\99\b2f8\obj\bld\135497\lib\org.sw.demo.madler.zlib-1.2.11.lib" "C:.sw\storage\pkg\76\c7\435a\obj\bld\135497\lib\org.sw.demo.facebook.zstd.zstd-1.4.4.lib" "C:.sw\storage\pkg\25\78\4a4d\obj\bld\135497\lib\org.sw.demo.mgk25.jbig.jbig-2.1.0.lib" "C:.sw\storage\pkg\60\89\7ba0\obj\bld\135497\lib\org.sw.demo.mgk25.jbig.ar-2.1.0.lib" "kernel32.lib" "oldnames.lib" "concrtd.lib" "msvcprtd.lib" "vcruntimed.lib" "msvcrtd.lib" "ucrtd.lib" "C:.sw\storage\pkg\2a\68\57cb\obj\bld\135497\lib\org.sw.demo.xz_utils.lzma-5.2.4.lib" "user32.lib" "gdi32.lib" "winspool.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "comdlg32.lib" "advapi32.lib" /IMPLIB:"E:/src/repo/leptonica/win64/src/Release/leptonica-1.80.0.lib" /DLL /MACHINE:X64 /INCREMENTAL:NO /PGD:"E:\src\repo\leptonica\win64\bin\Release\leptonica-1.80.0.pgd" /SUBSYSTEM:CONSOLE /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"leptonica.dir\Release\leptonica-1.80.0.dll.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /TLBID:1

Additional Options:
%(AdditionalOptions) /machine:x64

I receive the following warning/error for both Leptonica & Tesseract:

LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library

2.) I use Leptonica and Tesseract for OCR in my application. I've been building the DLLs for a few years with CPPAN and now SW.

from sw.

egorpugin avatar egorpugin commented on July 19, 2024
  1. Try to update sw (sw --self-upgrade or manually), run sw setup.
    This will update cmake integration script in the system.
    Run your commands again.

  2. What is your build system? If it is cmake, then it is easy to integrate lept/tess there like in this example: https://github.com/SoftwareNetwork/sw/blob/master/test/integrations/cmake/tess/CMakeLists.txt

from sw.

egorpugin avatar egorpugin commented on July 19, 2024

Also I've tested your workflow with leptonica, everything works fine as expected. I assume you have old sw/sw cmake integration.
I've added cmake integration version check, so it will notice users automatically in the future.
dae1dfe#diff-6f4bb1c6a0597a0398b5992992cbed92R157

from sw.

rweldin avatar rweldin commented on July 19, 2024

I wiped my SW folders, downloaded the current SW, did sw setup, downloaded the Leptonica source again, recompiled with Visual Studio and got the same LNK4098 link warning.

I also tried the following:
cmake -DBUILD_SHARED_LIBS=1 -DSW_BUILD_SHARED_LIBS=0 ..
cmake --build .

The build outputs a debug DLL when I'm expecting a release version. I also tried adding -DCMAKE_BUILD_TYPE=Release, but still get a debug DLL when building with cmake; below is the output.

Creating library R:/leptonica-master/win64/src/Debug/leptonica-1.80.0d.lib and object R:/leptonica-master/win64/src/Debug/leptonica-1.80.0d.exp
leptonica.vcxproj -> R:\leptonica-master\win64\bin\Debug\leptonica-1.80.0d.dll
Building Custom Rule R:/leptonica-master/CMakeLists.txt

In researching the LNK4098 issue I saw trying to link release and debug libs can cause this issue. If you have any other suggestions please let me know. Thank you!

from sw.

egorpugin avatar egorpugin commented on July 19, 2024

cmake --build . --config Release to build release binaries.

from sw.

egorpugin avatar egorpugin commented on July 19, 2024

Run cmake -DBUILD_SHARED_LIBS=1 -DSW_BUILD_SHARED_LIBS=0 .. -DSW_DEBUG=1, it will show sw command.
Run that command manually with -trace argument. Post results.

from sw.

rweldin avatar rweldin commented on July 19, 2024

Below is a text document with the output. Thank you!

trace.txt

from sw.

rweldin avatar rweldin commented on July 19, 2024

Of note I tried to compile Tesseract with cmake using the --config Release flag and the failure is noted below. tesseract.txt shows the full verbose output. Hope this is helpful to you.

R:\tesseract-master\Win64>cmake -DBUILD_SHARED_LIBS=1 -DSW_BUILD_SHARED_LIBS=0 ..
R:\tesseract-master\Win64>cmake --build . --config Release

Auto build dll exports
msvcprtd.lib(locale0_implib.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in adaptions.obj [R:\tesseract-master\Win64\libtesseract.vcxproj]
Creating library R:/tesseract-master/Win64/Release/tesseract50.lib and object R:/tesseract-master/Win64/Release/tesseract50.exp
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library [R:\tesseract-master\Win64\libtesseract.vcxproj]
R:\tesseract-master\Win64\bin\Release\tesseract50.dll : fatal error LNK1319: 1 mismatches detected [R:\tesseract-master\Win64\libtesseract.vcxproj]
tessopt.vcxproj -> R:\tesseract-master\Win64\bin\Release\tessopt.dll

from sw.

egorpugin avatar egorpugin commented on July 19, 2024

Ok, confirmed, reproduced and fixed. Thank you.
sw --self-upgrade and try again.

from sw.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.