Hi, Im a curious beginner, and Im struggling to compile my first program.

As per the title, even after changing env variables CHPL_LLVM to either system or bundled. Im still getting either the errors "/usr/bin/ld: cannot find -lstdc++: No such file or directory" OR "error: Make Binary - Linking"

Is this an issue when trying to use an installed Chapel? Or an issue building Chapel itself. I am assuming the former.

Can you send the output of printchplenv --all and printchplenv --verify-verbose, as well as chpl examples/hello.chpl --print-commands

-Jade

1 Like

Thanks for taking the time to reply:
I actually installed using sudo apt install, since I was only curious, there would be no need for source build

Output of $CHPL_HOME/util/printchplenv --all

machine info: Linux ardie-ThinkPad-T440 5.15.0-194-generic #204-Ubuntu SMP Wed Sep 2 13:09:23 UTC 2026 x86_64
CHPL_HOME: /usr/share/chapel/2.10 *
script location: /usr/share/chapel/2.10/util/chplenv
CHPL_HOST_PLATFORM: linux64 +
CHPL_HOST_COMPILER: gnu
CHPL_HOST_CC: gcc
CHPL_HOST_CXX: g++
CHPL_HOST_ARCH: x86_64
CHPL_TARGET_PLATFORM: linux64 +
CHPL_TARGET_COMPILER: llvm +
CHPL_TARGET_CC: /usr/lib/llvm-15/bin/clang
CHPL_TARGET_CXX: /usr/lib/llvm-15/bin/clang++
CHPL_TARGET_LD: /usr/lib/llvm-15/bin/clang++
CHPL_TARGET_ARCH: x86_64
CHPL_TARGET_CPU: native +
CHPL_LOCALE_MODEL: flat +
CHPL_COMM: none +
CHPL_TASKS: qthreads +
CHPL_LAUNCHER: none
CHPL_TIMERS: generic
CHPL_UNWIND: system +
CHPL_HOST_MEM: jemalloc +
CHPL_HOST_JEMALLOC: bundled
CHPL_TARGET_MEM: jemalloc +
CHPL_TARGET_JEMALLOC: bundled
CHPL_ATOMICS: cstdlib +
CHPL_GMP: system +
CHPL_HWLOC: system +
CHPL_RE2: bundled +
CHPL_LLVM: system +
CHPL_LLVM_SUPPORT: system
CHPL_LLVM_CONFIG: llvm-config-15
CHPL_LLVM_VERSION: 15
CHPL_AUX_FILESYS: none
CHPL_LIB_PIC: none +
CHPL_SANITIZE: none +
CHPL_SANITIZE_EXE: none +

machine info: Linux ardie-ThinkPad-T440 5.15.0-194-generic #204-Ubuntu SMP Wed Sep 2 13:09:23 UTC 2026 x86_64
CHPL_HOME: /usr/share/chapel/2.10 *
script location: /usr/share/chapel/2.10/util/chplenv
CHPL_HOST_PLATFORM: linux64 +
CHPL_HOST_COMPILER: gnu
CHPL_HOST_CC: gcc
CHPL_HOST_CXX: g++
CHPL_HOST_ARCH: x86_64
CHPL_TARGET_PLATFORM: linux64 +
CHPL_TARGET_COMPILER: llvm +
CHPL_TARGET_CC: /usr/lib/llvm-15/bin/clang
CHPL_TARGET_CXX: /usr/lib/llvm-15/bin/clang++
CHPL_TARGET_LD: /usr/lib/llvm-15/bin/clang++
CHPL_TARGET_ARCH: x86_64
CHPL_TARGET_CPU: native +
CHPL_LOCALE_MODEL: flat +
CHPL_COMM: none +
CHPL_TASKS: qthreads +
CHPL_LAUNCHER: none
CHPL_TIMERS: generic
CHPL_UNWIND: system +
CHPL_HOST_MEM: jemalloc +
CHPL_HOST_JEMALLOC: bundled
CHPL_TARGET_MEM: jemalloc +
CHPL_TARGET_JEMALLOC: bundled
CHPL_ATOMICS: cstdlib +
CHPL_GMP: system +
CHPL_HWLOC: system +
CHPL_RE2: bundled +
CHPL_LLVM: system +
CHPL_LLVM_SUPPORT: system
CHPL_LLVM_CONFIG: llvm-config-15
CHPL_LLVM_VERSION: 15
CHPL_AUX_FILESYS: none
CHPL_LIB_PIC: none +
CHPL_SANITIZE: none +

Output of printchplenv --verify-verbose:

machine info: Linux ardie-ThinkPad-T440 5.15.0-194-generic #204-Ubuntu SMP Wed Sep 2 13:09:23 UTC 2026 x86_64
CHPL_HOME: /usr/share/chapel/2.10 *
script location: /usr/share/chapel/2.10/util/chplenv
CHPL_TARGET_PLATFORM: linux64 +
CHPL_TARGET_COMPILER: llvm +
CHPL_TARGET_ARCH: x86_64
CHPL_TARGET_CPU: native +
CHPL_LOCALE_MODEL: flat +
CHPL_COMM: none +
CHPL_TASKS: qthreads +
CHPL_LAUNCHER: none
CHPL_TIMERS: generic
CHPL_UNWIND: system +
CHPL_TARGET_MEM: jemalloc +
CHPL_ATOMICS: cstdlib +
CHPL_GMP: system +
CHPL_HWLOC: system +
CHPL_RE2: bundled +
CHPL_LLVM: system +
CHPL_AUX_FILESYS: none
Running verification pass TestHostCompile
Trying to compile with 'g++ /tmp/tmpgb8dsjvt/tmpzf13kk3b.cpp -o /tmp/tmpgb8dsjvt/a.out'
Trying to run with '/tmp/tmpgb8dsjvt/a.out'
Running verification pass TestTargetCompileCC
Trying to compile with '/usr/lib/llvm-15/bin/clang /tmp/tmpjemk97hg/tmpg4_yld_s.c -o /tmp/tmpjemk97hg/a.out'
Trying to run with '/tmp/tmpjemk97hg/a.out'
Running verification pass TestTargetCompileCXX
Trying to compile with '/usr/lib/llvm-15/bin/clang++ /tmp/tmplp2o8zu8/tmpeyrlggny.cpp -o /tmp/tmplp2o8zu8/a.out'

Error: Verification failed: Failed to compile program: /tmp/tmplp2o8zu8/tmpeyrlggny.cpp:2:10: fatal error: 'iostream' file not found
#include
^~~~~~~~~~
1 error generated.

Output of chpl hello-world.chpl --print-comand:

invoking driver compilation phase

chpl --driver-compilation-phase --driver-tmp-dir /tmp/chpl-ardie.deleteme-EsnEF6 hello-world.chpl --print-commands
-I/usr/share/chapel/2.10/modules/standard -I/usr/share/chapel/2.10/modules/packages -I/usr/lib/chapel/2.10/runtime/include/localeModels/flat -I/usr/lib/chapel/2.10/runtime/include/localeModels -I/usr/lib/chapel/2.10/runtime/include/comm/none -I/usr/lib/chapel/2.10/runtime/include/comm -I/usr/lib/chapel/2.10/runtime/include/tasks/qthreads -I/usr/lib/chapel/2.10/runtime/include -I/usr/lib/chapel/2.10/runtime/include/qio -I/usr/lib/chapel/2.10/runtime/include/atomics/cstdlib -I/usr/lib/chapel/2.10/runtime/include/mem/jemalloc -I/usr/lib/chapel/2.10/third-party/utf8-decoder -DCHPL_JEMALLOC_PREFIX=chpl_je_ -I/usr/lib/chapel/2.10/third-party/qthread/install/linux64-x86_64-none-llvm-none-flat-jemalloc-system/include -I/usr/lib/chapel/2.10/third-party/jemalloc/install/target/linux64-x86_64-none-llvm-none/include -I/usr/lib/chapel/2.10/third-party/re2/install/linux64-x86_64-none-llvm-none/include -iquote. -I/tmp/chpl-ardie.deleteme-EsnEF6 -Werror=pointer-arith -Werror=write-strings -Werror=missing-declarations -Werror=missing-prototypes -Werror=strict-prototypes -Werror=missing-format-attribute -Wno-unused-function -Wno-strict-aliasing -fno-math-errno -I/usr/share/chapel/2.10/modules/internal -DCHPL_GEN_CODE -pthread -I/usr/include/x86_64-linux-gnu -include sys_basic.h -include wctype.h -include ctype.h -include chpl-prginfo.h -include llvm/chapel_libc_wrapper.h

invoking driver makeBinary phase

chpl --driver-makebinary-phase --driver-tmp-dir /tmp/chpl-ardie.deleteme-EsnEF6 hello-world.chpl --print-commands
-I/usr/share/chapel/2.10/modules/standard -I/usr/share/chapel/2.10/modules/packages -I/usr/lib/chapel/2.10/runtime/include/localeModels/flat -I/usr/lib/chapel/2.10/runtime/include/localeModels -I/usr/lib/chapel/2.10/runtime/include/comm/none -I/usr/lib/chapel/2.10/runtime/include/comm -I/usr/lib/chapel/2.10/runtime/include/tasks/qthreads -I/usr/lib/chapel/2.10/runtime/include -I/usr/lib/chapel/2.10/runtime/include/qio -I/usr/lib/chapel/2.10/runtime/include/atomics/cstdlib -I/usr/lib/chapel/2.10/runtime/include/mem/jemalloc -I/usr/lib/chapel/2.10/third-party/utf8-decoder -DCHPL_JEMALLOC_PREFIX=chpl_je_ -I/usr/lib/chapel/2.10/third-party/qthread/install/linux64-x86_64-none-llvm-none-flat-jemalloc-system/include -I/usr/lib/chapel/2.10/third-party/jemalloc/install/target/linux64-x86_64-none-llvm-none/include -I/usr/lib/chapel/2.10/third-party/re2/install/linux64-x86_64-none-llvm-none/include -iquote. -I/tmp/chpl-ardie.deleteme-EsnEF6 -Werror=pointer-arith -Werror=write-strings -Werror=missing-declarations -Werror=missing-prototypes -Werror=strict-prototypes -Werror=missing-format-attribute -Wno-unused-function -Wno-strict-aliasing -fno-math-errno -I/usr/share/chapel/2.10/modules/internal -DCHPL_GEN_CODE -pthread -I/usr/include/x86_64-linux-gnu -include sys_basic.h -include wctype.h -include ctype.h -include chpl-prginfo.h -include llvm/chapel_libc_wrapper.h

Make Binary - Linking

/usr/lib/llvm-15/bin/clang++ /tmp/chpl-ardie.deleteme-EsnEF6/chpl__module.o /usr/lib/chapel/2.10/runtime/lib/linux64/llvm/x86_64/cpu-none/loc-flat/comm-none/tasks-qthreads/tmr-generic/unwind-system/mem-jemalloc/atomics-cstdlib/hwloc-system/re2-bundled/fs-none/lib_pic-none/san-none/main.o -o /tmp/chpl-ardie.deleteme-EsnEF6/hello-world.tmp -L/usr/lib/chapel/2.10/runtime/lib/linux64/llvm/x86_64/cpu-none/loc-flat/comm-none/tasks-qthreads/tmr-generic/unwind-system/mem-jemalloc/atomics-cstdlib/hwloc-system/re2-bundled/fs-none/lib_pic-none/san-none -lchpl-static -L/usr/lib/chapel/2.10/third-party/qthread/install/linux64-x86_64-none-llvm-none-flat-jemalloc-system/lib -Wl,-rpath,/usr/lib/chapel/2.10/third-party/qthread/install/linux64-x86_64-none-llvm-none-flat-jemalloc-system/lib -lqthread -L/usr/lib/chapel/2.10/third-party/jemalloc/install/target/linux64-x86_64-none-llvm-none/lib -ljemalloc -L/usr/lib/chapel/2.10/third-party/re2/install/linux64-x86_64-none-llvm-none/lib -lre2 -Wl,-rpath,/usr/lib/chapel/2.10/third-party/re2/install/linux64-x86_64-none-llvm-none/lib -L/usr/lib/chapel/2.10/runtime/lib/linux64/llvm/x86_64/cpu-none/loc-flat/comm-none/tasks-qthreads/tmr-generic/unwind-system/mem-jemalloc/atomics-cstdlib/hwloc-system/re2-bundled/fs-none/lib_pic-none/san-none -ldl -lhwloc -lunwind -lm -lpthread -lgmp

/usr/bin/ld: cannot find -lstdc++: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)
child process exited with code 1
error: Make Binary - Linking
child process exited with code 1

=========

The hello word file, is just a single writeln()

1 Like

Ah ok great. Its not related to your issue here, but CHPL_LLVM doesn't need to be changed in a linux package install.

I believe the primary problem is that clang++ cannot properly compile C++, which means your C++ compiler is not working right and is why the Chapel install is broken. You can see that in the printchplenv --verify-verbose output. Try the following

# should be /usr/lib/llvm-15/bin/clang++, just double checking
which clang++
/usr/lib/llvm-15/bin/clang++ -v
cat > hello.cpp << EOF
#include <iostream>
int main() {
    std::cout << "Hello, World!" << std::endl; 
    return 0;
}
EOF
/usr/lib/llvm-15/bin/clang++ -v hello.cpp -o hello
./hello

Can you also share which OS and which OS package you are using? Based on that output, it looks like Ubuntu 22 and the Ubuntu 22 package?

-Jade

2 Likes

Thanks Jade for your time and helpful messages.

Turns out I just needed to: sudo apt install g++-12

I found the Stack Overflow link here that explains it. Ubuntu 22 ships with gcc 12 which messes with clang.

Im only ever familiar with gcc, not clang++ or g++ and what makes or breaks it.

Thanks again.

1 Like

Awesome, glad its working now! Let us know if you need any more assistance.

-Jade