<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Trivial program fails libc++ linkage"
   href="https://bugs.llvm.org/show_bug.cgi?id=48775">48775</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Trivial program fails libc++ linkage
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libc++
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>11.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>planetmarshalluk@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I'm having the following problem compiling a trivial program with clang 11.0.1
and libc++. I suspect it's an environment issue but I'm having trouble tracking
it down. I am running Ubuntu 20.04 LTS

`main.cpp`:

```
#include <iostream>

int main() {
    std::cout << "hello world" << std::endl;
    return 0;
}
```
```
<span class="quote">> clang++ -stdlib=libc++ main.cpp -o main</span >
```

**output**
```
-/usr/bin/ld: cannot find l
clang-11: error: linker command failed with exit code 1 (use -v to see
invocation)
```

Linking to gnu stdlibc++ works as expected.

I installed clang from source with the following configuration:
```
cmake ../llvm \
  -DCMAKE_BUILD_TYPE=Release \
  -DLLVM_ENABLE_PROJECTS=all \
  -DLLVM_ENABLE_OCAMLDOC=False \
  -DLLVM_ENABLE_BINDINGS=False \
  -DLIBCXX_ENABLE_PARALLEL_ALGORITHMS=True \
  -DPSTL_PARALLEL_BACKEND=tbb \
  -DCMAKE_PREFIX_PATH=../../oneTBB/install \
  -DLIBOMPTARGET_NVPTX_ALTERNATE_HOST_COMPILER=gcc-8 \
  -G Ninja
```

The output of
```
clang++ -v -stdlib=libc++ main.cpp -o main
```

is as follows:

```
clang version 11.0.1 (<a href="mailto:git@github.com">git@github.com</a>:llvm/llvm-project.git
43ff75f2c3feef64f9d73328230d34dac8832a91)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Candidate multilib: .;@m64
Selected multilib: .;@m64
Found CUDA installation: /usr/local/cuda-10.2, version 10.2
 "/usr/local/bin/clang-11" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj
-mrelax-all -disable-free -disable-llvm-verifier -discard-value-names
-main-file-name main.cpp -mrelocation-model static -mframe-pointer=all
-fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables
-target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -v
-resource-dir /usr/local/lib/clang/11.0.1 -internal-isystem
/usr/local/bin/../include/c++/v1 -internal-isystem /usr/local/include
-internal-isystem /usr/local/lib/clang/11.0.1/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -fdeprecated-macro
-fdebug-compilation-dir /home/andrew/projects/test -ferror-limit 19
-fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics
-faddrsig -o /tmp/main-0e8b1d.o -x c++ main.cpp
clang -cc1 version 11.0.1 based upon LLVM 11.0.1 default target
x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/bin/../include/c++/v1
 /usr/local/include
 /usr/local/lib/clang/11.0.1/include
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
 "/usr/bin/ld" -z relro --hash-style=gnu --eh-frame-hdr -m elf_x86_64
-dynamic-linker /lib64/ld-linux-x86-64.so.2 -o main
/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crt1.o
/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o
/usr/lib/gcc/x86_64-linux-gnu/9/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/9
-L/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu
-L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu
-L/usr/lib/gcc/x86_64-linux-gnu/9/../../.. -L/usr/local/bin/../lib -L/lib
-L/usr/lib /tmp/main-0e8b1d.o -lc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
/usr/lib/gcc/x86_64-linux-gnu/9/crtend.o
/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o
-/usr/bin/ld: cannot find l
clang-11: error: linker command failed with exit code 1 (use -v to see
invocation)
```</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>