Score:2

problem with making a c++ project with G++

aq flag

I am trying to build cascade library using G++ 8.3.0. In the documentation they mention that it was tested on G++ 4.7.2. My question is, is it necessary to downgrade to 4.7.2? if so could you please tell me how? because I tried both 4.8 (oldest version available according to $which gcc command) and 8.3.0 to build cascade and received the following error:

In file included from ../../include/descore/descore.hpp:104,
                 from ../../include/descore/stdafx.h:38,
                 from Wildcard.cpp:44:
../../include/descore/stltree.hpp:74:34: error: redefinition of ‘struct std::less<_Tp*>’
     template <typename T> struct less <T *>
                                  ^~~~~~~~~~
In file included from /usr/include/c++/8/bits/stl_tree.h:65,
                 from /usr/include/c++/8/set:60,
                 from ../../include/descore/descore.hpp:88,
                 from ../../include/descore/stdafx.h:38,
                 from Wildcard.cpp:44:
/usr/include/c++/8/bits/stl_function.h:424:12: note: previous definition of ‘struct std::less<_Tp*>’
     struct less<_Tp*> : public binary_function<_Tp*, _Tp*, bool>
            ^~~~~~~~~~
make: *** [Makefile:17: ../../objs/descore/Wildcard.o] Error 1

Or should I make changes to the .hpp files? (My final aim is to use cascade with G++-11. on ubuntu 19.10)

Thanks in advance.

cc flag
You need to use a c++ compiler, which would be g++ on Ubuntu, not gcc.
student_11 avatar
aq flag
I have edited my post. thanks. Do you get the same error when using the 'make' command?
hr flag
For me, using `g++-4.8` (on Ubuntu 18.04) overcomes the template redefinition issue (which I think is due to the code rolling its own partial specialization code for pointer types); however there are further errors at the link phase
hr flag
... OK so I did get it to build with g++-4.8 via cmake, by adding `descore` to the `target_link_libraries` and then using `cmake -DCMAKE_CXX_COMPILER=g++-4.8 -DCMAKE_CXX_FLAGS=-pthread`. But I don't know how to make it work with later g++.
student_11 avatar
aq flag
Thanks @steeldriver. I've built it using Microsoft VS2015 before. It did not work at first, but after I changed MSC_VERSION macros definitions in defines.hpp (i.e. #if _MSC_VER < 1900 #define va_copy(dst, src) ((void)((dst) = (src)))), it was built successfully. Cant we apply similar changes to g++ or .hpp files in Linux?
hr flag
@student_11 there *may* be a way to do that with g++ however I can't see anything obvious (such as a compiler switch or a `#ifdef` in the `stl_function.h` file that would allow the functionality to be turned off). You may need to remove the conflicting partial specialization code from the project. Good luck.
cc flag
Lines 80-90 of stltree.hpp give you the options for modification.
student_11 avatar
aq flag
@ubfun1 thanks. we should comment out the namespace above those lines to get rid of the error.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.