title: Installed g++ with miniconda/conda-forge, can't compile hello world
body: <p>This has something to do with a misconfiguration, but this is a brand new computer installed purely through miniconda/conda-forge, so it should work.</p>
  <p>My miniconda configuration is super-simple: <code>conda-forge</code> is the only channel other than defaults (<code>~/.condarc</code>):</p>
  <pre><code>changeps1: false
  channels:
    - conda-forge
    - defaults
  </code></pre>
  <p>It's up-to-date (<code>conda update --all</code>).</p>
  <p>The GNU C, C++, and Fortran compilers have been installed through the <a href="https://docs.conda.io/projects/conda-build/en/latest/resources/compiler-tools.html" rel="nofollow noreferrer">post-5.0 compiler environment</a>. Here are listings of <code>conda list linux</code>:</p>
  <pre><code># packages in environment at /home/jpivarski/miniconda3:
  #
  # Name                    Version                   Build  Channel
  binutils_impl_linux-64    2.36.1               h193b22a_2    conda-forge
  binutils_linux-64         2.36                hf3e587d_33    conda-forge
  gcc_impl_linux-64         9.3.0               h6df7d76_17  
  gcc_linux-64              9.3.0               hf25ea35_33    conda-forge
  gfortran_impl_linux-64    9.3.0               hc4a2995_19    conda-forge
  gfortran_linux-64         9.3.0               hdc58fab_33    conda-forge
  gxx_impl_linux-64         9.3.0               hbdd7822_17  
  gxx_linux-64              9.3.0               h3fbe746_33    conda-forge
  kernel-headers_linux-64   2.6.32              he073ed8_14    conda-forge
  ld_impl_linux-64          2.36.1               hea4e1c9_2    conda-forge
  libgcc-devel_linux-64     9.3.0               hb95220a_17  
  libstdcxx-devel_linux-64  9.3.0               hf0c5c8d_17  
  sysroot_linux-64          2.12                he073ed8_14    conda-forge
  </code></pre>
  <p>and <code>conda list compiler</code>:</p>
  <pre><code># packages in environment at /home/jpivarski/miniconda3:
  #
  # Name                    Version                   Build  Channel
  c-compiler                1.2.0                h7f98852_0    conda-forge
  compilers                 1.2.0                ha770c72_0    conda-forge
  cxx-compiler              1.2.0                h4bd325d_0    conda-forge
  fortran-compiler          1.2.0                h1990efc_0    conda-forge
  </code></pre>
  <p>and <code>conda list binutil</code>:</p>
  <pre><code># packages in environment at /home/jpivarski/miniconda3:
  #
  # Name                    Version                   Build  Channel
  binutils                  2.36.1               hdd6e379_2    conda-forge
  binutils_impl_linux-64    2.36.1               h193b22a_2    conda-forge
  binutils_linux-64         2.36                hf3e587d_33    conda-forge
  </code></pre>
  <p>This is a Debian system, and it came with a package named <code>gcc-8-base</code> installed,</p>
  <pre><code>gcc-8-base/stable,now 8.3.0-6 amd64 [installed]
  </code></pre>
  <p>but that package didn't add a <code>gcc</code> command to the path, so it's not user-visible. This Debian is in a Crostini VM on a Chromebook (<code>/proc/version</code>):</p>
  <pre><code>Linux version 5.4.119-14943-gff839c7fedcc (chrome-bot@chromeos-ci-legacy-us-east1-d-x32-83-pa8b) (Chromium OS 12.0_pre422132_p20210405-r4 clang version 13.0.0 (/var/tmp/portage/sys-devel/llvm-12.0_pre422132_p20210405-r4/work/llvm-12.0_pre422132_p20210405/clang cd442157cff4aad209ae532cbf031abbe10bc1df)) #1 SMP PREEMPT Wed Jul 28 21:06:01 PDT 2021
  </code></pre>
  <p>Now, the fun part. Here's the simplest C++ program imaginable:</p>
  <pre class="lang-cpp prettyprint-override"><code>// #include &lt;iostream&gt;
  
  int main(int argc, char** argv) {
    int x = 2 + 4;
    // std::cout &lt;&lt; &quot;hello world&quot; &lt;&lt; std::endl;
    return 0;
  }
  </code></pre>
  <p>(Yes, I commented out &quot;hello world&quot; when it didn't work.)</p>
  <p>Compiling it with any of the following:</p>
  <pre class="lang-sh prettyprint-override"><code>g++ tmp.cpp
  g++ -std=c++11 tmp.cpp
  g++ -std=c++11 -lstdc++ tmp.cpp
  </code></pre>
  <p>yields</p>
  <pre><code>/home/jpivarski/miniconda3/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: /home/jpivarski/miniconda3/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/lib/../lib/libstdc++.so: undefined reference to `aligned_alloc@GLIBC_2.16'
  /home/jpivarski/miniconda3/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: /home/jpivarski/miniconda3/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/lib/../lib/libstdc++.so: undefined reference to `clock_gettime@GLIBC_2.17'
  collect2: error: ld returned 1 exit status
  </code></pre>
  <p>Incidentally, with <code>ldd /that/long/path/to/libstdc++.so</code>:</p>
  <pre><code>./../../x86_64-conda-linux-gnu/lib/../lib/libstdc++.so
          linux-vdso.so.1 (0x00007ffd2e8d1000)
          libm.so.6 =&gt; /lib/x86_64-linux-gnu/libm.so.6 (0x00007ef64da8e000)
          libc.so.6 =&gt; /lib/x86_64-linux-gnu/libc.so.6 (0x00007ef64d8cd000)
          /lib64/ld-linux-x86-64.so.2 (0x00007ef64dd92000)
          libgcc_s.so.1 =&gt; /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007ef64d8b3000)
  </code></pre>
  <p>nothing is &quot;not found.&quot;</p>
  <p>I can compile the above program (with commented-out &quot;hello world&quot;) using <code>gcc</code>:</p>
  <pre class="lang-sh prettyprint-override"><code>gcc -std=c++11 tmp.cpp
  </code></pre>
  <p>but if I put the <code>#include &lt;iostream&gt;</code> and <code>std::cout</code> back in, the compiler errors are:</p>
  <pre><code>/home/jpivarski/miniconda3/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: /tmp/cc8BE1Tc.o: warning: relocation against `_ZSt4cout' in read-only section `.text'
  /home/jpivarski/miniconda3/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: /tmp/cc8BE1Tc.o: in function `main':
  tmp.cpp:(.text+0x20): undefined reference to `std::cout'
  /home/jpivarski/miniconda3/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: tmp.cpp:(.text+0x25): undefined reference to `std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;&amp; std::operator&lt;&lt; &lt;std::char_traits&lt;char&gt; &gt;(std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;&amp;, char const*)'
  /home/jpivarski/miniconda3/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: tmp.cpp:(.text+0x2f): undefined reference to `std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;&amp; std::endl&lt;char, std::char_traits&lt;char&gt; &gt;(std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;&amp;)'
  /home/jpivarski/miniconda3/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: tmp.cpp:(.text+0x3a): undefined reference to `std::ostream::operator&lt;&lt;(std::ostream&amp; (*)(std::ostream&amp;))'
  /home/jpivarski/miniconda3/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: /tmp/cc8BE1Tc.o: in function `__static_initialization_and_destruction_0(int, int)':
  tmp.cpp:(.text+0x6a): undefined reference to `std::ios_base::Init::Init()'
  /home/jpivarski/miniconda3/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: tmp.cpp:(.text+0x7f): undefined reference to `std::ios_base::Init::~Init()'
  /home/jpivarski/miniconda3/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: warning: creating DT_TEXTREL in a PIE
  collect2: error: ld returned 1 exit status
  </code></pre>
  <p>How could it have gotten so misconfigured, and how to fix it? This is a <em>fresh installation</em>. Nothing weird has happened yet. If this should be a bug report to conda-forge, I don't know where to post it.</p>