Coder Social home page Coder Social logo

Comments (13)

rsnitsch avatar rsnitsch commented on July 2, 2024

I am integrating tesseract into my project and get a build error, too:

(...)
[131/140] [org.sw.demo.boost.filesystem-1.81.0].lib
Exception in file D:/dev/cppan2/client2/src/sw/builder/command.cpp:840, function execute1: When executing: [pub.egorpugin.primitives.command-0.3.1]/src/command.cpp
C:/Users/Robert/.sw/storage/pkg/9d/a6/8d0d/src/sdir/src/command/src/command.cpp(142): error C2039: "contains" ist kein Member von "std::basic_string<char,std::char_traits<char>,std::allocator<char>>".
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xstring(4905): note: Siehe Deklaration von "std::basic_string<char,std::char_traits<char>,std::allocator<char>>"
C:/Users/Robert/.sw/storage/pkg/9d/a6/8d0d/src/sdir/src/command/src/command.cpp(147): note: Siehe Verweis auf die gerade kompilierte Instanziierung "auto primitives::Command::setProgram::<lambda_1>::()::<lambda_1>::operator ()<const char(&)[6]>(_T1) const" der Funktions-Vorlage.
        with
        [
            _T1=const char (&)[6]
        ]

Relevant part of my CMakeLists.txt:

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Add Tesseract via SW
# Source: https://github.com/SoftwareNetwork/sw/tree/master/test/integrations/cmake/tess
set(SW_BUILD_SHARED_LIBS 1)
set(DEPENDENCIES
    org.sw.demo.google.tesseract.libtesseract-master
)
find_package(SW REQUIRED)
sw_add_package(${DEPENDENCIES})
sw_execute()

from sw.

FlyinTeller avatar FlyinTeller commented on July 2, 2024

I resorted to building tesseract from source with -DSW_BUILD=False and manual installing of neccessary dependencies

from sw.

egorpugin avatar egorpugin commented on July 2, 2024

Use the latest VS2022.
I might need to update sw binary first to make it work.

from sw.

livezingy avatar livezingy commented on July 2, 2024

I get the same error when I compile the tesseract5.3.1 on VS1019&win11 with sw.
Then I compile the tesseract5.3.1 X64 successfully with vcpkg, cmake and command prompt on win11 refer to workflows/vcpkg.yml

  • Install cmake and vcpkg, Let's suppose the path of vcpkg is: D:/vcpkg. Add vcpkg and cmake path to environment variable Path.

  • Build and Install Leptonica and image libraries using vcpkg. The Leptonica and image libraries will be installed in D:/vcpkg/installed/x64-windows.
    vcpkg install leptonica:x64-windows

  • Build and Install PkgConfig. the workflow doesn't contain this step. it will report errors when we compile tesseract if we don't have PkgConfig.
    vcpkg install pkgconf:x64-windows

  • Install libarchive. the workflow doesn't contain this step. it will report errors when we compile tesseract if we don't have archive. The latest version of vcpkg untill 2023/6/26 could not intall archive because of some bug. we could download the compiled x64 [libarchive]. Then unzip it and copy the .h/.dll/.lib files to the corresponding folders in D:/vcpkg/installed/x64-windows.

  • Get the source code of tesseract5.3.1. Unzip it and come to its path in command prompt, then run the following command.
    -DSW_BUILD=OFF --->close SW
    -DBUILD_SHARED_LIBS=ON --->generate dll.

cmake . -B build -DCMAKE_BUILD_TYPE=Release -DSW_BUILD=OFF -DOPENMP_BUILD=OFF -DBUILD_SHARED_LIBS=ON -DBUILD_TRAINING_TOOLS=OFF "-DCMAKE_TOOLCHAIN_FILE=D:/vcpkg/scripts/buildsystems/vcpkg.cmake"
cmake --build build --config Release --target install

from sw.

rsnitsch avatar rsnitsch commented on July 2, 2024

Use the latest VS2022. I might need to update sw binary first to make it work.

Unfortunately, I cannot easily switch to VS 2022, because that breaks compatibility with another library that I use (OpenCV). When I try to use VS 2022 then CMake reports:
Found OpenCV Windows Pack but it has no binaries compatible with your configuration. You should manually point CMake variable OpenCV_DIR to your build of OpenCV library.

I could compile OpenCV myself with VS 2022 as well, but currently I don't have the time for that.

For now I have resorted to using the tesseract binaries by Uni Mannheim and calling tesseract.exe as a subprocess (saving image file and providing the path to that).

from sw.

egorpugin avatar egorpugin commented on July 2, 2024

I mean, that you need to install VS2022 for sw.
For your purposes you are free to use any version you need.

from sw.

rsnitsch avatar rsnitsch commented on July 2, 2024

I get a new error now:

ninja: error: 'C:/Users/Robert/.sw/storage/pkg/b1/62/8e34/obj/bld/485381/lib/org.sw.demo.google.tesseract.libtesseract-5.3.1.lib', needed by 'CMakeFiles/MYPROJECT_autogen_timestamp_deps', missing and no known rule to make it

My CMakeLists.txt:

# Add Tesseract via SW
# Source: https://github.com/SoftwareNetwork/sw/tree/master/test/integrations/cmake/tess
set(SW_BUILD_SHARED_LIBS 1)
set(SW_DEPENDENCIES
    org.sw.demo.google.tesseract.libtesseract-5.3.1
)
find_package(SW REQUIRED)
sw_add_package(${SW_DEPENDENCIES})
sw_execute()

# ...

target_link_libraries(MYPROJECT PRIVATE
    # other deps...
    ${SW_DEPENDENCIES}
)

I tried to remove the line with SW_BUILD_SHARED_LIBS but it doesn't change anything.

sw version:

λ sw --version
sw.client.sw version 1.0.0
git revision 30611200c2168a3ca7f9d888c11ba375b4667d07
assembled on
13.06.2023 21:33:07 UTC
13.06.2023 23:33:07 Mitteleurop�ische Sommerzeit

Visual Studio 2019 and 2022 are installed and up-to-date. I also have the Visual Studio 2017 build tools installed and updated.

from sw.

egorpugin avatar egorpugin commented on July 2, 2024

Hi,

I'm not sure that Ninja generator works with sw.
I tried your example and see

d:\dev\cppan2\client2\test\integrations\cmake\tess\ninja>cmake --build .
ninja: error: 'D:/dev/swst/pkg/b0/7f/f40a/obj/bld/108430/lib/org.sw.demo.google.tesseract.libtesseract-5.3.2.lib', needed by 'tess_example.exe', missing and no known rule to make it

Try to build using VS generator.

from sw.

egorpugin avatar egorpugin commented on July 2, 2024

I've made a fix for Ninja.
7d2916a#diff-680a0d8c76eec8315c509b457b47195fd59aa97dcf5c70cad13e2e080d4f0074R331

Try to add following lines (without version change in the top) into C:\users\u\.sw\storage\static\SWConfig.cmake

from sw.

rsnitsch avatar rsnitsch commented on July 2, 2024

Sorry @egorpugin I am now using vcpkg to integrate tesseract.

My CMakeLists.txt now looks like this:

# Make vcpkg install all binaries (DLLs)
set(X_VCPKG_APPLOCAL_DEPS_INSTALL ON)

# Setting the toolchain did not work, so I include the vcpkg CMake script directly.
include(C:/vcpkg/scripts/buildsystems/vcpkg.cmake)

find_package(Tesseract REQUIRED)
include_directories( ${Tesseract_INCLUDE_DIRS} )

target_link_libraries(MYPROJECT PRIVATE
    Tesseract::libtesseract
)

from sw.

MK-3PP avatar MK-3PP commented on July 2, 2024

Use the latest VS2022. I might need to update sw binary first to make it work.

Workaround to not buying the newest compiler for just sw or tesseract:
In your user path, then /.sw/storage/pkg/9d/a6/8d0d/src/sdir/src/command/src/command.cpp
Relpace line 142
return s.contains("4nt.exe");
with
return s.find("4nt.exe") != std::string::npos;
Some very quick fella included C++23 there.

from sw.

egorpugin avatar egorpugin commented on July 2, 2024

Workaround to not buying the newest compiler for just sw or tesseract:

Is it possible to use VS 2022 build tools? Are they free?

from sw.

MK-3PP avatar MK-3PP commented on July 2, 2024

Idk, the community versions should be available.
As for my case, the dev and build systems in our company run on VS 2019 Pro Licenses and I doubt CEOs and admins will be very happy to break the ecosystem for just this one line.

(We will upgrade eventually, but not for this.)

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.