Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #67810

Re: Trying to be generic with the linker (ld instead of g++)

From Ralf Fassel <ralfixx@gmx.de>
Newsgroups comp.lang.c++
Subject Re: Trying to be generic with the linker (ld instead of g++)
Date 2019-08-20 14:05 +0200
Message-ID <ygao90k59fo.fsf@akutech.de> (permalink)
References <fd41e1db-a2dc-445e-8ecb-f176d3361e03@googlegroups.com>

Show all headers | View raw


* Frederick Gotham <cauldwell.thomas@gmail.com>
| But if you also want to link with the C++ library (including the STL), then in theory you can try something like:
>
| ld -lc -lc++ -o prog *.o
>
| But this doesn't work for me on my 64-Bit x86_64 Ubuntu 18.04 personal
| computer. I've tried a few different switches to get the C++ standard
| library (e.g. lstdc++) but none of them work.
>
| How do you link the C++ standard library in when linking with 'ld' ?

You could run "g++ -v" to see what g++ is doing to get the job done:

    g++ --help
    Usage: g++ [options] file...
    Options:
--<snip-snip>--
    -v                       Display the programs invoked by the compiler.

But the main question would be: why would you want to run ld directly?

I'd rather do

  g++ -o prog prog.cxx

than some (probably version depended) magic...

R'

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Trying to be generic with the linker (ld instead of g++) Frederick Gotham <cauldwell.thomas@gmail.com> - 2019-08-20 04:09 -0700
  Re: Trying to be generic with the linker (ld instead of g++) Bart <bc@freeuk.com> - 2019-08-20 12:25 +0100
    Re: Trying to be generic with the linker (ld instead of g++) Frederick Gotham <cauldwell.thomas@gmail.com> - 2019-08-20 04:34 -0700
      Re: Trying to be generic with the linker (ld instead of g++) Chris Vine <chris@cvine--nospam--.freeserve.co.uk> - 2019-08-21 01:07 +0100
    Re: Trying to be generic with the linker (ld instead of g++) Keith Thompson <kst-u@mib.org> - 2019-08-20 15:50 -0700
      Re: Trying to be generic with the linker (ld instead of g++) Bart <bc@freeuk.com> - 2019-08-21 00:27 +0100
  Re: Trying to be generic with the linker (ld instead of g++) Ralf Fassel <ralfixx@gmx.de> - 2019-08-20 14:05 +0200
  Re: Trying to be generic with the linker (ld instead of g++) David Brown <david.brown@hesbynett.no> - 2019-08-20 14:10 +0200
  Re: Trying to be generic with the linker (ld instead of g++) Keith Thompson <kst-u@mib.org> - 2019-08-20 15:58 -0700
  Re: Trying to be generic with the linker (ld instead of g++) Tim Rentsch <tr.17687@z991.linuxsc.com> - 2019-08-22 04:47 -0700
    Don't extensions still work? (Was: Trying to be generic with the linker (ld instead of g++)) gazelle@shell.xmission.com (Kenny McCormack) - 2019-08-22 12:12 +0000
      Re: Don't extensions still work? (Was: Trying to be generic with the linker (ld instead of g++)) David Brown <david.brown@hesbynett.no> - 2019-08-22 15:08 +0200
      Re: Don't extensions still work? (Was: Trying to be generic with the linker (ld instead of g++)) Tim Rentsch <tr.17687@z991.linuxsc.com> - 2019-08-22 12:57 -0700

csiph-web