Why do I fail to load the dylib? - macos

Here is the command I typed:
clang++ -Iboost -Ijpeg_lib/include/ -Ljpeg_lib/lib/ -ljpeg.9 mandelbrot.cpp
The directory structure is like this:
mandelbrot.cpp
/boost
/jpeg_lib/lib/
libjpeg.9.dylib
/jpeg_lib/include/
The compilation is successful, but when I run the binary file, an error occurs:
dyld: Library not loaded: /usr/local/lib/libjpeg.9.dylib
Referenced from: /Users/hanxu/Documents/./a.out
Reason: image not found
Trace/BPT trap: 5
I have specified the library searching path to jpeg_lib/include/, why does the program still search at /usr/local/lib ?

You should include the directory where libjpeg.9.dylib lives in LD_LIBRARY_PATH, which is required to locate the libraries at runtime:
export LD_LIBRARY_PATH=/path/to/libjpeg

Have you checked permissions on your jpeg_lib ? If you installed whatever it is you are running as root and then ran as yourself this may have happened.
I just had the same error message with running GD graphics from a Perl cgi after a portmanteau install as root and found that the /usr/local/lib directory in which my libjpeg.9.dylib resides had permissions 700. Changing to 755 (like all the other directories in /usr/local) solved the problem.

Related

Change dylib search directory in macOS

I was trying out the godal library and wrote a simple script as follows:
package main
import (
"github.com/airbusgeo/godal"
)
func main() {
godal.RegisterAll()
}
Running go run main.go throws the following error
dyld[19569]: Library not loaded: #rpath/libgdal.30.dylib
Referenced from: /private/var/folders/y5/yh59dj093xn_dz8lm0mhv6lh0000gp/T/go-build1573968352/b001/exe/test
Reason: tried: '/usr/local/lib/libgdal.30.dylib' (no such file), '/usr/lib/libgdal.30.dylib' (no such file)
signal: abort trap
godal has a dependency on gdal and I had installed it via conda. Due to this, the dylib is located under my conda folder - /Users/ash/miniconda3/lib not /usr/local/lib.
How can I have the program search for libgdal.dylib in /Users/ash/miniconda3/lib instead of /usr/local/lib ?
You could try setting GDAL_LIBRARY_PATH=/Users/ash/miniconda3/lib/libgdal.dylib
You can try this in both the shell where you run go run .... or as an os.Setenv("GDAL_LIBRARY_PATH", "/Users/ash/miniconda3/lib/libgdal.dylib")
Add the path to the miniconda3 lib directory to the DYLD_FALLBACK_LIBRARY_PATH environment variable. In your case, that would be:
DYLD_FALLBACK_LIBRARY_PATH=/Users/ash/miniconda3/lib:$DYLD_FALLBACK_LIBRARY_PATH YourGoExecutable
Note: Don't use DYLD_LIBRARY_PATH, as this will clobber existing path resolution, and mostly likely result in unintended trouble down the line.

libproj not loaded while installing sumo on macOS

I was going through the Flow installation and when I typed sumo --version into the terminal I got the following error message:
dyld: Library not loaded: /usr/local/opt/proj/lib/libproj.13.dylib
Referenced from: /Users/apple/sumo_binaries/bin/sumo
Reason: image not found
I've tried reinstalling sumo but the problem persisted.
How can I solve this issue?
I've found a fix for the problem.
Type the following into the terminal:
ln -s /usr/local/opt/proj/lib/libproj.15.dylib /usr/local/opt/proj/lib/libproj.13.dylib
Open up the directory mentioned above and make sure both libraries show (even if one of them is a shortcut) and rerun the sumo installation.
Note: you may have to change the paths depending on where your libproj.15.dylib is located.

ROOT cern install error

I'm trying to install ROOT (from cern) and I have a problem. This is the error that I have after make comand.
bin/rootcling: error while loading shared libraries: libtinfow.so.6: cannot open shared object file: No such file or directory
How can I resolve this? I looked for a libtinfow package but seems it doen't exist!
You need to install ncurses shared lib, and while configuring ncurses before building do:
./configure --prefix=/path/to/ncurses --with-termlib --with-shared --enable-widec

Memcached: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file

Situation: I installed memcached on a CenTOS 5 (64 bit). I also ended up installing some PHP plugins using PECL, though they're unnecessary now.
Problem:When I execute
/etc/init.d/memcached start
I get the following error:
Starting memcached: memcached: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory
But the file libevent-2.0.so.5 is present in /opt/couchbase/lib/.
Should it be there in some other folder ? How to get memcached to start ?
/opt/couchbase/lib will not be set on your system library path by default. That's why your unable to find libevent when running /etc/init.d/memcached.
To quickly solve this you can just run the command as follows:
LD_LIBRARY_PATH=/opt/couchbase/lib /etc/init.d/memcached
or to solve this over the long term add the following file (assuming your using centos):
/etc/ld.so.conf.d/couchbase.conf
and in that file add the path "/opt/couchbase/lib". Then run ldconfig and re-run the command to start memcached.
sudo ln -s /usr/lib/libevent-2.1.so.6 /usr/lib64/libevent-2.1.so.6
for libevent-2.0.so.5 the same.

Access denied error in boost-bjam isntallation

i'm trying to lunch bjam as a step to install the boost library, needed to run Cufflinks (RNASeq analysis software).
however, when i run the code:
$ ./bjam --prefix=/cygdrive/c/cygdrive/c/Boost/include/boost-1_53/boost -- toolset=gcc architecture=x86 address_model=32 link=static runtime-link=static stage install
i get the following error
Access is denied.
Access is denied.
Access is denied.
Access is denied.
C:/Users/se24553/Downloads/boost_1_53_0/tools/build/v2/build\property.jam:328: in validate1 from module property
error: Invalid property '<address_model>32': unknown feature 'address_model'.
C:/Users/se24553/Downloads/boost_1_53_0/tools/build/v2/build\property.jam:337: in property.validate from module property
C:/Users/se24553/Downloads/boost_1_53_0/tools/build/v2/build\build-request.jam:216: in convert-command-line-element from module build-request
C:/Users/se24553/Downloads/boost_1_53_0/tools/build/v2/build\build-request.jam:154: in build-request.from-command-line from module build-request
C:/Users/se24553/Downloads/boost_1_53_0/tools/build/v2\build-system.jam:613: in load from module build-system
C:\Users\se24553\Downloads\boost_1_53_0\tools\build\v2/kernel\modules.jam:283: in import from module modules
C:\Users\se24553\Downloads\boost_1_53_0\tools\build\v2/kernel/bootstrap.jam:142: in boost-build from module
C:\Users\se24553\Downloads\boost_1_53_0\boost-build.jam:17: in module scope from module
and I don't really know how to overcome that.
the directory /cygdrive/c/cygdrive/c/Boost/ (and i tried to use only this path but the result is the same) is where i have installed the various files using the code b2 install --prefix=/cygdrive/c/cygdrive/c/Boost/, however, it contains two folders include and lib, lib is empty while include contains --> boost-1_53 --> boost and here there are all the other folders and the .hpp files.
i am using cygdrive on Win 7 if that helps!
thanks :)
I had the same problem:
In windows 7 your bin directory may be protected:
$ chmod -R a+r bin
$ chmod -R a+x bin
How to compile Boost (and link?) libraries in cygwin windows7 i686-w64-mingw32-g++ with bjam
Barthelemy

Resources