Skip to content

Error: "no member named 'getenv' in the global namespace" during the compilation with libc++ #19850

@YanzhaoW

Description

@YanzhaoW

Check duplicate issues.

  • Checked for duplicates

Description

Hi,

I'm trying to install ROOT via clang with libc++. The installation failed due to the following error:

[2130/5199] Building CXX object core/foundation/CMakeFiles/Foundation_Stage1.dir/src/FoundationUtils.cxx.o
FAILED: core/foundation/CMakeFiles/Foundation_Stage1.dir/src/FoundationUtils.cxx.o
/usr/bin/clang++-20  -I/home/yanwang/software/src/root/core/foundation/inc -I/home/yanwang/software/src/root/core/foundation/res -I/home/yanwang/software/src/root/core/cont/inc -I/home/yanwang/software/src/root/core/clingutils/res -I/home/yanwang/software/src/root/core/clingutils/inc -I/home/yanwang/software/src/root/core/clib/inc -I/home/yanwang/software/src/root/core/base/inc -I/home/yanwang/software/src/root-build/ginclude -fcolor-diagnostics -Wc++11-narrowing -Wsign-compare -Wsometimes-uninitialized -Wconditional-uninitialized -Wheader-guard -Warray-bounds -Wcomment -Wtautological-compare -Wstrncat-size -Wloop-analysis -Wbool-conversion -pipe  -Wall -W -Woverloaded-virtual -fsigned-char -pthread -stdlib=libc++ -O3 -DNDEBUG -std=c++23 -fPIC -fvisibility-inlines-hidden    -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fno-strict-aliasing -Wwrite-strings -Wno-shadow -Wno-unused-parameter -MD -MT core/foundation/CMakeFiles/Foundation_Stage1.dir/src/FoundationUtils.cxx.o -MF core/foundation/CMakeFiles/Foundation_Stage1.dir/src/FoundationUtils.cxx.o.d -o core/foundation/CMakeFiles/Foundation_Stage1.dir/src/FoundationUtils.cxx.o -c /home/yanwang/software/src/root/core/foundation/src/FoundationUtils.cxx
/home/yanwang/software/src/root/core/foundation/src/FoundationUtils.cxx:167:36: error: no member named 'getenv' in the global namespace
  167 |       if (const char* envValue = ::getenv("ROOTSYS")) {
      |                                  ~~^
1 error generated.

Reproducer

  1. download root source with git:
git clone --branch v6-36-04 --depth=1 https://github.com/root-project/root.git root
  1. run cmake with the configuration:
cmake -Dlibcxx=ON -Dx11=OFF -DCMAKE_CXX_STANDARD=23 -Dbuiltin_vdt=ON -Ddavix=OFF   .

ROOT version

  • ROOT: 6.36.04
  • OS: ubuntu 22.04
  • Compiler: clang 20.1.8
  • CXX: /usr/bin/clang++-20
  • CC: /usr/bin/clang-20

Installation method

From source

Operating system

Ubuntu

Additional context

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions