Agg_Concatenate not compiling in 9.3
Hi,We have upgraded our vertica to 9.3 version and when compiling the Agg_Concatenate function(Concatenate.cpp) it is giving compile error which is running fine in Vertica 9.2.Below are the errors,Any suggestion.
$ g++ -D HAVE_LONG_INT_64 -I /opt/vertica/sdk/include -Wall -shared -Wno-unused-value -fPIC -o /opt/app/vertica/sdk/examples/AggregateFunctions/Concatenate.so Concatenate.cpp /opt/vertica/sdk/include/Vertica.cpp
In file included from /opt/vertica/sdk/include/Vertica.h:74:0,
from Concatenate.cpp:7:
/opt/vertica/sdk/include/BuildAssertions.h:48:10: error: #error "Vertica requires C++11 compatibility."
#error "Vertica requires C++11 compatibility."
^
In file included from /usr/include/c++/4.8.2/atomic:38:0,
from /opt/vertica/sdk/include/VerticaUDx.h:62,
from /opt/vertica/sdk/include/Vertica.h:76,
from Concatenate.cpp:7:
/usr/include/c++/4.8.2/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support for the \
^
In file included from /usr/include/c++/4.8.2/atomic:41:0,
from /opt/vertica/sdk/include/VerticaUDx.h:62,
from /opt/vertica/sdk/include/Vertica.h:76,
from Concatenate.cpp:7:
/usr/include/c++/4.8.2/bits/atomic_base.h:70:3: error: ‘constexpr’ does not name a type
constexpr memory_order
^
/usr/include/c++/4.8.2/bits/atomic_base.h:70:3: note: C++11 ‘constexpr’ only available with -std=c++11 or -std=gnu++11
/usr/include/c++/4.8.2/bits/atomic_base.h:76:3: error: ‘constexpr’ does not name a type
constexpr memory_order
Best Answers
-
Bryan_H Vertica Employee Administrator
What version of g++ is installed? Be sure it is recent enough to include C++11 support, e.g.
$ g++ --version
g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39)6 -
LenoyJ - Select Field - Employee
It works for me:
As @Bryan_H said - it looks like you may need to upgrade you g++ version. According to https://www.vertica.com/docs/9.3.x/HTML/Content/Authoring/ExtendingVertica/UDx/DevEnvironment.htmVertica requires a minimum of gcc version 4.8.4 and a maximum version of 7.3. The default versions of g++ on Amazon Linux 2.0 and Ubuntu 16.04 are not compatible.
On a side note, agg_concatenate sounds similar to the built-in function listagg - you may not need a UDx after all.
dbadmin=> select id, agg_concatenate(name || ',') ag from mytable group by 1; id | ag ----+----------- 1 | AA, 2 | AB,AC, 3 | AF,AE,AD, (3 rows)
versus:
dbadmin=> select id, listagg(name) ag from mytable group by 1; id | ag ----+---------- 1 | AA 2 | AB,AC 3 | AF,AE,AD
6
Answers
Basically what the error says, try adding
-std=c++11
or-std=gnu++11
to the compiler options.More info on what changed in UDx development in 9.3:
https://www.vertica.com/docs/9.3.x/HTML/Content/Authoring/NewFeatures/9.3/9.3.0/SDKUpdates.htm
https://www.vertica.com/docs/9.3.x/HTML/Content/Authoring/ExtendingVertica/C++/CompilingC++.htm
Thanks Lenoy..But i have tried with that but giving error.
$ g++ -std=c++11 -D HAVE_LONG_INT_64 -I /opt/vertica/sdk/include -Wall -shared -Wno-unused-value -fPIC -o /opt/vertica/sdk/examples/AggregateFunctions/Concatenate.so Concatenate.cpp /opt/vertica/sdk/include/Vertica.cpp
cc1plus: error: unrecognized command line option "-std=c++11"
cc1plus: error: unrecognized command line option "-std=c++11"
Hi Bryan,The version is one step lower and planning to upgrade.Current version:
$ g++ --version
g++ (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23)
Copyright (C) 2010 Free Software Foundation, Inc.
Could you please tell after the upgrade do i need to add -std=c++11 in g++ command.
thanks
Thanks lenoy and Bryan for sharing,Will update once done with upgrade gcc...thanks again