Comments (27)
Thanks. Is this documented, or if not, should it be?
from leptonica.
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.
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.
Thank you!
from leptonica.
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.
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.
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.
Hi,
Please add CXX language in cmake project command.
from leptonica.
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.
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.
Hi,
You need the latest Visual Studio if you are building with SW tool.
from leptonica.
Looks like the dependency with the error uses C++23, for which you need VS 2022.
Some changes I found in other forums:
- 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 toreturn s.find("4nt.exe") != std::string::npos;
- In
leptonica/CMakeLists.txt
, change the lineLANGUAGES C
toLANGUAGES C CXX
- 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.
from leptonica.
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.
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.
@DanBloomberg : this is sw issue. There is not problem to build leptonica with VS2019 (and cmake without sw [-DSW_BUILD=OFF])
from leptonica.
at least at https://github.com/DanBloomberg/leptonica/blob/master/.github/workflows/cmake-win64.yml ;-)
from leptonica.
I wrote some instructions to wiki ( https://github.com/DanBloomberg/leptonica/wiki) - feel free to improve it (especially grammar ;- ) )
from leptonica.
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.
I was focusing on building the library. AFAIK Leptonica is not linked against Gnuplot, right?
from leptonica.
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.
from leptonica.
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.
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.
@zdenop
Is this issue resolved?
from leptonica.
IMO yes
from leptonica.
from leptonica.
Related Issues (20)
- Leptonica 1.84 release schedule HOT 28
- How to detect the four corners of paper or ID card HOT 8
- 1.84.0 fails to build in FreeBSD 14.0 due missing reference to libm using CMake HOT 24
- CMake build in 1.84.0 adds include to non-existant path
- 1.84.1: compile time warnings HOT 3
- pixWriteJp2k: unexpected strong color artifacts on featureless image HOT 7
- pixOrientDetect with .bmp file HOT 6
- Logic error in pixcmapIsValid() HOT 5
- Regression: file not found on MacOS when opening /tmp file HOT 2
- Identifying and removing asterisks HOT 8
- pixDeskewGeneral(...) failing to detect a 45 degree skew? HOT 2
- Application crashing while disposing Pix.Create object HOT 5
- get minarea-rotated box of a skew area HOT 2
- pixRead() can't read png images HOT 5
- Crash when access Pix colormap on debug HOT 6
- Installing leptonica on Windows failed with reason prompt 'SW' not found HOT 2
- Errors building Leptonica for use with Tesseract HOT 2
- getImpliedFileFormat / pixWriteImpliedFormat and PNM issues HOT 2
- pixOrientCorrect/pixOrientDetect issue with PBM HOT 4
- Cross-Compiling Leptonica for Windows on Arch Linux HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from leptonica.