I am trying to do something with the tesseract c++ library but I get the following linker error(mingw32-g++):
undefined reference to `tesseract::TessBaseAPI::TessBaseAPI()'
I am using Code::Blocks as my IDE and have done the following steps to prepare my environment:
Downloaded the sources and prepared my build folder as descripted at http://tesseract-ocr.googlecode.com/svn/trunk/vs2008/doc/setup.html
Created a new Code::Blocks project
Added all libraries included in the lib directory to the Project (Settings->Compiler Settings->Linker Setting->Link libraries->add)
Added the three additional folders (include, include/tesseract, include/leptonica) to the search directory list (Settings->Compiler Settings->Search directorys->add)
Then I have written some code to test my configuration ...
#include <baseapi.h>
#include <allheaders.h>
#include <iostream>
using namespace std;
int main()
{
tesseract::TessBaseAPI *api = new tesseract::TessBaseAPI();
return 0;
}
... and the above written linker error occurs.
I donĀ“t know what I am doing wrong, hope that anybody have an idea.
Thanks a lot.
You have to add the libraries under the Other Linker Flags in Build Settings.
Try adding -ltesseract and -lstdc++ and the paths to tesseract and leptonica libraries in the following convention:
-L/usr/local/Cellar/tesseract/3.04.01_2/lib
I had to add all the C/C++ include paths:
..\tesseract_3.05\api
..\tesseract_3.05\ccmain
..\tesseract_3.05\ccutil
..\tesseract_3.05\ccstruct
..\tesseract_3.05\classify
..\tesseract_3.05\cube
..\tesseract_3.05\cutil
..\tesseract_3.05\dict
..\tesseract_3.05\neural_networks\runtime
..\tesseract_3.05\textord
..\tesseract_3.05\viewer
..\tesseract_3.05\opencl
..\tesseract_3.05\wordrec
..\leptonica\src
..\liblept
Also I added all the libraries:
giflib.lib
libjpeg.lib
liblept.lib
libpng.lib
libtesseract.lib
libtiff.lib
libwebp.lib
openjpeg.lib
zlib.lib
In ubuntu, installing tesseract and leptonica:
sudo apt install tesseract-ocr
sudo apt install libtesseract-dev
(see:https://github.com/tesseract-ocr/tesseract/wiki)
Place the headers:
#include <tesseract/baseapi.h>
#include <leptonica/allheaders.h>
Compile:
g++ program.cpp -o program -llept -ltesseract
Related
I have downloaded "Chilkat C/C++ Library Downloads for Qt, CodeBlocks, MinGW, TDM-GCC, and MinGW-w64" version of Chilkat library in order to run above ftp c++ code.
#include <stdio.h>
#include "include/CkZip.h"
#include "include/CkFtp2.h"
#include "include/CkMailMan.h"
#include "include/CkXml.h"
#include "include/CkPrivateKey.h"
#include "include/CkRsa.h"
#include "include/CkHttp.h"
#include "include/CkMime.h"
#include "include/CkMht.h"
#include "include/CkSsh.h"
#include "include/CkSFtp.h"
void DoNothing(void)
{
// Instantiate the objects...
CkZip zip;
CkMailMan mailman;
CkFtp2 ftp2;
CkXml xml;
CkPrivateKey privKey;
CkRsa rsa;
CkHttp http;
CkMime mime;
CkMht mht;
CkSsh ssh;
CkSFtp sftp;
printf("Zip version: %s\n",zip.version());
}
int main(int argc, const char* argv[])
{
DoNothing();
return 0;
}
I have read the README fille and tried to run sample C++ sample linkSample.cpp.
for that reason I have read the linkSample.sh file which places in the Chilkat for Mingw folder.
I have worked in windows and loaded mingw and the path of g++ added to the cmd.
When I directly run the .sh folder command to the cmd I have received following error!
C:\Users\emma\Desktop\chilkat-9.5.0-x86_64-8.1.0-posix-seh-rt_v6-rev0>g++ -Wl,--enable-auto-import linkSample.cpp -o"linkSample.exe" -L. -lchilkat-9.5.0 -L/c/MinGW/lib -lcrypt32 -lws2_32 -ldnsapi
C:\Users\emma\AppData\Local\Temp\cciL4ofa.o:linkSample.cpp:(.text+0x10): undefined reference to `CkZip::CkZip()'
C:\Users\emma\AppData\Local\Temp\cciL4ofa.o:linkSample.cpp:(.text+0x1d): undefined reference to `CkMailMan::CkMailMan()'
C:\Users\emma\AppData\Local\Temp\cciL4ofa.o:linkSample.cpp:(.text+0x2a): undefined reference to `CkFtp2::CkFtp2()'
Could you guide me about compileing and running sample chilkat cpp program?
Thanks
I have change the workspace to linux and Also downloaded Chilkat "C/C++ Libraries for Linux" and copy the linkSample.cpp code to inside of it and run the following code:
g++ linkSample.cpp -Llib -lchilkat-9.5.0 -o linkSample -ldl
and the bin file have been appeared without error message. BUt, when I have tried to run executable bin file the following error message appears:
./linkSample: error while loading shared libraries: libchilkat-9.5.0.so: cannot open shared object file: No such file or directory
I want to keep my workspace in windows but I have just tried to see what happend in linux, and finally it does not work properly.
Any suggestion do you have?
Thanks
I have a fresh install of OS X 10.11.4 that I immediately installed the Xcode toolchain on, then Homebrew, then Boost 1.60. In order to test that everything had gone well, I wrote the following code on my Desktop.
#include <iostream>
#include <boost/filesystem.hpp>
int main() {
boost::filesystem::path new_directory("hello");
boost::filesystem::create_directory(new_directory);
}
I then attempted to compile it as I usually have done with the following command.
$ clang++ test.cpp -o test -lboost_system -lboost_filesystem
I received the following error.
test.cpp:3:10: fatal error: 'boost/filesystem.hpp' file not found
#include <boost/filesystem.hpp>
This is how I have always compiled projects that link Boost in the past. I'm assuming that I have probably forgotten a step along the way that allows clang to search a specific path to dynamically link the libraries. What should I change in order for this compilation command to work?
For me, boost has been compiled and installed into a subdirectory of my home directory, so you'll need to modify the paths as appropriate for your homebrew installation:
flags="-std=c++1z -I/${HOME}/local/include -L${HOME}/local/lib -lboost_filesystem -lboost_system"
c++ ${flags} -o jared jared.cpp
First get the location of boost by doing the following:
brew info boost
From the image above, you can see that my location is
/usr/local/Cellar/boost/1.66.0
Then, to compile, use the following:
c++ -I /usr/local/Cellar/boost/1.66.0 main.cpp -o boost
I am trying to compile the following code which has the headers:
#include <SDL2/SDL.h>
#include <SDL2_image/SDL_image.h>
However after running the following makefile:
g++ -std=c++11 src/main.cpp -lSDL2 -lSDL2_image
I get the following error:
fatal error: SDL2_image/SDL_image.h: No such file or directory
#include <SDL2_image/SDL_image.h>
Any suggestions? Not entirely sure about my installation of SDL_image. I am running this on Ubuntu.
This problem can be solved through installing libsdl2-image-dev package:
apt install libsdl2-image-dev
Run apt-file search SDL_image.h
The result will tell you the location of the include file.
For instance, /usr/include/SDL2/SDL_image.h was returned.
So, when you want to include SDL_image.h, write everything after the include/ in between < >.
Thus, includes should look like the following:
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
See the question's comments for the original discussion regarding this solution.
From SDL documentation, it says that add 'lSDL_image' to the end of the compile line.
cc -o myprogram mysource.o `sdl-config --libs` -lSDL_image
or
gcc -o myprogram mysource.c `sdl-config --libs` -lSDL_image
Here is the reference -> https://www.libsdl.org/projects/docs/SDL_image/SDL_image.html
Section 2.2 Compiling.
So for SDL2, you just need to change 'lSDL_image' to 'lSDL2_image'.
For Windows + SDL2-2.0.8 + SDL_image-2.0.4 + Codeblocks you've got the add both Runtime Binaries and Development Libraries to the compiler and linker. Or else, you'll get the error SDL2_image not found, even with having the dll in your program's directory, this occurs. Hopefully others find this helpful; I had to figure it out myself. Example: If your resources are separate, you'll be adding the two plus your standard SDL2 paths to your compiler and linker. Warning: SDL2_image.h has it's headers assuming that the headers are in the same folder as the SDL2 framework. If you get errors about the image header, include the sub-folder SDL2 from SDL framework in the path and then you should be including SDL2 in the program as: include <SDL.h> rather than include <SDL2/SDL.h>.
On my xcode project, I added the dylib of freetype to the project Link Binary phase.
I ensure /usr/local/include and /usr/local/lib are in search paths in the build settings.
I then include:
#include <freetype2/ft2build.h>
#include FT_FREETYPE_H
But i get an error that freetype.h was not found. Any ideas? I tried including <freetype2/freetype.h> directly, but that leads to more compile problems with include paths in other freetype files.
Looking at the demo programs in "freetype2-demos", I see:
#include <ft2build.h>
#include FT_FREETYPE_H
Also, I think you need your compiler command-line to include -I (path to freetype includes).
For example...
g++ -I (...)/freetype2 myfile.cpp
Here are the instructions. The suggestion there is to compile with something like...
g++ $(freetype-config --cflags) myfile.cpp
...which, if you system is configured correctly, will incorporate the -I option that I previously mentioned.
When I am including the asio header:
#include <boost/asio.hpp>
I got the error:
undefined reference to boost::system::generic_category()
So I read that I had to link to boost_system which I did. But now it gives the error::
cannot find -lboost_system
Why can it not find boost_system. I'm using Codeblocks on Windows.
boost is a separate library that needs to be installed on you building machine.
Please follow these instructions to install:
http://www.boost.org/doc/libs/1_55_0/doc/html/bbv2/installation.html
http://www.boost.org/
After installation your application needs to be able to find it if it is not installed in a standard location.
you will need to supply the header and lib directories to the build process.
g++ source source.cpp -I/path to boost headers -L path to boost libs -lboost_system
Look inside you libs directory to be sure that you have boost_system. It is possible depending on the build that you may only have boost_system-mt