How to compile tesseract baseapi.h with MinGW on window? - c++

So I want to use tesseract api on my project.
And the problem is I don't know how to compile this baseapi.h with MinGW on window.
I'm using this
g++ -I/[...]/project/tesseract-master/include/ -I/[...]/project/leptonica/src/ t.cpp -o t
and got
In file included from t.cpp:2:
/[...]/project/tesseract-master/include/tesseract/baseapi.h:33:10: fatal error: tesseract/version.h: No such file or directory
#include <tesseract/version.h>
^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
I think the problem is about version.h file, It's actually a version.h.in file
leptonica also have same problem with .h.in file
I don't know if MinGW can compile this type of file, so if there's a way or it can't pls tell me thanks.
g++.exe (i686-posix-dwarf-rev0, Built by MinGW-W64 project) 8.1.0
Tesseract from main branch https://github.com/tesseract-ocr/tesseract
Leptonica from 1.80.0 release
https://github.com/DanBloomberg/leptonica

It seems that you did not install tesseract - otherwise version.h (actually generated during tesseract build/compilation) would be present.

Related

can not build cpp using clang pre-built binary: file wchar.h not found

I am using MacOS 10.15. Since the clang shipped with MacOS does not include clang-format. I installed another pre-built clang binary from here. I have added the binary file path to my PATH variable.
export PATH="$HOME/tools/clang+llvm-10.0.0-x86_64-apple-darwin/bin:$PATH"
I tried to compile a simple program:
#include <iostream>
int main(int argc, char *argv[]) {
std::cout << "Hello world!\n";
return 0;
}
using the following command:
clang++ hello.cpp -o hello
I got the following error:
In file included from hello.cpp:1:
In file included from /Users/jdhao/tools/clang+llvm-10.0.0-x86_64-apple-darwin/bin/../include/c++/v1/iostream:37:
In file included from /Users/jdhao/tools/clang+llvm-10.0.0-x86_64-apple-darwin/bin/../include/c++/v1/ios:214:
In file included from /Users/jdhao/tools/clang+llvm-10.0.0-x86_64-apple-darwin/bin/../include/c++/v1/iosfwd:95:
/Users/jdhao/tools/clang+llvm-10.0.0-x86_64-apple-darwin/bin/../include/c++/v1/wchar.h:118:15: fatal error: 'wchar.h' file not found
#include_next <wchar.h>
^~~~~~~~~
1 error generated.
I found that wchar.h bundled with this pre-built package is in the following directory:
/Users/jdhao/tools/clang+llvm-10.0.0-x86_64-apple-darwin/include/c++/v1/
So I added the -I flag:
clang++ -I /Users/jdhao/tools/clang+llvm-10.0.0-x86_64-apple-darwin/include/c++/v1 hello.cpp -o hello
The error still persists.
If I use clang++ shipped with MacOS, I have no problem compiling the source code:
# the following works without any error
/usr/bin/clang++ hello.cpp -o hello
I have seen post here, here, and here, but the solutions do not apply.
You got clang-format improperly. Reset the system to the state before you installed another pre-built clang binary. Then use Homebrew to install clang-format
brew install clang-format
clang+llvm-10.0.0-x86_64-apple-darwin is not suitable to your Mac. It depends on system frameworks that are not available, so you get the error finding wchar.h in a system framework. When you install clang+llvm-10.0.0-x86_64-apple-darwin you ignore framework dependencies. Homebrew will care about dependencies.

Windows C++ How to install GLFW library?

I am coding window part of my game. Code gives error. I think the reason of the error is the lack of GLFW library. I am using Notepad++ for editing and MinGW for compiling. How can I install a library to my folder?
Error:
NPP_SAVE: C:\Users\User\Desktop\game\src\main.cpp
CD: C:\Users\User\Desktop\game\src
Current directory: C:\Users\User\Desktop\game\src
g++ "main.cpp" -o main -march=native -O3
Process started (PID=1568) >>>
In file included from main.cpp:4:
Display.h:7:10: fatal error: GLFW/glfw3.h: No such file or directory
#include <GLFW/glfw3.h>
^~~~~~~~~~~~~~
compilation terminated.
<<< Process finished (PID=1568). (Exit code 1)
NPP_RUN: main
; executing: NPP_RUN main
- the specified file was not found
================ READY ================
You don't install a library, you just need to tell the compiler where to find the headers and libraries you require. How you do this depends on your build environment.
If you use only mingw g++ you need the following options:
-I (that's an uppercase i!)(specify path to include files, in your case the path to glfw/include directory)
-L (path to libraries, in your case to the folder that contains glfw3.lib)
-l (that's a lower case L!)(a list of libraries to use, in your case glfw3, without the extension)

"fatal error: boost/regex.hpp: No such file or directory" when trying to compile C++ program using a makefile

I am trying to compile a piece of open source software called "SPECIES
Identification of Taxonomic Mentions in Text". I am on MacOS.
I downloaded the source code (which can be found here), moved into the directory and used the command make to compile. This is the error returned:
g++ -fpic -pthread -Wall -O3 -o organisms organisms.cxx -lm -lboost_regex
In file included from batch_tagger.h:5:0,
from organisms.cxx:3:
tagger.h:7:27: fatal error: boost/regex.hpp: No such file or directory
compilation terminated.
make: *** [organisms] Error 1
I installed the C++ boost library using brew install boostand tried the above steps again (it did not work).
I tried dropping the boost directory into the directory containing the source code (it did not work).
Any suggestions/help?
You need to tell the compiler where to find boost headers.
You need to use the include path option to specify where the boost headers can be find, use -I/path/to/boost/include.
Then include the file using #include <boost/regex.hpp> from your code.

missing .lib files while compiling qt 4.8 project

I'm trying to build Open-Sankoré project (https://github.com/Sankore/Sankore-3.1) on qt-creator using qt 4.8.6 kit & mingw4 on windows..
I was able to overcome many compiler errors subsequently through some workarounds but this error stumped me:
g++: ole32.lib: No such file or directory
g++: oleaut32.lib: No such file or directory
g++: user32.lib: No such file or directory
g++: gdi32.lib: No such file or directory
g++: advapi32.lib: No such file or directory
I guess it's related to msvc compiler and that I'm compiling now using gcc..
Anyone have an idea how to fix this ??
g++ cannot use .lib generated by msvc, is use libXXX.a lib files
download Qt for mingw g++
http://download.qt.io/official_releases/qt/4.8/4.8.7/qt-opensource-windows-x86-mingw482-4.8.7.exe

Compiling tesseract on Windows using Cygwin GCC

Getting below error while compiling tesseract source on Windows using Cygwin GCC:
-MT"training/commontraining.d" -o "training/commontraining.o" "../training/commontraining.cpp"
../training/commontraining.cpp:17:30: fatal error: base/init_google.h: No such file or directory
Please help me find which library provides the init_google.h header file.