Giter VIP home page Giter VIP logo

Comments (27)

DanBloomberg avatar DanBloomberg commented on July 17, 2024 1

Thanks. Is this documented, or if not, should it be?

from leptonica.

Medalha avatar Medalha commented on July 17, 2024

I made some experiments. If I use the main 'CMakeLists.txt' from March 21, the build of library and programs succeeds without error.

The file mentioned above is downloadable from here:
https://github.com/DanBloomberg/leptonica/blob/0180cb11e405f766ce1429d6c7fd3acf1eb21f46/CMakeLists.txt

from leptonica.

DanBloomberg avatar DanBloomberg commented on July 17, 2024

Thank you for reporting this and doing the experiment to find where it broke.

Diffing those two CMakeLists.txt files, I ge:

44c44
<   LANGUAGES C
---
>   LANGUAGES C CXX
46,50d45
< set(CMAKE_C_STANDARD 17)
< set(CMAKE_C_STANDARD_REQUIRED ON)
< 
< # Standard installation paths
< include(GNUInstallDirs)
234c229
< if(CMAKE_C_COMPILER_ID MATCHES "Clang")
---
> if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
249a245
> include(CheckCXXCompilerFlag)
253a250
>   check_cxx_compiler_flag(${flag_} CXX_HAS${result_})
261c258
<     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
---
>     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
278a276,278
>       endif()
>       if(CXX_HAS${flag_var})
>         set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${flag_}")

Just a guess (I don't do support for the cmake build): your problem is with C_STANDARD 17.
Someone will look into this.

Dan

from leptonica.

Medalha avatar Medalha commented on July 17, 2024

Thank you!

from leptonica.

Medalha avatar Medalha commented on July 17, 2024

I commented these two lines and the problem persists:

set(CMAKE_C_STANDARD 17)
set(CMAKE_C_STANDARD_REQUIRED ON)

On the other end, leaving the above lines as they are and resetting a single line from

LANGUAGES C

to

LANGUAGES C CXX

as it was before, enables the build without error.

from leptonica.

zdenop avatar zdenop commented on July 17, 2024

leptonica is C project, not C++. So reverting this declaration is a mistake.
Windows sw build works: https://github.com/DanBloomberg/leptonica/actions/runs/5844900648/job/15848467357
Clean windows cmake build (without sw) works fine too (see https://github.com/DanBloomberg/leptonica/actions/workflows/cmake-win64.yml)

@egorpugin: do you have any suggestions for this problem?

from leptonica.

Medalha avatar Medalha commented on July 17, 2024

I don't have enough knowledge on these matters to evaluate this issue properly. All I know is that I used to build Leptonica (with sw) without any issue and suddenly I couldn't do it anymore, with the error I reported in my first message. It happened after the change in the "CMakeLists.txt" file.

The fact remains that simply changing that line to "LANGUAGES C CXX" enables the correct building of the project. The question is why. Why is this enough?

from leptonica.

egorpugin avatar egorpugin commented on July 17, 2024

Hi,

Please add CXX language in cmake project command.

from leptonica.

Medalha avatar Medalha commented on July 17, 2024

Please add CXX language in cmake project command.

Do you mean the cmake command line? Do you remember the correct syntax? I can search for it, of course.

from leptonica.

rajeshja avatar rajeshja commented on July 17, 2024

Has there been any change @egorpugin ? I'm trying to build leptonica and it's failing with the following errors:

[143/150] [pub.egorpugin.primitives.command-0.3.1]/src/command.cpp
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/xxx/.sw/storage/pkg/9d/a6/8d0d/src/sdir/src/command/src/command.cpp(142): error C2039: 'contains': is not a member of '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(4871): note: see declaration of 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>'
C:/Users/xxx/.sw/storage/pkg/9d/a6/8d0d/src/sdir/src/command/src/command.cpp(147): note: see reference to function template instantiation 'auto primitives::Command::setProgram::<lambda_1>::()::<lambda_1>::operator ()<const char(&)[6]>(_T1) const' being compiled
        with
        [
            _T1=const char (&)[6]
        ]
C:/Users/xxx/.sw/storage/pkg/9d/a6/8d0d/src/sdir/src/command/src/command.cpp(147): error C3487: 'bool': all return expressions must deduce to the same type: previously it was 'void'
C:/Users/xxx/.sw/storage/pkg/9d/a6/8d0d/src/sdir/src/command/src/command.cpp(144): error C3487: 'bool': all return expressions must deduce to the same type: previously it was 'void'
C:/Users/xxx/.sw/storage/pkg/9d/a6/8d0d/src/sdir/src/command/src/command.cpp(144): error C2562: 'primitives::Command::setProgram::<lambda_1>::()::<lambda_1>::operator ()': 'void' function returning a value
C:/Users/xxx/.sw/storage/pkg/9d/a6/8d0d/src/sdir/src/command/src/command.cpp(147): note: see declaration of 'primitives::Command::setProgram::<lambda_1>::()::<lambda_1>::operator ()'
C:/Users/xxx/.sw/storage/pkg/9d/a6/8d0d/src/sdir/src/command/src/command.cpp(147): error C2296: '||': illegal, left operand has type 'void'
C:/Users/xxx/.sw/storage/pkg/9d/a6/8d0d/src/sdir/src/command/src/command.cpp(147): error C2297: '||': illegal, right operand has type 'void'
command failed: exit code = 2
Total errors: 1

I've tried changing LANGUAGES C to LANGUAGES C CXX and also tried adding the following:

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

but it seems to make no difference.

from leptonica.

egorpugin avatar egorpugin commented on July 17, 2024

Hi,

You need the latest Visual Studio if you are building with SW tool.

from leptonica.

rajeshja avatar rajeshja commented on July 17, 2024

Looks like the dependency with the error uses C++23, for which you need VS 2022.
Some changes I found in other forums:

  1. Edit line 142 in C:/Users/xxx/.sw/storage/pkg/9d/a6/8d0d/src/sdir/src/command/src/command.cpp (look in the error for the exact location) and change it to return s.find("4nt.exe") != std::string::npos;
  2. In leptonica/CMakeLists.txt, change the line LANGUAGES C to LANGUAGES C CXX
  3. I'm not sure if this is strictly necessary, so if the above two don't work, additionally add the following lines:
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

after set(CMAKE_C_STANDARD_REQUIRED ON)

Once command.cpp is compiled, you can remove all these changes.

from leptonica.

Medalha avatar Medalha commented on July 17, 2024

from leptonica.

rajeshja avatar rajeshja commented on July 17, 2024

Once the dependency is compiled, the original code works. The above changes I have listed allow the code to be built with VS 2019.

from leptonica.

DanBloomberg avatar DanBloomberg commented on July 17, 2024

@egorpugin @zdenop

This looks to me like a documentation/maintenance issue worth fixing, because it is claimed to affect users who are building with versions of VS before 2022.

from leptonica.

zdenop avatar zdenop commented on July 17, 2024

@DanBloomberg : this is sw issue. There is not problem to build leptonica with VS2019 (and cmake without sw [-DSW_BUILD=OFF])

from leptonica.

zdenop avatar zdenop commented on July 17, 2024

at least at https://github.com/DanBloomberg/leptonica/blob/master/.github/workflows/cmake-win64.yml ;-)

from leptonica.

zdenop avatar zdenop commented on July 17, 2024

I wrote some instructions to wiki ( https://github.com/DanBloomberg/leptonica/wiki) - feel free to improve it (especially grammar ;- ) )

from leptonica.

DanBloomberg avatar DanBloomberg commented on July 17, 2024

Thank you! I have modified it slightly, suggesting that one should load png, lz, jpeg and tiff libraries.
The other 3 image I/O libraries are not as important.

There are two other optional dependencies, which are not image I/O:

  • gnuplot (for plotting data)
  • poppler (for rendering pdf files as images)

I am in the process of putting code that uses poppler programs pdftoppm and pdfimages into the library, in a new file renderpdf.c (not yet added).
Right now, the code that uses them is only in several programs; e.g., cleanpdf, croppdf, compresspdf.

We should at some point include these two optional dependencies in the wiki. You can see the information about gnuplot in gplot.c and about poppler in prog/cleanpdf.c, line 122 ff.

from leptonica.

zdenop avatar zdenop commented on July 17, 2024

I was focusing on building the library. AFAIK Leptonica is not linked against Gnuplot, right?

from leptonica.

DanBloomberg avatar DanBloomberg commented on July 17, 2024

Yes, you're right. gnuplot and the poppler programs are not dependencies of the library, and are not linked.

They're just programs that can be called, so best to leave them out of this BUILD wiki.

from leptonica.

Medalha avatar Medalha commented on July 17, 2024

from leptonica.

zdenop avatar zdenop commented on July 17, 2024

Ups. I forgot to reorder sections in wiki correctly...
jbigkit, lzma, and zstd are used by libtiff -, they are not used by leptonica directly...

Please be aware that libtiff (maybe also others) has more optional dependencies that I did not cover in this tutorial.

from leptonica.

DanBloomberg avatar DanBloomberg commented on July 17, 2024

We enable tiff read/write with two compression formats
IFF_TIFF_ZIP and IFF_TIFF_JPEG
that require libraries external to tiff.
So the jpeg library is a dependency of tiff and needs to be included.
I believe all computers have the zip library, so that's not an issue.

from leptonica.

DanBloomberg avatar DanBloomberg commented on July 17, 2024

@zdenop
Is this issue resolved?

from leptonica.

zdenop avatar zdenop commented on July 17, 2024

IMO yes

from leptonica.

Medalha avatar Medalha commented on July 17, 2024

from leptonica.

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.