Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between -rpath and -L?

gcc and ld provide many ways to specify a search path for libraries—among them the -rpath and -L flags. The manpages reveal no differences between these two flags, effectively saying each flag adds a library to the library search path. Yet it seems strange that both flags do exactly the same thing. What are the differences, if any, between these two options?

like image 256
Craig M. Brandenburg Avatar asked Dec 12 '11 22:12

Craig M. Brandenburg


People also ask

What's the difference between single and double quotation marks?

General Usage Rules In America, Canada, Australia and New Zealand, the general rule is that double quotes are used to denote direct speech. Single quotes are used to enclose a quote within a quote, a quote within a headline, or a title within a quote.

What's the difference between quotation marks and apostrophes?

But I bet you're curious about how they're different, why else would you be here? The main difference between the two is: Quotation marks are used to report speech. An apostrophe is used for making contractions and possession.

What's the difference between () and []?

() is a tuple: An immutable collection of values, usually (but not necessarily) of different types. [] is a list: A mutable collection of values, usually (but not necessarily) of the same type.

How do you use single quotation marks?

Single quotation marks are also known as 'quote marks', 'quotes', 'speech marks' or 'inverted commas'. Use them to: show direct speech and the quoted work of other writers. enclose the title of certain works.


1 Answers

You must be reading some outdated copies of the manpages (emphasis added):

-rpath=dir
      Add a directory to the runtime library search path. This is used
      when linking an ELF executable with shared objects. All -rpath
      arguments are concatenated and passed to the runtime linker, which
      uses them to locate shared objects at runtime.

vs.

-L searchdir
--library-path=searchdir
      Add path searchdir to the list of paths that ld will search for
      archive libraries and ld control scripts.

So, -L tells ld where to look for libraries to link against when linking. You use this (for example) when you're building against libraries in your build tree, which will be put in the normal system library paths by make install. --rpath, on the other hand, stores that path inside the executable, so that the runtime dynamic linker can find the libraries. You use this when your libraries are outside the system library search path.

like image 185
derobert Avatar answered Oct 15 '22 00:10

derobert