Installing in a file system that does not support symlinks - windows

I have a project using autoconf, automake and libtool. I have configured it with --prefix=/some/directory, and /some/directory is unfortunately mounted on a filesystem that does not support symlinks, resulting in errors.
ln: failed to create symbolic link 'libblas.so': Read-only file system
Is there a way to prevent make install from using symlinks, but rather use copies?

Related

Why can this dynamic library file include all dependencies? [duplicate]

Program is part of the Xenomai test suite, cross-compiled from Linux PC into Linux+Xenomai ARM toolchain.
# echo $LD_LIBRARY_PATH
/lib
# ls /lib
ld-2.3.3.so libdl-2.3.3.so libpthread-0.10.so
ld-linux.so.2 libdl.so.2 libpthread.so.0
libc-2.3.3.so libgcc_s.so libpthread_rt.so
libc.so.6 libgcc_s.so.1 libstdc++.so.6
libcrypt-2.3.3.so libm-2.3.3.so libstdc++.so.6.0.9
libcrypt.so.1 libm.so.6
# ./clocktest
./clocktest: error while loading shared libraries: libpthread_rt.so.1: cannot open shared object file: No such file or directory
Is the .1 at the end part of the filename? What does that mean anyway?
Your library is a dynamic library.
You need to tell the operating system where it can locate it at runtime.
To do so,
we will need to do those easy steps:
Find where the library is placed if you don't know it.
sudo find / -name the_name_of_the_file.so
Check for the existence of the dynamic library path environment variable(LD_LIBRARY_PATH)
echo $LD_LIBRARY_PATH
If there is nothing to be displayed, add a default path value (or not if you wish to)
LD_LIBRARY_PATH=/usr/local/lib
We add the desired path, export it and try the application.
Note that the path should be the directory where the path.so.something is. So if path.so.something is in /my_library/path.so.something, it should be:
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/my_library/
export LD_LIBRARY_PATH
./my_app
Reference to source
Here are a few solutions you can try:
ldconfig
As AbiusX pointed out: If you have just now installed the library, you may simply need to run ldconfig.
sudo ldconfig
ldconfig creates the necessary links and cache to the most recent
shared libraries found in the directories specified on the command
line, in the file /etc/ld.so.conf, and in the trusted directories
(/lib and /usr/lib).
Usually your package manager will take care of this when you install a new library, but not always, and it won't hurt to run ldconfig even if that is not your issue.
Dev package or wrong version
If that doesn't work, I would also check out Paul's suggestion and look for a "-dev" version of the library. Many libraries are split into dev and non-dev packages. You can use this command to look for it:
apt-cache search <libraryname>
This can also help if you simply have the wrong version of the library installed. Some libraries are published in different versions simultaneously, for example, Python.
Library location
If you are sure that the right package is installed, and ldconfig didn't find it, it may just be in a nonstandard directory. By default, ldconfig looks in /lib, /usr/lib, and directories listed in /etc/ld.so.conf and $LD_LIBRARY_PATH. If your library is somewhere else, you can either add the directory on its own line in /etc/ld.so.conf, append the library's path to $LD_LIBRARY_PATH, or move the library into /usr/lib. Then run ldconfig.
To find out where the library is, try this:
sudo find / -iname *libraryname*.so*
(Replace libraryname with the name of your library)
If you go the $LD_LIBRARY_PATH route, you'll want to put that into your ~/.bashrc file so it will run every time you log in:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/library
Update
While what I write below is true as a general answer about shared libraries, I think the most frequent cause of these sorts of message is because you've installed a package, but not installed the -dev version of that package.
Well, it's not lying - there is no libpthread_rt.so.1 in that listing. You probably need to re-configure and re-build it so that it depends on the library you have, or install whatever provides libpthread_rt.so.1.
Generally, the numbers after the .so are version numbers, and you'll often find that they are symlinks to each other, so if you have version 1.1 of libfoo.so, you'll have a real file libfoo.so.1.0, and symlinks foo.so and foo.so.1 pointing to the libfoo.so.1.0. And if you install version 1.1 without removing the other one, you'll have a libfoo.so.1.1, and libfoo.so.1 and libfoo.so will now point to the new one, but any code that requires that exact version can use the libfoo.so.1.0 file. Code that just relies on the version 1 API, but doesn't care if it's 1.0 or 1.1 will specify libfoo.so.1. As orip pointed out in the comments, this is explained well at here.
In your case, you might get away with symlinking libpthread_rt.so.1 to libpthread_rt.so. No guarantees that it won't break your code and eat your TV dinners, though.
You need to ensure that you specify the library path during
linking when you compile your .c file:
gcc -I/usr/local/include xxx.c -o xxx -L/usr/local/lib -Wl,-R/usr/local/lib
The -Wl,-R part tells the resulting binary to also look for the library
in /usr/local/lib at runtime before trying to use the one in /usr/lib/.
Try adding LD_LIBRARY_PATH, which indicates search paths, to your ~/.bashrc file
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path_to_your_library
It works!
The linux.org reference page explains the mechanics, but doesn't explain any of the motivation behind it :-(
For that, see Sun Linker and Libraries Guide
In addition, note that "external versioning" is largely obsolete on Linux, because symbol versioning (a GNU extension) allows you to have multiple incompatible versions of the same function to be present in a single library. This extension allowed glibc to have the same external version: libc.so.6 for the last 10 years.
cd /home/<user_name>/
sudo vi .bash_profile
add these lines at the end
LD_LIBRARY_PATH=/usr/local/lib:<any other paths you want>
export LD_LIBRARY_PATH
Another possible solution depending on your situation.
If you know that libpthread_rt.so.1 is the same as libpthread_rt.so then you can create a symlink by:
ln -s /lib/libpthread_rt.so /lib/libpthread_rt.so.1
Then ls -l /lib should now show the symlink and what it points to.
I had a similar error and it didn't fix with giving LD_LIBRARY_PATH in ~/.bashrc .
What solved my issue is by adding .conf file and loading it.
Go to terminal an be in su.
gedit /etc/ld.so.conf.d/myapp.conf
Add your library path in this file and save.(eg: /usr/local/lib).
You must run the following command to activate path:
ldconfig
Verify Your New Library Path:
ldconfig -v | less
If this shows your library files, then you are good to go.
running:
sudo ldconfig
was enough to fix my issue.
I had this error when running my application with Eclipse CDT on Linux x86.
To fix this:
In Eclipse:
Run as -> Run configurations -> Environment
Set the path
LD_LIBRARY_PATH=/my_lib_directory_path
Wanted to add, if your libraries are in a non standard path, run ldconfig followed by the path.
For instance I had to run:
sudo ldconfig /opt/intel/oneapi/mkl/2021.2.0/lib/intel64
to make R compile against Intel MKL
All I had to do was run:
sudo apt-get install libfontconfig1
I was in the folder located at /usr/lib/x86_64-linux-gnu and it worked perfectly.
Try to install lib32z1:
sudo apt-get install lib32z1
If you are running your application on Microsoft Windows, the path to dynamic libraries (.dll) need to be defined in the PATH environment variable.
If you are running your application on UNIX, the path to your dynamic libraries (.so) need to be defined in the LD_LIBRARY_PATH environment variable.
The error occurs as the system cannot refer to the library file mentioned. Take the following steps:
Running locate libpthread_rt.so.1 will list the path of all the files with that name. Let's suppose a path is /home/user/loc.
Copy the path and run cd home/USERNAME. Replace USERNAME with the name of the current active user with which you want to run the file.
Run vi .bash_profile and at the end of the LD_LIBRARY_PATH parameter, just before ., add the line /lib://home/usr/loc:.. Save the file.
Close terminal and restart the application. It should run.
I got this error and I think its the same reason of yours
error while loading shared libraries: libnw.so: cannot open shared
object file: No such file or directory
Try this. Fix permissions on files:
cd /opt/Popcorn (or wherever it is)
chmod -R 555 * (755 if not ok)
I use Ubuntu 18.04
Installing the corresponding -dev package worked for me,
sudo apt install libgconf2-dev
Before installing the above package, I was getting the below error:
turtl: error while loading shared libraries: libgconf-2.so.4: cannot open shared object file: No such file or directory
I got this error and I think its the same reason of yours
error while loading shared libraries: libnw.so: cannot open shared object
file: No such file or directory
Try this. Fix permissions on files:
sudo su
cd /opt/Popcorn (or wherever it is)
chmod -R 555 * (755 if not ok)
chown -R root:root *
A similar problem can be found here.
I've tried the mentioned solution and it actually works.
The solutions in the previous questions may work. But the following is an easy way to fix it.
It works by reinstalling the package libwbclient
in fedora:
dnf reinstall libwbclient
You can read about libraries here:
https://domiyanyue.medium.com/c-development-tutorial-4-static-and-dynamic-libraries-7b537656163e

Why `make install` is deleting library files *.so generated by `make`?

I am compiling C++ Poco libraries. I do
cmake -DCMAKE_INSTALL_PREFIX=./ -DCMAKE_BUILD_TYPE=Debug ../
make
make install
At make install I get an error
"path/poco/instDir/lib/libPocoEncodingsd.so.60".
Call Stack (most recent call first):
cmake_install.cmake:50 (include)
Makefile:85: recipe for target 'install' failed
make: *** [install] Error
Basically the file libPocoEncodingsd.so.60 is created with make but then make install deletes it.
Why is that?
If I do not run make install the folder inside the installation path is not created and all the *.h files are not copied there.
This happens because:
-DCMAKE_INSTALL_PREFIX=./
means that you are installing over the top of the build directory itself,
with the result that for each filename in the cmake command:
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE SHARED_LIBRARY FILES
"path/poco/instDir/lib/libPocoEncodingsd.so.60"
"path/poco/instDir/lib/libPocoEncodingsd.so"
)
the source and destination files are the same. Cmake preemptively deletes the
destination file to replace it with the source file. Which means it has deleted
the source file. Hence your failure.
This behaviour may be a bug in cmake. On the face of it, if it checks and finds that the
destination file exists and has the same timestamp as the source file, it should consider
the destination file up to date and not attempt to replace it. But I haven't delved into that. Installing on top of your build directory is reasonably classified
under Don't do that.
Conventionally on Unix-like OSes, locally built packages shall be installed to
/usr/local. That's what /usr/local is for. Cmake, like other source package
deployment tools, respects this convention by default. So if you simply run:
cmake -DCMAKE_BUILD_TYPE=Debug ../
make
sudo make install # Or however you run `make install` as root.
then the poco libraries will be installed in /usr/local/lib and the headers
in /usr/local/include/Poco. /usr/local/lib is a default library search path for the
linker and /usr/local/include is a default header search path for the compiler.
If for some reason you don't want to install to the default prefix, then
choose some:
-DCMAKE_INSTALL_PREFIX=/not/in/the/build/dir
and you will avoid this problem.

zeroMQ: cannot open libzmq.so.4

I am trying to install the zeroMQ for my server(redhat 7). Here is what I did:
1) download the zeroMQ and unpack it.
2) navigate to the file where I put the zeroMQ and run the commands below:
./configure
make
make install
Now I can find two head files in /usr/local/include: zmq.h and zmq_utils.h and five files in /usr/local/lib: libzmq.a libzmq.la libzmq.so libzmq.so.4 libzmq.so.4.0.0.
Then I try to code like this:
#include <zmq.h>
...
void * context = zmq_init(1);
But I get this error message: undefined reference to `zmq_init'
I find that the include works well but it cant find 'zmq_init', so maybe it's the problem of lib files. But all of the lib files have been in /usr/local/lib, right?
What should I do?
Problem solved:
I got that error message because the lib files are in the directory: /usr/local/lib
What we need to do is to create a file named local-lib.conf under the directory /etc/ld.so.conf.d/ and write /usr/local/lib in it. The name of the file is not important but its extension must be .conf.
Then, we must navigate to /etc/ld.so.conf.d/ and type this command: sudo ldconfig
I tried the fix provided by #Yves above, but that didn't work out for me so here's another way for Debian/Git installations.
Alternative fix:
I have faced this issue on a Docker container which was occuring due to the libzmq/czmq which was installed by cloning the git repo.
The problem is that the shared libraries when installed using git are located in the /usr/local/lib folder instead of /usr/lib/ where usually, in my case a C/C++ program looks for shared library files.
I fixed it by copying all files from /usr/local/lib folder to/usr/lib/ using the command
$ sudo cp -R /usr/local/lib/* /usr/lib
This was for a RPi/ Ubuntu-16.04 docker, the command or location of the files may vary depending on your OS.

macos - how to tell cabal/ghc to look in /opt for libraries/include files?

I've got the pcre library installed via ports in /opt.
I'm trying to install pcre-light, but cabal install pcre-light reports:
Resolving dependencies...
Configuring pcre-light-0.4...
Preprocessing library pcre-light-0.4...
Base.hsc:103:18: error: pcre.h: No such file or directory
...
pcre.h is located in /opt/local/include
Update: I had trouble linking with the pcre library provided by macports, so I switched over to using home brew.
http://www.haskell.org/ghc/docs/7.0.2/html/Cabal/builders.html
--extra-include-dirs[=dir]
An extra directory to search for C header files. You can use this flag multiple times to get a list of directories.
You might need to use this flag if you have standard system header files in a non-standard location that is not mentioned in the package's .cabal file. Using this option has the same affect as appending the directory dir to the include-dirs field in each library and executable in the package's .cabal file. The advantage of course is that you do not have to modify the package at all. These extra directories will be used while building the package and for libraries it is also saved in the package registration information and used when compiling modules that use the library.

What does /usr/sbin/install really do?

I'm trying to install discount on my VPS which is based on Solaris and compiling works great after setting some environment variables but the install fails.
So I thought I'd do the install manually, but what does install really do? Is it simply a mv followed by a chmod? Is it magic? That error seems to show that it attempts to do a lot of searching for files all over?
Can I just copy the binary, library and header files as usual?
Googling "install" doesn't give me much relevant information so I appreciate any clarification I can get!
According to man install:
install [OPTION]... [-T] SOURCE DEST`
install [OPTION]... SOURCE... DIRECTORY
install [OPTION]... -t DIRECTORY SOURCE...
install [OPTION]... -d DIRECTORY...
In the first three forms, copy SOURCE to DEST or multiple SOURCE(s) to
the existing DIRECTORY, while setting permission modes and owner/group.
In the 4th form, create all components of the given DIRECTORY(ies).
As for the difference to using cp, according to install vs. cp; and mmap, install unlinks the existing file, creating a new one linked to the same spot.
This has the advantage that, if the file you're trying to overwrite is a currently running program, it can continue running, as the file being written is in fact in a new location, and the existing program code is still in the old one.
A cp simply tries to overwrite the existing file, which will fail if the file is locked due to being in use.
Further information
install Command

Resources