How to compile abbreviation hierarchies using KIT?

I am using KIT to compile the implementation of hierarchy reductions .

This software was published in 2009 and is obviously not supported since. Since several things have changed at this time (with the new C ++ standards and compiler versions), the code no longer compiles from the shelf.

README is not very verbose when it comes to compilation instructions and says that you should only call make . However, using make gives me the following error:

  g ++ -Wall -W -Wno-unused-parameter -O6 -c -o main.o main.cpp
 In file included from /usr/include/c++/4.8/ext/hash_map:60:07,
                  from command /../ io /../ datastr / graph /../../ io / serialize.h: 26,
                  from command /../ io /../ datastr / graph / edge.h: 26,
                  from command /../ io /../ datastr / graph / graph.h: 59,
                  from command /../ io / createGraph.h: 28,
                  from command / NodeOrder.h: 29,
                  from main.cpp: 35:
 /usr/include/c++/4.8/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date.  Please use a non-deprecated interface with equivalent functionality instead.  For a listing of replacement headers and interfaces, consult the file backward_warning.h.  To disable this warning use -Wno-deprecated.  [-Wcpp]
  #warning \
   ^
 command /../ processing /../ EliminationWeight.h: 42: 35: error: a call to a constructor cannot appear in a constant-expression
      static const Type MAX_VALUE = __DBL_MAX__;
                                    ^
 command /../ processing /../ EliminationWeight.h: 43: 36: error: a call to a constructor cannot appear in a constant-expression
      static const Type MIN_VALUE = -__ DBL_MAX__;
                                     ^
 make: *** [main.o] Error 1 

What do I need to do to compile?

+4
source share
1 answer

To make the software compilation error-free, you need to follow a few steps. I checked this instruction with gcc 4.8.1 and Boost 1.53.0.

constructor call cannot appear in constant expression

(I already answered this subtask in detail there , but will repeat the important steps here.)

The first compilation error we encounter is related to software using non-standard GCC compiler extensions. It seems that during the development of the software they should not have been included using the compiler, but this requires modern GCC. However, for future compatibility, we simply get rid of them and implement the functions in a standard way.

The compiler tells us that the problem is lines 42 and 43 of EliminationWeight.h . These are the lines in this file:

 static const Type MAX_VALUE = __DBL_MAX__; static const Type MIN_VALUE = -__DBL_MAX__; 

GCC complains here because the initialization of doubles in a class of a class is not covered by the standard. Instead, we must do this separately. Therefore, remove the initialization and change the lines as follows:

 static const Type MAX_VALUE; static const Type MIN_VALUE; 

Also remove #include <limits> , since we no longer need to have this file.

Since we still want to initialize these values, we look at main.cpp and find line 84 and the following:

 // doesn't look nice, but required by the compiler (gcc 4) const EdgeWeight Weight::MAX_VALUE; const EliminationWeight::Type EliminationWeight::MAX_VALUE; const EliminationWeight::Type EliminationWeight::MIN_VALUE; 

It looks like the perfect place to do our initializations. Modify lines 86 and 87 to contain the following code:

 const EliminationWeight::Type EliminationWeight::MAX_VALUE = std::numeric_limits< EliminationWeight::Type >::max(); const EliminationWeight::Type EliminationWeight::MIN_VALUE = -std::numeric_limits< EliminationWeight::Type >::max(); 

Also add

 #include <limits> 

to main.cpp , because now we use the std::numeric_limits class from this header.

collect2: error: ld returned 1 exit status

Now compilation will work, but the connection will fail with a huge error message. (I already examined this problem there , but will repeat its essence here.)

All errors will be associated with the Boost :: Regex binding. This is the complete error message on my machine:

  g ++ -lboost_regex -lboost_iostreams -o main main.o 
 main.o: In function `boost :: re_detail :: perl_matcher, std :: allocator>>, boost :: regex_traits>> :: unwind_extra_block (bool) ':
 . Main.cpp :( text._ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE18unwind_extra_blockEb [_ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE18unwind_extra_blockEb] + 0x2c): undefined reference to `boost :: re_detail :: put_mem_block (void *) '
 main.o: In function `void boost :: re_detail :: raise_error>>> (boost :: regex_traits_wrapper>> const &, boost :: regex_constants :: error_type) ':
 . Main.cpp :( text._ZN5boost9re_detail11raise_errorINS_20regex_traits_wrapperINS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEEEvRKT_NS_15regex_constants10error_typeE [_ZN5boost9re_detail11raise_errorINS_20regex_traits_wrapperINS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEEEvRKT_NS_15regex_constants10error_typeE] + 0x7d): undefined reference to `boost :: re_detail :: get_default_error_string (boost :: regex_constants :: error_type) '
 . Main.cpp :( text._ZN5boost9re_detail11raise_errorINS_20regex_traits_wrapperINS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEEEvRKT_NS_15regex_constants10error_typeE [_ZN5boost9re_detail11raise_errorINS_20regex_traits_wrapperINS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEEEvRKT_NS_15regex_constants10error_typeE] + 0xb1): undefined reference to `boost :: re_detail :: raise_runtime_error (std :: runtime_error const &) '
 . Main.cpp :( text._ZN5boost9re_detail11raise_errorINS_20regex_traits_wrapperINS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEEEvRKT_NS_15regex_constants10error_typeE [_ZN5boost9re_detail11raise_errorINS_20regex_traits_wrapperINS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEEEvRKT_NS_15regex_constants10error_typeE] + 0xcb): undefined reference to `boost :: re_detail :: get_default_error_string (boost :: regex_constants :: error_type) '
 main.o: In function `__gnu_cxx :: __ normal_iterator boost :: re_detail :: re_is_set_member, char, boost :: regex_traits>, unsigned int> (__ gnu_cxx :: __ normal_iterator, __gnu_cxx :: __ normal_iterator, boost :: re_detail :: * re_set_long , boost :: re_detail :: regex_data>> const &, bool) ':
 . Main.cpp :( text._ZN5boost9re_detail16re_is_set_memberIN9__gnu_cxx17__normal_iteratorIPKcSsEEcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEjEET_SB_SB_PKNS0_11re_set_longIT2_EERKNS0_10regex_dataIT0_T1_EEb [_ZN5boost9re_detail16re_is_set_memberIN9__gnu_cxx17__normal_iteratorIPKcSsEEcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEjEET_SB_SB_PKNS0_11re_set_longIT2_EERKNS0_10regex_dataIT0_T1_EEb] + 0x17b): undefined reference to `boost :: re_detail :: cpp_regex_traits_implementation :: transform_primary (char const *, char const *) const '
 . Main.cpp :( text._ZN5boost9re_detail16re_is_set_memberIN9__gnu_cxx17__normal_iteratorIPKcSsEEcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEjEET_SB_SB_PKNS0_11re_set_longIT2_EERKNS0_10regex_dataIT0_T1_EEb [_ZN5boost9re_detail16re_is_set_memberIN9__gnu_cxx17__normal_iteratorIPKcSsEEcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEjEET_SB_SB_PKNS0_11re_set_longIT2_EERKNS0_10regex_dataIT0_T1_EEb] + 0x4c0): undefined reference to `boost :: re_detail :: cpp_regex_traits_implementation :: transform (char const *, char const *) const '
 main.o: In function `boost :: re_detail :: perl_matcher, std :: allocator>>, boost :: regex_traits>> :: extend_stack () ':
 . Main.cpp :( text._ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE12extend_stackEv [_ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE12extend_stackEv] + 0x18): undefined reference to `boost :: re_detail :: get_mem_block () '
 main.o: In function `boost :: re_detail :: perl_matcher, std :: allocator>>, boost :: regex_traits>> :: match_imp () ':
 . Main.cpp :( text._ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE9match_impEv [_ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE9match_impEv] + 0xc): undefined reference to `boost :: re_detail :: get_mem_block () '
 . Main.cpp :( text._ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE9match_impEv [_ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE9match_impEv] + 0x19e): undefined reference to `boost :: re_detail :: verify_options (unsigned int, boost :: regex_constants :: _ match_flags) '
 . Main.cpp :( text._ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE9match_impEv [_ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE9match_impEv] + 0x254): undefined reference to `boost :: re_detail :: put_mem_block (void *) '
 . Main.cpp :( text._ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE9match_impEv [_ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE9match_impEv] + 0x3c6): undefined reference to `boost :: re_detail :: put_mem_block (void *) '
 main.o: In function `bool boost :: regex_match, std :: allocator, std :: allocator>>, char, boost :: regex_traits>> (std :: basic_string, std :: allocator> const &, boost :: match_results , std :: allocator> :: const_iterator, std :: allocator>>> &, boost :: basic_regex>> const &, boost :: regex_constants :: _ match_flags) ':
 . Main.cpp :( text._ZN5boost11regex_matchISt11char_traitsIcESaIcESaINS_9sub_matchIN9__gnu_cxx17__normal_iteratorIPKcSsEEEEEcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEbRKSbIT2_T_T0_ERNS_13match_resultsINSJ_14const_iteratorET1_EERKNS_11basic_regexISG_T3_EENS_15regex_constants12_match_flagsE [_ZN5boost11regex_matchISt11char_traitsIcESaIcESaINS_9sub_matchIN9__gnu_cxx17__normal_iteratorIPKcSsEEEEEcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEbRKSbIT2_T_T0_ERNS_13match_resultsINSJ_14const_iteratorET1_EERKNS_11basic_regexISG_T3_EENS_15regex_constants12_match_flagsE] + 0xe9): undefined reference to `boost :: re_detail :: perl_matcher, std :: allocator>>, boost :: regex_traits>> :: construct_init (boost :: basic_regex> > const &, boost :: regex_constants :: _ match_flags) '
 main.o: In function `void Command :: createVector (std :: string const &, std :: vector> &, double) ':
 main.cpp :(. text._ZN7Command12createVectorIdEEvRKSsRSt6vectorIT_SaIS4_EES4 _ [_ ZN7Command12createVectorIdEEvRKSsRSt6vectorIT_SaIS4_EES4 _] + 0x4a) :: undefined reference_created_considered_conflict_function
 main.cpp :(. text._ZN7Command12createVectorIdEEvRKSsRSt6vectorIT_SaIS4_EES4 _ [_ ZN7Command12createVectorIdEEvRKSsRSt6vectorIT_SaIS4_EES4 _] + 0x7b) :: undefined reference_confirm * do not read without any error ... + + + + + + + + + + + + + + + + + + + + + + + + + 1
 main.cpp :(. text._ZN7Command12createVectorIdEEvRKSsRSt6vectorIT_SaIS4_EES4 _ [_ ZN7Command12createVectorIdEEvRKSsRSt6vectorIT_SaIS4_EES4 _] + 0xac): undefined reference to const * const * do not write out unconditional_reass_created
 main.o: In function `void Command :: createVector (std :: string const &, std :: vector> &, unsigned int) ':
 main.cpp :(. text._ZN7Command12createVectorIjEEvRKSsRSt6vectorIT_SaIS4_EES4 _ [_ ZN7Command12createVectorIjEEvRKSsRSt6vectorIT_SaIS4_EES4 _] + 0x48): undefined reference to const * const * do not write out unconditional_reass_created
 main.cpp :(. text._ZN7Command12createVectorIjEEvRKSsRSt6vectorIT_SaIS4_EES4 _ [_ ZN7Command12createVectorIjEEvRKSsRSt6vectorIT_SaIS4_EES4 _] + 0x79): undefined reference to const * const * do not write out unconditional_reass_created
 main.o: main.cpp :(. text._ZN7Command12createVectorIjEEvRKSsRSt6vectorIT_SaIS4_EES4 _ [_ ZN7Command12createVectorIjEEvRKSsRSt6vectorIT_SaIS4_EES4 _] + 0xaa): more> unconditional_references basic_references_default
 main.o: In function `boost :: re_detail :: perl_matcher, std :: allocator>>, boost :: regex_traits>> :: match_match () ':
 main.cpp :( text._ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE11match_matchEv [_ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE11match_matchEv] + 0x371):. undefined reference to `boost :: match_results, std :: allocator>>> :: maybe_assign (boost :: match_results, std :: allocator>>> const &) ''
 main.o: In function `boost :: re_detail :: perl_matcher, std :: allocator>>, boost :: regex_traits>> :: match_dot_repeat_slow () ':
 . Main.cpp :( text._ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE21match_dot_repeat_slowEv [_ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE21match_dot_repeat_slowEv] + 0x229): undefined reference to `boost :: re_detail :: get_mem_block () '
 collect2: error: ld returned 1 exit status
 make: *** [main] Error 1 

It seems that Boost :: Regex was not found at all. Please note that this is one of the Boost libraries that you need to compile and link to your application to work. The following is an assumption that you received a compiled version, and it is located in the directory of your system library.

When linking, it is important that the order in which libraries and object files are transferred to GCC through command-line options. For some reason, what seemed to work with GCC in 2009 no longer works now. This can be fixed by changing the order in which make passes parameters to GCC.

Locate the Makefile in the project root directory and find line 6:

 $(CXX) $(LINK) -o $@ $^ $(LIBS) 

Here you can see that make passes linker linkers containing Boost libraries in front of the object file. (If you cannot, don’t worry. You do not need to understand the Makefile to follow this explanation.) To do this work with the current GCC, we will reorder the parameters. Line 6 of your Makefile should look like this:

 $(CXX) -o $@ $^ $(LIBS) $(LINK) 

Save it and run make again. Compilation and binding should now proceed without errors.

warning: #warning This file contains at least one obsolete or obsolete header

You will still see a compiler warning telling you that you are using obsolete header files. You can ignore this warning. However, it is possible that new versions of GCC will not ship with this header file, and compilation will fail.

If you want to fix it, here's how.

The task lies in io/serialize.h , which includes <ext/hash_map> . The C ++ 11 standard replaces this with unordered_map . Therefore, we will fix the code to use it. Line 128 will be

 typedef __gnu_cxx::hash_map<key_type, data_type> HashMap; 

Modify this to use unordered_map as follows:

 typedef std::unordered_map<key_type, data_type> HashMap; 

Now we also need to fix the header. Remove the inclusion of <ext/hash_map> and replace line 26 with

 #include <algorithm> #include <unordered_map> 

<algorithm> include is required because obviously <ext/hash_map> also provided std::sort and std::reverse for hash_map . These functions are now in the <algorithm> header, and the code is based on the fact that they are included in this file.

Since this is a C ++ 11 function, we need to tell GCC that we want to support this. Go to compiler.make in the project root directory and find line 6, which should be

 CXXFLAGS = $(DEBUG) $(WARNING) $(OPTIMIZER) 

At the end of the line, add a switch to use C ++ 11:

 CXXFLAGS = $(DEBUG) $(WARNING) $(OPTIMIZER) -std=c++11 

Run make clean and make again, and your code should compile without any errors or warnings.

+6
source

Source: https://habr.com/ru/post/1491587/


All Articles