ubuntu - cgi3.2.9 make install 在 ubuntu 18.4 中失败
问题描述
当我安装 cgi 3.2.9 时,它列出了以下错误:
Making install in cgicc make[1]: Entering directory
'/root/learncpp/webprogramming/cgicc-3.2.9/cgicc' /bin/bash
../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I..
-I.. -x c++ -Wall -W -pedantic -g -O2 -MT libcgicc_la-Cgicc.lo -MD -MP -MF .deps/libcgicc_la-Cgicc.Tpo -c -o libcgicc_la-Cgicc.lo `test -f 'Cgicc.cpp' || echo './'`Cgicc.cpp libtool: compile: g++
-DHAVE_CONFIG_H -I. -I.. -I.. -x c++ -Wall -W -pedantic -g -O2 -MT libcgicc_la-Cgicc.lo -MD -MP -MF .deps/libcgicc_la-Cgicc.Tpo -c
Cgicc.cpp -fPIC -DPIC -o .libs/libcgicc_la-Cgicc.o Cgicc.cpp: In
member function ‘bool cgicc::Cgicc::findEntries(const string&, bool,
std::vector<cgicc::FormEntry>&) const’: Cgicc.cpp:328:54: error:
call of overloaded
‘copy_if(std::vector<cgicc::FormEntry>::const_iterator,
std::vector<cgicc::FormEntry>::const_iterator,
std::back_insert_iterator<std::vector<cgicc::FormEntry> >,
cgicc::FE_nameCompare)’ is ambiguous
std::back_inserter(result),FE_nameCompare(param));
^ Cgicc.cpp:99:3: note: candidate: Out cgicc::copy_if(In, In, Out,
Pred) [with In = __gnu_cxx::__normal_iterator<const
cgicc::FormEntry*, std::vector<cgicc::FormEntry> >; Out =
std::back_insert_iterator<std::vector<cgicc::FormEntry> >; Pred =
cgicc::FE_nameCompare] copy_if(In first, ^~~~~~~ In file
included from /usr/include/c++/7/algorithm:62:0,
from Cgicc.cpp:29: /usr/include/c++/7/bits/stl_algo.h:737:5: note: candidate: _OIter
std::copy_if(_IIter, _IIter, _OIter, _Predicate) [with _IIter =
__gnu_cxx::__normal_iterator<const cgicc::FormEntry*, std::vector<cgicc::FormEntry> >; _OIter =
std::back_insert_iterator<std::vector<cgicc::FormEntry> >;
_Predicate = cgicc::FE_nameCompare]
copy_if(_InputIterator __first, _InputIterator __last,
^~~~~~~ Cgicc.cpp:332:56: error: call of overloaded ‘copy_if(std::vector<cgicc::FormEntry>::const_iterator,
std::vector<cgicc::FormEntry>::const_iterator,
std::back_insert_iterator<std::vector<cgicc::FormEntry> >,
cgicc::FE_valueCompare)’ is ambiguous
std::back_inserter(result), FE_valueCompare(param));
^ Cgicc.cpp:99:3: note: candidate: Out cgicc::copy_if(In, In, Out,
Pred) [with In = __gnu_cxx::__normal_iterator<const
cgicc::FormEntry*, std::vector<cgicc::FormEntry> >; Out =
std::back_insert_iterator<std::vector<cgicc::FormEntry> >; Pred =
cgicc::FE_valueCompare] copy_if(In first, ^~~~~~~ In file
included from /usr/include/c++/7/algorithm:62:0,
from Cgicc.cpp:29: /usr/include/c++/7/bits/stl_algo.h:737:5: note: candidate: _OIter
std::copy_if(_IIter, _IIter, _OIter, _Predicate) [with _IIter =
__gnu_cxx::__normal_iterator<const cgicc::FormEntry*, std::vector<cgicc::FormEntry> >; _OIter =
std::back_insert_iterator<std::vector<cgicc::FormEntry> >;
_Predicate = cgicc::FE_valueCompare]
copy_if(_InputIterator __first, _InputIterator __last,
^~~~~~~ Makefile:417: recipe for target 'libcgicc_la-Cgicc.lo' failed make[1]: *** [libcgicc_la-Cgicc.lo] Error 1 make[1]: Leaving
directory '/root/learncpp/webprogramming/cgicc-3.2.9/cgicc'
Makefile:337: recipe for target 'install-recursive' failed make: ***
[install-recursive] Error 1
解决方案
使用 gcc 版本 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04) 编译 cgicc 3.2.9 时我遇到了同样的错误
copy_if 模板是在 C++ 11 及更高版本中定义的,所以我使用以下内容来防止 Cgicc.cpp 中的代码被编译,如果它已经被支持的话:
#if __cplusplus <= 199711L
// ============================================================
// Function copy_if (handy, missing from STL)
// ============================================================
// This code taken directly from
// "The C++ Programming Language, Third Edition" by Bjarne Stroustrup
template<class In, class Out, class Pred>
Out
copy_if(In first,
In last,
Out res,
Pred p)
{
while(first != last) {
if(p(*first))
*res++ = *first;
++first;
}
return res;
}
#endif
它现在工作正常。
推荐阅读
- jxbrowser - JxBrowser onStartLoadingFrame 数据传递问题
- python - python中的None,True,False是什么?
- android - 添加 firebase 后,所有 com.android.support 库必须使用完全相同的版本规范
- arrays - 如何解组结构内的多维数组
- ios - 无法与 iOS 11 SearchController 中的视图交互?
- javascript - 如何在 NODE JS 中使用谷歌方向服务 API 中的折线点计算中点
- cmake - CPack WIX 在安装树之外安装一个文件
- ios - 用户说话时自动开始录音
- postgresql - 如何在 Kubernetes 中为 PostgreSQL 数据使用 PersistentVolume
- c# - 如何在忙碌时显示指示器