2014-09-02 2 views
0

У меня возникают некоторые проблемы при компиляции проекта C++ в Eclipse. Он работает хорошо, но когда я заголовочный файл подталкивание (алгоритм/string.hpp) он показывает мне theese ошибки:Ошибка в проекте C++ eclipse с использованием библиотек Boost

16:25:53 **** Incremental Build of configuration Debug for project Emulator **** 
make all 
Building file: ../src/Emulator.cpp 
Invoking: GCC C++ Compiler 
g++ -I/usr/lib/qt/include -I/root/boost/boost/ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/Emulator.d" -MT"src/Emulator.d" -o "src/Emulator.o" "../src/Emulator.cpp" 
In file included from /usr/include/boost/algorithm/string/finder.hpp:23:0, 
       from /usr/include/boost/algorithm/string/find.hpp:22, 
       from /usr/include/boost/algorithm/string/predicate.hpp:23, 
       from /root/boost/boost/algorithm/string.hpp:21, 
       from ../src/Emulator.cpp:12: 
/usr/include/boost/algorithm/string/detail/finder.hpp: En la instanciación de ‘boost::iterator_range<Iterator> boost::algorithm::detail::token_finderF<PredicateT>::operator()(ForwardIteratorT, ForwardIteratorT) const [with ForwardIteratorT = __gnu_cxx::__normal_iterator<char*, std::basic_string<char> >; PredicateT = const char*]’: 
/usr/include/boost/algorithm/string/concept.hpp:43:28: se requiere desde ‘void boost::algorithm::FinderConcept<FinderT, IteratorT>::constraints() [with FinderT = boost::algorithm::detail::token_finderF<const char*>; IteratorT = __gnu_cxx::__normal_iterator<char*, std::basic_string<char> >]’ 
/usr/include/boost/concept/detail/has_constraints.hpp:32:62: se requiere para la sustitución de ‘template<class Model> boost::concepts::detail::yes boost::concepts::detail::has_constraints_(Model*, boost::concepts::detail::wrap_constraints<Model, (& Model:: constraints)>*) [with Model = boost::algorithm::FinderConcept<boost::algorithm::detail::token_finderF<const char*>, __gnu_cxx::__normal_iterator<char*, std::basic_string<char> > >]’ 
/usr/include/boost/concept/detail/has_constraints.hpp:42:5: se requiere desde ‘const bool boost::concepts::not_satisfied<boost::algorithm::FinderConcept<boost::algorithm::detail::token_finderF<const char*>, __gnu_cxx::__normal_iterator<char*, std::basic_string<char> > > >::value’ 
/usr/include/boost/concept/detail/has_constraints.hpp:45:31: se requiere desde ‘struct boost::concepts::not_satisfied<boost::algorithm::FinderConcept<boost::algorithm::detail::token_finderF<const char*>, __gnu_cxx::__normal_iterator<char*, std::basic_string<char> > > >’ 
/usr/include/boost/mpl/if.hpp:67:11: se requiere desde ‘struct boost::mpl::if_<boost::concepts::not_satisfied<boost::algorithm::FinderConcept<boost::algorithm::detail::token_finderF<const char*>, __gnu_cxx::__normal_iterator<char*, std::basic_string<char> > > >, boost::concepts::constraint<boost::algorithm::FinderConcept<boost::algorithm::detail::token_finderF<const char*>, __gnu_cxx::__normal_iterator<char*, std::basic_string<char> > > >, boost::concepts::requirement<boost::concepts::failed************ boost::algorithm::FinderConcept<boost::algorithm::detail::token_finderF<const char*>, __gnu_cxx::__normal_iterator<char*, std::basic_string<char> > >::************> >’ 
/usr/include/boost/concept/detail/general.hpp:50:8: se requiere desde ‘struct boost::concepts::requirement_<void (*)(boost::algorithm::FinderConcept<boost::algorithm::detail::token_finderF<const char*>, __gnu_cxx::__normal_iterator<char*, std::basic_string<char> > >)>’ 
/usr/include/boost/algorithm/string/iter_find.hpp:77:13: se requiere desde ‘SequenceSequenceT& boost::algorithm::iter_split(SequenceSequenceT&, RangeT&, FinderT) [with SequenceSequenceT = std::vector<std::basic_string<char> >; RangeT = std::basic_string<char>; FinderT = boost::algorithm::detail::token_finderF<const char*>]’ 
/usr/include/boost/algorithm/string/split.hpp:149:69: se requiere desde ‘SequenceSequenceT& boost::algorithm::split(SequenceSequenceT&, RangeT&, PredicateT, boost::algorithm::token_compress_mode_type) [with SequenceSequenceT = std::vector<std::basic_string<char> >; RangeT = std::basic_string<char>; PredicateT = const char*]’ 
../src/Emulator.cpp:23:27: se requiere desde aquí 
/usr/include/boost/algorithm/string/detail/finder.hpp:583:45: error: expression cannot be used as a function 
          while(It2!=End && m_Pred(*It2)) ++It2; 
              ^
In file included from /usr/include/c++/4.8.3/algorithm:62:0, 
       from /usr/include/c++/4.8.3/ext/slist:47, 
       from /usr/include/boost/algorithm/string/std/slist_traits.hpp:16, 
       from /usr/include/boost/algorithm/string/std_containers_traits.hpp:23, 
       from /root/boost/boost/algorithm/string.hpp:18, 
       from ../src/Emulator.cpp:12: 
/usr/include/c++/4.8.3/bits/stl_algo.h: En la instanciación de ‘_RandomAccessIterator std::__find_if(_RandomAccessIterator, _RandomAccessIterator, _Predicate, std::random_access_iterator_tag) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<char*, std::basic_string<char> >; _Predicate = const char*]’: 
/usr/include/c++/4.8.3/bits/stl_algo.h:4465:41: se requiere desde ‘_IIter std::find_if(_IIter, _IIter, _Predicate) [with _IIter = __gnu_cxx::__normal_iterator<char*, std::basic_string<char> >; _Predicate = const char*]’ 
/usr/include/boost/algorithm/string/detail/finder.hpp:570:74: se requiere desde ‘boost::iterator_range<Iterator> boost::algorithm::detail::token_finderF<PredicateT>::operator()(ForwardIteratorT, ForwardIteratorT) const [with ForwardIteratorT = __gnu_cxx::__normal_iterator<char*, std::basic_string<char> >; PredicateT = const char*]’ 
/usr/include/boost/algorithm/string/concept.hpp:43:28: se requiere desde ‘void boost::algorithm::FinderConcept<FinderT, IteratorT>::constraints() [with FinderT = boost::algorithm::detail::token_finderF<const char*>; IteratorT = __gnu_cxx::__normal_iterator<char*, std::basic_string<char> >]’ 
/usr/include/boost/concept/detail/has_constraints.hpp:32:62: se requiere para la sustitución de ‘template<class Model> boost::concepts::detail::yes boost::concepts::detail::has_constraints_(Model*, boost::concepts::detail::wrap_constraints<Model, (& Model:: constraints)>*) [with Model = boost::algorithm::FinderConcept<boost::algorithm::detail::token_finderF<const char*>, __gnu_cxx::__normal_iterator<char*, std::basic_string<char> > >]’ 
/usr/include/boost/concept/detail/has_constraints.hpp:42:5: se requiere desde ‘const bool boost::concepts::not_satisfied<boost::algorithm::FinderConcept<boost::algorithm::detail::token_finderF<const char*>, __gnu_cxx::__normal_iterator<char*, std::basic_string<char> > > >::value’ 
/usr/include/boost/concept/detail/has_constraints.hpp:45:31: se requiere desde ‘struct boost::concepts::not_satisfied<boost::algorithm::FinderConcept<boost::algorithm::detail::token_finderF<const char*>, __gnu_cxx::__normal_iterator<char*, std::basic_string<char> > > >’ 
/usr/include/boost/mpl/if.hpp:67:11: se requiere desde ‘struct boost::mpl::if_<boost::concepts::not_satisfied<boost::algorithm::FinderConcept<boost::algorithm::detail::token_finderF<const char*>, __gnu_cxx::__normal_iterator<char*, std::basic_string<char> > > >, boost::concepts::constraint<boost::algorithm::FinderConcept<boost::algorithm::detail::token_finderF<const char*>, __gnu_cxx::__normal_iterator<char*, std::basic_string<char> > > >, boost::concepts::requirement<boost::concepts::failed************ boost::algorithm::FinderConcept<boost::algorithm::detail::token_finderF<const char*>, __gnu_cxx::__normal_iterator<char*, std::basic_string<char> > >::************> >’ 
/usr/include/boost/concept/detail/general.hpp:50:8: se requiere desde ‘struct boost::concepts::requirement_<void (*)(boost::algorithm::FinderConcept<boost::algorithm::detail::token_finderF<const char*>, __gnu_cxx::__normal_iterator<char*, std::basic_string<char> > >)>’ 
/usr/include/boost/algorithm/string/iter_find.hpp:77:13: se requiere desde ‘SequenceSequenceT& boost::algorithm::iter_split(SequenceSequenceT&, RangeT&, FinderT) [with SequenceSequenceT = std::vector<std::basic_string<char> >; RangeT = std::basic_string<char>; FinderT = boost::algorithm::detail::token_finderF<const char*>]’ 
/usr/include/boost/algorithm/string/split.hpp:149:69: se requiere desde ‘SequenceSequenceT& boost::algorithm::split(SequenceSequenceT&, RangeT&, PredicateT, boost::algorithm::token_compress_mode_type) [with SequenceSequenceT = std::vector<std::basic_string<char> >; RangeT = std::basic_string<char>; PredicateT = const char*]’ 
../src/Emulator.cpp:23:27: se requiere desde aquí 
/usr/include/c++/4.8.3/bits/stl_algo.h:214:23: error: ‘__pred’ cannot be used as a function 
    if (__pred(*__first)) 
        ^
/usr/include/c++/4.8.3/bits/stl_algo.h:218:23: error: ‘__pred’ cannot be used as a function 
    if (__pred(*__first)) 
        ^
/usr/include/c++/4.8.3/bits/stl_algo.h:222:23: error: ‘__pred’ cannot be used as a function 
    if (__pred(*__first)) 
        ^
/usr/include/c++/4.8.3/bits/stl_algo.h:226:23: error: ‘__pred’ cannot be used as a function 
    if (__pred(*__first)) 
        ^
/usr/include/c++/4.8.3/bits/stl_algo.h:234:23: error: ‘__pred’ cannot be used as a function 
    if (__pred(*__first)) 
        ^
/usr/include/c++/4.8.3/bits/stl_algo.h:238:23: error: ‘__pred’ cannot be used as a function 
    if (__pred(*__first)) 
        ^
/usr/include/c++/4.8.3/bits/stl_algo.h:242:23: error: ‘__pred’ cannot be used as a function 
    if (__pred(*__first)) 
        ^
make: *** [src/Emulator.o] Error 1 

16:26:04 Build Finished (took 11s.425ms) 

И когда я использую другую библиотеку (iostream, вектор, строка, fstream ...), он говорит, что Eclipse не смог найти эту библиотеку, но если я скомпилирую ее без заголовка boost, это сработает. Это мой код:

//============================================================================ 
// Name  : Emulator.cpp 
// Author  : Manulaiko 
// Version  : 1.0 
// Description : SpaceBattles' emulator main file 
//============================================================================ 

#include <iostream> 
#include <fstream> 
#include <string> 
#include <vector> 
#include "/root/boost/boost/algorithm/string.hpp" 

using namespace std; 

void loadConfig() 
{ 
    ifstream file("settings"); 
    string s; 

    while(getline(file, s)) { 
     vector<string> line; 
     boost::split(line, s,"="); 

     //Test 
     cout << line[0] << " = " << line[1] << endl; 
    } 
} 

void connect() 
{ 

} 

int main() { 
    cout << "SpaceBattles C++ emulator 1.0 by Manulaiko" << endl; 
    cout << endl; 

    cout << "Reading settings file..." << endl; 
    loadConfig(); 

    cout << "Establishing connection to MySQL..." << endl; 
    connect(); 
} 
+0

не знал, что локализованные версии GCC существуют. – Drop

+0

Вы проверили документацию «boost :: split» или примеры? – MatthiasB

+0

@ πάνταῥεῖ Я вижу сейчас. Это намного хуже;) – Drop

ответ

0

Третьи пары в boost::split() должны быть функция (или «отозван»), а не строка. Попробуйте

boost::split(line, s, boost::is_any_of("=")); 

is_any_of() на самом деле конструктор, но он создает объект, который может быть назван как функция.

Существует, вероятно, что-то лучше, чем is_any_of (то есть что-то вроде is_equal), но я вытащил его прямо из документации: http://www.boost.org/doc/libs/1_56_0/doc/html/string_algo/usage.html#idp432343152

Смежные вопросы