A couple of answers mention the LD_RUNPATH environment variable:
use RPATH but not RUNPATH?
How to blacklist a shared library to avoid it being fetched by the loader?
but I couldn't find any description or official reference, including in the ld(1) and ld.so(8) Linux man pages. It seems that the goal is to have a lower precedence than LD_LIBRARY_PATH, particularly useful under Solaris, where LD_LIBRARY_PATH overrides everything.
A search on Google shows some discussions involving LD_RUNPATH, but nothing concrete. A search on Wikipedia is also unsuccessful. I also did some compilation/run tests with shared libraries under GNU/Linux and Solaris, but couldn't notice any effect.
So, what is this environment variable? Is there any official documentation?
There is no LD_RUNPATH. Most likely this is a typo of LD_RUN_PATH or DT_RUNPATH.
Regarding DT_RUNPATH, TechBlog says:
The DT_RUNPATH value is set with the linker options -rpath (or
LD_RUN_PATH) and the –enable-new-dtags.
Sorry, did not fully understand (or read enough :) ), in the ld(1) manual you have the answer:
LD_RUN_PATH is used to initialise the run path if the -rpath option is not used.
You may find interresting informations on GNU GCC pages or on Linux documentation project.
See:
http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html
Related
I am new to rocket chip,
and I want to ask question.
where can I know what these command can do?
I already knew gcc(c compiler) and objdump(generate assembly code).
what others can do?
Use the standard Linux documentation. So take the name after the common riscv64-unknown-elf prefix and look it up in the manual. Eg...
man as
man ld
man objdump
man run
...etc...
i am using scons for different compilers.
vc10 and renesas compiler.
if i compile the program by using env.program(---) am getting the link flags as
"link /nologo /subsystem:console /pdb:project.pdb /OUT:program.exe D:\build1\subdirA\subdirA.lib D:\build1\subdirB\subdirB.lib main.obj"
it is working for VC10 compiler. But for renesas(my microcontroller) compiler, i am getting an error like
"Cannot open file : "/OUT:program.exe""
it will accept " -output=program.abs" command when linking. how can i change that one. can you please tell me
when program is linking /OUT:program.exe is adding by default.
can you please tell me how to change that to "-output=program.abs"
Thank you
What you want to do is called cross-compile: compile a Renesas binary on Windows. Seems like what you have done is loaded the Windows VC10 toolset in SCons (SCons does this automatically unless told not to) and just changed the compiler binary, so SCons is still using the VC10 compiler/linker flags, which dont seem to be compatible. I had to do something similar once with SCons, where I cross-compiled Cavium Octeon in a Linux environment, but luckily for me almost all of the flags were compatible.
I dont know anything about Renesas, but if its compilation flags are more similar to another platform/toolset, then load those instead of Windows, as follows where Im loading the Linux gcc toolset.
env = Environment(tools = ['gcc'])
Look for Construction Environments in the SCons man page for a complete list of supported tools. Keep in mind that by doing this, you will no longer have support for the native platform toolset, Windows VC10 in your case.
When and if you find a similar platform, and you still need to change some compiler/linker flags or options, take a look at changing the related SCons Construction Variables. A few that could be helpful are: CXXFLAGS, LIBSUFFIX, LINKFLAGS, OBJSUFFIX, and PROGSUFFIX. The LINKFLAGS construction variable is actually the answer to your original question.
I did a google search for scons renesas, and came across this link which might also be helpful.
I'm working on a Firefox plugin that uses external libraries to render 3D graphics on the browser.
The problem is that I want the plugin to use external libraries packed with it without changing the LD_LIBRARY_PATH variable.
The libraries are installed in a position relative to the plugin (a shared library too), while the actual executable (i.e. the browser) can be located somewhere entirely else.
I'm testing it on Ubuntu (no problem at Windows version of the plugin)
My dependencies are OpenSceneGraph libraries and static compilation will make the plugin really big (not an option if there is another one).
Use the rpath option when linking and specify the 'special' path $ORIGIN.
Example:
-Wl,-R,'$ORIGIN/../lib'
Here's a site that elaborates on using $ORIGIN:
http://www.itee.uq.edu.au/~daniel/using_origin/
You could maybe use the -L flag during the compilation to specify the relative path where the linker can find your shared objects.
If you have already generated your lib, you can link by directly invoking the ldcommand.
Tips : You can easily check if some symbols are defined in a lib using the unix command nm. This is a useful way to check that the linking is well-done.
(If I were you, I would just change temporaly the LD_LIBRARY_PATH as you said in your post. Why don't you want to do this ?)
It's wrong to use relative rpath for security reason,
You should use libdl functions (dlopen, etc)
I'm trying to write a configure.ac file such that the resulting configure script searches for a library directory containing a given static library e.g. libsomething.a. How can I do this? At the moment I have it check just one location with:
AC_CHECK_FILE([/usr/local/lib/libsomething.a],[AC_SUBST(libsomething,"-L/usr/local/lib -lsomething")],[AC_SUBST(libcfitsio,'')])
But I want it to try and find it automatically. And if the library isn't in one of the default locations, I'd like configure to say that the library wasn't found and that a custom location can be specified with --use-something=path as is usually done. So I also need to then check if --use-something=path is provided. I'm pretty new at creating configure files, and the M4 documentation isn't very easy to follow, so would appreciate any help.
Thanks!
It's not the job of configure to search where libraries are installed. it should only make sure they are available to the linker. If the user installed them in a different location, he knows how to call ./configure CPPFLAGS=-I/the/location/include LDFLAGS=-L/the/location/lib so that the tools will find the library (this is explained in the --help output of configure and in the standard INSTALL file).
Also --with-package and --enable-package macros are not supposed to be used to specify paths, contrary to what many third-party macros will do. The GNU Coding Standards explicitly prohibit this usage:
Do not use a --with option to
specify the file name to use to find
certain files. That is outside the scope
of what --with options are for.
CPPFLAGS and LDFLAGS are already here to address the problem, so why redevelop and maintain another mechanism?
The best way to figure this out is to look at other autoconf macros that do something similar. Autoconf macros are an amalgam of Bourne shell script and M4 code, so they can literally solve any computable problem.
Here's a link to a macro I wrote for MySQL++ that does this: mysql++.m4.
When I use `man fcntl' got the message:
No manual entry for fcntl
which the pkg is needed to install?
ps. I use debian.
In Debian these man pages are available in manpages-dev package.
This doesn't answer your question directly, but: I myself just use the internet: here is the first search result for "man fcntl" in google.
fcntl is a standard C library function so it should be one of your development packages. However, I long ago gave up on using man on the UNIX boxes themselves, try typing "man fcntl" into Google (with the quotes) to get online versions.
Just don't do this to try and figure out how man itself works. Typing "man man" into Google returns some interesting results (not safe for work).