0

I try to compile C++ program on my ubuntu 18.04. In program I use some external libraries.

The error looks like this:

blib/bun/impl/orm.hpp:1995:20: error: ‘struct blib::bun::__private::type_conversion’ redeclared as different kind of symbol
             struct type_conversion<SimpleObjHolder<T>> {
                    ^~~~~~~~~~~~~~~
blib/bun/impl/orm.hpp:1944:20: note: previous declaration ‘template<class T> struct blib::bun::__private::type_conversion’
             struct type_conversion {
                    ^~~~~~~~~~~~~~~
blib/bun/impl/orm.hpp:1995:53: error: expected unqualified-id before ‘>’ token
             struct type_conversion<SimpleObjHolder<T>> {
                                                     ^~
blib/bun/impl/orm.hpp:2114:12: error: ‘type_conversion’ is not a class template
     struct type_conversion<blib::bun::__private::SimpleObjHolder<T>> {
            ^~~~~~~~~~~~~~~
blib/bun/impl/orm.hpp:2114:67: error: conflicting declaration of template ‘template<class T> struct soci::type_conversion’
     struct type_conversion<blib::bun::__private::SimpleObjHolder<T>> {
                                                                   ^~
In file included from /usr/local/include/soci/exchange-traits.h:11:0,
                 from /usr/local/include/soci/into-type.h:13,
                 from /usr/local/include/soci/blob-exchange.h:12,
                 from /usr/local/include/soci/soci.h:18,
                 from /home/mike/Documents/PROJECTS/C/blib/bun/impl/DbBackend.hpp:9,
                 from blib/bun/impl/orm.hpp:41,
                 from blib/bun/bun.hpp:3,
                 from main.cpp:12:
/usr/local/include/soci/type-conversion-traits.h:19:8: note: previous declaration ‘template<class T, class Enable> struct soci::type_conversion’
 struct type_conversion
        ^~~~~~~~~~~~~~~
<builtin>: recipe for target 'main' failed
make: *** [main] Error 1

The example part of problematic code looks like this:

struct type_conversion<SimpleObjHolder<T>> {
                using ObjectHolderType = SimpleObjHolder<T>;
                using ObjType = T;
......

The exact problematic line is:

struct type_conversion<SimpleObjHolder<T>> {

Seems compiler can't understand the syntax, or my compiler is not right version.

I am newbie with C/C++, please, clarify me this moment..

This is the Makefile:

LDFLAGS := -L/usr/local/lib -L/home/mike/Documents/PROJECTS/C/libs/socket \
-I/home/mike/Documents/PROJECTS/C/third_party/unqlite -I/home/mike/Documents/PROJECTS/C -I/home/mike/Documents/PROJECTS/C/third_party
LDLIBS :=  -lchilkat-9.5.0 -lpthread -lresolv -lsocket
EXECUTABLE := main
CXXFLAGS=-g -std=c++11 -Wall -pedantic

all: $(EXECUTABLE)

clean:
    rm -f $(EXECUTABLE) *.o

Error after CXXFLAGS=-g -std=c++11 -Wall -pedantic added:

    blib/bun/impl/orm.hpp:1995:20: error: ‘type_conversion’ is not a class template
             struct type_conversion<SimpleObjHolder<T>> {
                    ^~~~~~~~~~~~~~~
blib/bun/impl/orm.hpp:1995:36: error: ‘SimpleObjHolder’ was not declared in this scope
             struct type_conversion<SimpleObjHolder<T>> {
                                    ^~~~~~~~~~~~~~~
blib/bun/impl/orm.hpp:1995:36: note: suggested alternative:
blib/bun/impl/orm.hpp:415:20: note:   ‘blib::bun::__private::SimpleObjHolder’
             struct SimpleObjHolder {
                    ^~~~~~~~~~~~~~~
blib/bun/impl/orm.hpp:1995:20: error: ‘struct blib::bun::__private::type_conversion’ redeclared as different kind of symbol
             struct type_conversion<SimpleObjHolder<T>> {
                    ^~~~~~~~~~~~~~~
blib/bun/impl/orm.hpp:1944:20: note: previous declaration ‘template<class T> struct blib::bun::__private::type_conversion’
             struct type_conversion {
                    ^~~~~~~~~~~~~~~
blib/bun/impl/orm.hpp:1995:53: error: expected unqualified-id before ‘>’ token
             struct type_conversion<SimpleObjHolder<T>> {
                                                     ^~
blib/bun/impl/orm.hpp:2105:14: warning: extra ‘;’ [-Wpedantic]
             };
              ^
blib/bun/impl/orm.hpp:2114:12: error: ‘type_conversion’ is not a class template
     struct type_conversion<blib::bun::__private::SimpleObjHolder<T>> {
            ^~~~~~~~~~~~~~~
blib/bun/impl/orm.hpp:2114:67: error: conflicting declaration of template ‘template<class T> struct soci::type_conversion’
     struct type_conversion<blib::bun::__private::SimpleObjHolder<T>> {

I tried with CXXFLAGS=-g -std=c++11 -Wall -pedantic, CXXFLAGS=-g -std=c++14 -Wall -pedantic, CXXFLAGS=-g -std=c++17 -Wall -pedantic

gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)

Mikael
  • 1,209
  • 1
  • 16
  • 47
  • 1
    Can you try with `CXXFLAGS=-std=c++11` (or 14 /17 ) (see https://stackoverflow.com/questions/16886591/how-do-i-enable-c11-in-gcc if needed) – Martin Morterol Feb 18 '20 at 08:08
  • 1
    Older C++ compilers used to choke on on the `>>` pair because it was a keyword and insisted to have a space to separate the `>` that way: `struct type_conversion > {`. Unsure whether relevant here, hence a mere comment and not an answer... – Serge Ballesta Feb 18 '20 at 08:16
  • But how can I solve it? In used library a lot of such codes `>>`, I can't edit it everywhere. I have added CXXFLAGS=-g -std=c++11 -Wall -pedantic to Makefile, next error I added to post – Mikael Feb 18 '20 at 08:18

0 Answers0