abseil/abseil-cpp

error: no type named 'string_view' in namespace 'absl'

Closed this issue · 2 comments

Describe the issue

I got an error during the building program module on Fedora 39

Compiling cphonenumber.cpp
clang -std=c++11 -fPIC -DPIC -g -funroll-loops -Wcast-align -pthread -DKSR_PTHREAD_MUTEX_SHARED -Wall -Wno-write-strings -Wno-deprecated -Wno-unused-function -Wno-sign-compare -Wno-strict-aliasing -fPIC -DPIC -g -funroll-loops -Wcast-align -pthread -DKSR_PTHREAD_MUTEX_SHARED -Wall  -DNAME='"kamailio"' -DVERSION='"5.7.2"' -DARCH='"x86_64"' -DOS='linux_' -DOS_QUOTED='"linux"' -DCOMPILER='"gcc 13.2.1"' -D__CPU_x86_64 -D__OS_linux -DVERSIONVAL=5007002 -DCFG_DIR='"/etc/kamailio/"' -DSHARE_DIR='"/usr/share/kamailio/"' -DRUN_DIR='"/var/run/kamailio/"' -DPKG_MALLOC -DSHM_MMAP -DDNS_IP_HACK -DUSE_MCAST -DUSE_TCP -DDISABLE_NAGLE -DHAVE_RESOLV_RES -DUSE_DNS_CACHE -DUSE_DNS_FAILOVER -DUSE_DST_BLOCKLIST -DUSE_NAPTR -DWITH_XAVP -DMEM_JOIN_FREE -DF_MALLOC -DQ_MALLOC -DTLSF_MALLOC -DDBG_SR_MEMORY -DUSE_TLS -DTLS_HOOKS -DUSE_CORE_STATS -DSTATISTICS -DMALLOC_STATS -DUSE_SCTP -DFAST_LOCK -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 -DCC_GCC_LIKE_ASM -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD -DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H -DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER -DHAVE_IP_MREQN -DUSE_RAW_SOCKS -DHAVE_EPOLL -DHAVE_SIGIO_RT -DSIGINFO64_WORKAROUND -DUSE_FUTEX -DHAVE_SELECT  -I/usr/local/include -DMOD_NAME='"phonenum"' -c cphonenumber.cpp -o cphonenumber.o
In file included from cphonenumber.cpp:24:
In file included from /usr/include/phonenumbers/geocoding/phonenumber_offline_geocoder.h:24:
In file included from /usr/include/absl/synchronization/mutex.h:67:
In file included from /usr/include/absl/base/const_init.h:25:
In file included from /usr/include/absl/base/config.h:86:
/usr/include/absl/base/policy_checks.h:79:2: error: "C++ versions less than C++14 are not supported."
   79 | #error "C++ versions less than C++14 are not supported."
      |  ^
In file included from cphonenumber.cpp:24:
In file included from /usr/include/phonenumbers/geocoding/phonenumber_offline_geocoder.h:24:
In file included from /usr/include/absl/synchronization/mutex.h:74:
In file included from /usr/include/absl/synchronization/internal/kernel_timeout.h:30:
In file included from /usr/include/absl/time/clock.h:26:
In file included from /usr/include/absl/time/time.h:89:
/usr/include/absl/strings/string_view.h:52:26: error: no type named 'string_view' in namespace 'std'
   52 | using string_view = std::string_view;
      |                     ~~~~~^
/usr/include/absl/strings/string_view.h:686:8: error: unknown type name 'string_view'
  686 | inline string_view ClippedSubstr(string_view s, size_t pos,
      |        ^
/usr/include/absl/strings/string_view.h:686:34: error: unknown type name 'string_view'
  686 | inline string_view ClippedSubstr(string_view s, size_t pos,
      |                                  ^
/usr/include/absl/strings/string_view.h:687:45: error: use of undeclared identifier 'string_view'
  687 |                                  size_t n = string_view::npos) {
      |                                             ^
/usr/include/absl/strings/string_view.h:697:11: error: unknown type name 'string_view'
  697 | constexpr string_view NullSafeStringView(const char* p) {
      |           ^
/usr/include/absl/strings/string_view.h:698:14: error: use of undeclared identifier 'string_view'
  698 |   return p ? string_view(p) : string_view();
      |              ^
/usr/include/absl/strings/string_view.h:698:31: error: use of undeclared identifier 'string_view'
  698 |   return p ? string_view(p) : string_view();
      |                               ^
In file included from cphonenumber.cpp:24:
In file included from /usr/include/phonenumbers/geocoding/phonenumber_offline_geocoder.h:24:
In file included from /usr/include/absl/synchronization/mutex.h:74:
In file included from /usr/include/absl/synchronization/internal/kernel_timeout.h:30:
In file included from /usr/include/absl/time/clock.h:26:
In file included from /usr/include/absl/time/time.h:90:
/usr/include/absl/time/civil_time.h:489:27: error: no type named 'string_view' in namespace 'absl'
  489 | bool ParseCivilTime(absl::string_view s, CivilSecond* c);
      |                     ~~~~~~^
/usr/include/absl/time/civil_time.h:490:27: error: no type named 'string_view' in namespace 'absl'
  490 | bool ParseCivilTime(absl::string_view s, CivilMinute* c);
      |                     ~~~~~~^
/usr/include/absl/time/civil_time.h:491:27: error: no type named 'string_view' in namespace 'absl'
  491 | bool ParseCivilTime(absl::string_view s, CivilHour* c);
      |                     ~~~~~~^
/usr/include/absl/time/civil_time.h:492:27: error: no type named 'string_view' in namespace 'absl'
  492 | bool ParseCivilTime(absl::string_view s, CivilDay* c);
      |                     ~~~~~~^
/usr/include/absl/time/civil_time.h:493:27: error: no type named 'string_view' in namespace 'absl'
  493 | bool ParseCivilTime(absl::string_view s, CivilMonth* c);
      |                     ~~~~~~^
/usr/include/absl/time/civil_time.h:494:27: error: no type named 'string_view' in namespace 'absl'
  494 | bool ParseCivilTime(absl::string_view s, CivilYear* c);
      |                     ~~~~~~^
/usr/include/absl/time/civil_time.h:509:34: error: no type named 'string_view' in namespace 'absl'
  509 | bool ParseLenientCivilTime(absl::string_view s, CivilSecond* c);
      |                            ~~~~~~^
/usr/include/absl/time/civil_time.h:510:34: error: no type named 'string_view' in namespace 'absl'
  510 | bool ParseLenientCivilTime(absl::string_view s, CivilMinute* c);
      |                            ~~~~~~^
/usr/include/absl/time/civil_time.h:511:34: error: no type named 'string_view' in namespace 'absl'
  511 | bool ParseLenientCivilTime(absl::string_view s, CivilHour* c);
      |                            ~~~~~~^
/usr/include/absl/time/civil_time.h:512:34: error: no type named 'string_view' in namespace 'absl'
  512 | bool ParseLenientCivilTime(absl::string_view s, CivilDay* c);
      |                            ~~~~~~^
/usr/include/absl/time/civil_time.h:513:34: error: no type named 'string_view' in namespace 'absl'
  513 | bool ParseLenientCivilTime(absl::string_view s, CivilMonth* c);
      |                            ~~~~~~^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [Makefile:21: cphonenumber.o] Error 1
make[1]: *** [Makefile:508: modules] Error 1
make[1]: Leaving directory '/root/tools/rpmbuild/BUILD/kamailio-5.7.2/src'
make: *** [Makefile:34: every-module] Error 2

Steps to reproduce the problem

Build kamailio phonenum module on Fedora 39
https://github.com/kamailio/kamailio/tree/master/src/modules/phonenum

What version of Abseil are you using?

abseil-cpp-20230802.1-1.fc39.x86_64
abseil-cpp-testing-20230802.1-1.fc39.x86_64
abseil-cpp-devel-20230802.1-1.fc39.x86_64

What operating system and version are you using?

Fedora 39

What compiler and version are you using?

clang-resource-filesystem-17.0.4-1.fc39.noarch
clang-libs-17.0.4-1.fc39.x86_64
clang-17.0.4-1.fc39.x86_64
```

### What build system are you using?

To bulid Kamailio used Makefiles

### Additional context

The same module compiled properly on Fedora 38.
A probable issue happens after devel files update.

From your log:

clang -std=c++11

...

   79 | #error "C++ versions less than C++14 are not supported."
      |  ^

You are trying to build in C++11 mode when you need at least C++14.

Thanks @derekmauro, I have used -std=c++17 and this solved program build.