Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #82847
| From | Andrey Tarasevich <andreytarasevich@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: g++ and linking |
| Date | 2022-01-22 10:24 -0800 |
| Organization | A noiseless patient Spider |
| Message-ID | <sshi53$6f2$1@dont-email.me> (permalink) |
| References | <nuidnQ-AaOJpFXb8nZ2dnUU7-LfNnZ2d@giganews.com> |
On 1/21/2022 8:32 PM, Joseph Hesse wrote: > Hello, > > Suppose we compile two source files to object files with: > g++ -c -std=c++14 file1.cpp file2.cpp > > Now we link them to an executable. > g++ -o prog -std=c++14 file1.o file2.o > > Since the above is a linker command, do we need the -std=c++14? No and yes. The only conceivable practical reason to do this would be a potential situation where different versions of the language standard required linking in different versions of standard library binaries. This is a reasonable possibility, but AFAIK GCC does not use different libraries for different language standards. Hence: no. Considerations of name mangling or identifier length mentioned by other posters are handled transparently by the linker, in a naturally completely language-agnostic manner. The linker does not need to know what name mangling scheme is used by the compiler proper. So, again: no. But, on the other hand, why do you even care? Who knows what compiler switches `g++` executable uses to form the proper linker command line? And if it doesn't use them today, who knows what compiler switches `g++` executable will use tomorrow to form the proper linker command line? For this reason it kinda makes good sense to just make sure that all `g++` parameters are kept as consistent as possible between `g++` invocations. Just pass'em all and let `g++` itself sort'em out. For this reason: yes. -- Best regards, Andrey Tarasevich
Back to comp.lang.c++ | Previous | Next — Previous in thread | Find similar | Unroll thread
g++ and linking Joseph Hesse <joeh@gmail.com> - 2022-01-22 06:32 +0200
Re: g++ and linking "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2022-01-22 09:39 +0100
Re: g++ and linking Richard Damon <Richard@Damon-Family.org> - 2022-01-22 06:30 -0500
Re: g++ and linking David Brown <david.brown@hesbynett.no> - 2022-01-22 12:53 +0100
Re: g++ and linking Bonita Montero <Bonita.Montero@gmail.com> - 2022-01-22 16:45 +0100
Re: g++ and linking Richard Damon <Richard@Damon-Family.org> - 2022-01-22 11:13 -0500
Re: g++ and linking Bonita Montero <Bonita.Montero@gmail.com> - 2022-01-22 19:00 +0100
Re: g++ and linking Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-02-01 07:17 -0800
Re: g++ and linking "james...@alumni.caltech.edu" <jameskuyper@alumni.caltech.edu> - 2022-02-01 08:19 -0800
Re: g++ and linking Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-04-25 07:19 -0700
Re: g++ and linking "james...@alumni.caltech.edu" <jameskuyper@alumni.caltech.edu> - 2022-04-25 09:06 -0700
Re: g++ and linking Andrey Tarasevich <andreytarasevich@hotmail.com> - 2022-01-22 10:24 -0800
csiph-web