obtener un programa básico de c++ para compilar usando clang++ en Ubuntu 16
Tengo problemas compilando en Ubuntu 16.04 LTS (servidor). Compila bien si no incluyo el bit -std=c++11
. La versión de Clang es 3.8.
>cat foo.cpp
#include <string>
#include <iostream>
using namespace std;
int main(int argc,char** argv) {
string s(argv[0]);
cout << s << endl;
}
>clang++ -std=c++11 -stdlib=libc++ foo.cpp
In file included from foo.cpp:1:
/usr/include/c++/v1/string:1938:44: error: 'basic_string<_CharT, _Traits, _Allocator>' is missing exception specification
'noexcept(is_nothrow_copy_constructible<allocator_type>::value)'
basic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __a)
^
/usr/include/c++/v1/string:1326:40: note: previous declaration is here
_LIBCPP_INLINE_VISIBILITY explicit basic_string(const allocator_type& __a)
^
1 error generated.
2 answers
Ha instalado libc++-dev
en ubuntu 16.04 con la expectativa (correcta) de que debería
para permitirle construir con clang++
usando libc++
y sus encabezados para su
biblioteca estándar.
debería, pero en presencia de std=c++11
(o estándar posterior),
no lo hace, debido a Debian bug # 808086,
que te has encontrado.
Si desea compilar con clang++
al estándar C++11 o posterior, entonces
hasta que ubuntu obtenga una solución para esto, tendrá que hacerlo sin libc++
, utilizar
libstdc++
(la biblioteca estándar de C++ de GNU) en su lugar, que es el comportamiento predeterminado.
clang++ -std=c++11 foo.cpp
O:
clang++ -std=c++11 -stdlib=libstdc++ foo.cpp
Funcionará.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-05-08 07:24:50
Hasta que se corrija el error de Debian mencionado en la respuesta de Mike Kinghan, simplemente agregar la especificación faltante (pero requerida) noexcept
a la definición de ctor manualmente permite solucionar el problema, es decir, solo podría agregar
#if _LIBCPP_STD_VER <= 14
_NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
#else
_NOEXCEPT
#endif
Después de la línea 1938 de /usr/include/c++/v1/string
.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-07-14 23:59:17