I have want to build a shared object/shared library to be used by an executable later on.
I have a directory with my own *.cpp
as well as the corresponding *.h
files.
All the files are located in the same directory as my makefile
(-I.
):
#makefile to create shared library w/o executable from own headers and tesseract
CC = g++
INCL = -I. -I/usr/include/tesseract/ -I/usr/include/leptonica/
CFLAGS= -Wall -g -c -fPIC
LDFLAGS = -shared
LIBS = libtesseract.a liblept.a
RM = rm -f
TARGET_LIB = libTargetLib.so
SRCS = *.cpp
OBJS = $(SRCS:.cpp=.o)
.PHONY: all
all: ${TARGET_LIB}
$(TARGET_LIB): $(OBJS)
$(CC) $(LDFLAGS) $(INCL) -Wl,-rpath=/usr/lib/x86_64-linux-gnu/ -o $(TARGET_LIB) $^ -L/usr/lib/x86_64-linux-gnu/ -llept -ltesseract
$(OBJS): $(SRCS)
$(CC) $(CFLAGS) $(SRCS)
The library files to be linked, libtesseract.a
and liblept.a
are in the location /usr/lib/x86_64-linux-gnu
, I doublechecked.
I am aware of this problem: ambiguous symbol File: tesscallback.h so I also commented out the correspondent lines.
When I run make
, I get this error (tons of lines more):
In file included from /usr/include/tesseract/baseapi.h:34:0, from file1.h:16, from file1.cpp:4: /usr/include/tesseract/tesscallback.h:296:12: error: expected nested-name-specifier before ‘remove_reference’ typename remove_reference::type p1_; ^~~~~~~~~~~~~~~~ /usr/include/tesseract/tesscallback.h:296:12: error: expected ‘;’ at end of member declaration /usr/include/tesseract/tesscallback.h:296:28: error: expected unqualified-id before ‘<’ token typename remove_reference::type p1_; ^ /usr/include/tesseract/tesscallback.h: In constructor ‘_ConstTessMemberResultCallback_1_0::_ConstTessMemberResultCallback_1_0(const T*, _ConstTessMemberResultCallback_1_0::MemberSignature, P1)’: /usr/include/tesseract/tesscallback.h:301:29: error: class ‘_ConstTessMemberResultCallback_1_0’ does not have any field named ‘p1_’ member_(member), p1_(p1) { } ^~~ /usr/include/tesseract/tesscallback.h: In member function ‘virtual R _ConstTessMemberResultCallback_1_0::Run()’: /usr/include/tesseract/tesscallback.h:305:38: error: ‘p1_’ was not declared in this scope R result = (object_->*member_)(p1_); ^~~ /usr/include/tesseract/tesscallback.h:308:38: error: ‘p1_’ was not declared in this scope R result = (object_->member_)(p1_); ^~~ /usr/include/tesseract/tesscallback.h: At global scope: /usr/include/tesseract/tesscallback.h:326:12: error: expected nested-name-specifier before ‘remove_reference’ typename remove_reference::type p1_; ^~~~~~~~~~~~~~~~ /usr/include/tesseract/tesscallback.h:326:12: error: expected ‘;’ at end of member declaration /usr/include/tesseract/tesscallback.h:326:28: error: expected unqualified-id before ‘<’ token typename remove_reference::type p1_; ^ /usr/include/tesseract/tesscallback.h: In constructor ‘_ConstTessMemberResultCallback_1_0::_ConstTessMemberResultCallback_1_0(const T, _ConstTessMemberResultCallback_1_0::MemberSignature, P1)’: /usr/include/tesseract/tesscallback.h:331:29: error: class ‘_ConstTessMemberResultCallback_1_0’ does not have any field named ‘p1_’ member_(member), p1_(p1) { } ^~~ /usr/include/tesseract/tesscallback.h: In member function ‘virtual void _ConstTessMemberResultCallback_1_0::Run()’: /usr/include/tesseract/tesscallback.h:335:27: error: ‘p1_’ was not declared in this scope (object_->*member_)(p1_); ^~~ /usr/include/tesseract/tesscallback.h:337:27: error: ‘p1_’ was not declared in this scope (object_->*member_)(p1_);
When I do not comment it out (i. e., lines still there), I get:
In file included from /usr/include/tesseract/baseapi.h:34:0, from process_houghlines.h:18, from process_houghlines.cpp:3: /usr/include/tesseract/tesscallback.h:278:29: error: ‘remove_reference’ is not a class template template struct remove_reference { typedef T type; }; ^~~~~~~~~~~~~~~~ /usr/include/tesseract/tesscallback.h:278:29: error: redefinition of ‘struct remove_reference’ /usr/include/tesseract/tesscallback.h:277:29: note: previous definition of ‘struct remove_reference’ template struct remove_reference { typedef T type; }; ^~~~~~~~~~~~~~~~ /usr/include/tesseract/tesscallback.h:296:12: error: expected nested-name-specifier before ‘remove_reference’ typename remove_reference::type p1_; ^~~~~~~~~~~~~~~~ /usr/include/tesseract/tesscallback.h:296:12: error: expected ‘;’ at end of member declaration /usr/include/tesseract/tesscallback.h:296:28: error: expected unqualified-id before ‘<’ token typename remove_reference::type p1_; ^ /usr/include/tesseract/tesscallback.h: In constructor ‘_ConstTessMemberResultCallback_1_0::_ConstTessMemberResultCallback_1_0(const T*, _ConstTessMemberResultCallback_1_0::MemberSignature, P1)’: /usr/include/tesseract/tesscallback.h:301:29: error: class ‘_ConstTessMemberResultCallback_1_0’ does not have any field named ‘p1 ’ member_(member), p1_(p1) { } ^~~ /usr/include/tesseract/tesscallback.h: In member function ‘virtual R _ConstTessMemberResultCallback_1_0::Run()’: /usr/include/tesseract/tesscallback.h:305:38: error: ‘p1_’ was not declared in this scope R result = (object_->*member_)(p1_); ^~~ /usr/include/tesseract/tesscallback.h:308:38: error: ‘p1_’ was not declared in this scope R result = (object_->member_)(p1_); ^~~ /usr/include/tesseract/tesscallback.h: At global scope: /usr/include/tesseract/tesscallback.h:326:12: error: expected nested-name-specifier before ‘remove_reference’ typename remove_reference::type p1_; ^~~~~~~~~~~~~~~~ /usr/include/tesseract/tesscallback.h:326:12: error: expected ‘;’ at end of member declaration /usr/include/tesseract/tesscallback.h:326:28: error: expected unqualified-id before ‘<’ token typename remove_reference::type p1_; ^ /usr/include/tesseract/tesscallback.h: In constructor ‘_ConstTessMemberResultCallback_1_0::_ConstTessMemberResultCallback_1_0(const T, _ConstTessMemberResultCallback_1_0::MemberSignature, P1)’: /usr/include/tesseract/tesscallback.h:331:29: error: class ‘_ConstTessMemberResultCallback_1_0’ does not have any field named ... (reoccurring error)
The files file1.h
and file1.cpp
:
...
#include <tesseract/baseapi.h>
#include <leptonica/allheaders.h>
...
and
...
#include "file1.h"
...
The files file2.h
and file2.cpp
:
...
#include <tesseract/baseapi.h>
#include <leptonica/allheaders.h>
...
and
...
#include "file2.h"
...
I dont even understand, why the errors differ, since the headers are to the extend of using Tesseract just equal and one time the error occurs in one, than in the other file.
Thank you so much for any help.