Local install of GNU MP, how to access it from ld? - bash

I have a compiled local install of GMP:
/path/to/gmp
.../lib/gmp.h
.../include/[gmp_binaries.etc]
Now, I export the path, just to test the install; I'll add symlinks in some central location once I get it working:
export LD_LIBRARY_PATH=/path/to/gmp:$LD_LIBRARY_PATH
g++ -lgmp
// error: /usr/bin/ld: cannot find -lgmp
export LD_LIBRARY_PATH=/path/to/gmp/include:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/path/to/gmp/lib:$LD_LIBRARY_PATH
g++ -lgmp
// error: /usr/bin/ld: cannot find -lgmp
Basically, my question is: how do I connect my local libraries to ld?
(And the point is installing content without sudo, so I can't "just ____," for the most part)

-l requires a -L location to search in g++. Make does not follow your LD_LIBRARY_PATH. Make needs a specific location to search for specific libraries not included in /usr/lib
# define library paths in addition to /usr/lib
# if I wanted to include libraries not in /usr/lib I'd specify
# their path using -Lpath, something like:
LFLAGS = -L/home/newhall/lib -L../lib
From this site
Find your libgmp file, and link as follows:
g++ -L/path/to/libgmp/ -lgmp

Related

configure: error: one or more libs available at link-time are not available run-time. Libs used at link-time: -lssh2 -lssl -lcrypto -lz

env: centos7
install curl
when i start install curl and ./configure --with-ssl --with-zlib, i occurs errors about libs, what mean about link-time? it's env set? i have no any experience about installtaion by make, needed to install other package? how to fix it?
./configrue --with-ssl --with-zlib
accurs errors:
checking run-time libs availability... failed
configure: error: one or more libs available at link-time are not available
run-time. Libs used at link-time: -lssh2 -lssl -lcrypto -lz
the errors occur bebause of openssl install
after installed openssl, should check up while it usefully
when i input openssl version, it show same unkown path errors
so, u should set:
ln -s /usr/local/lib64/libssl.so.1.1 /usr/lib64/libssl.so.1.1
ln -s /usr/local/lib64/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1
it worked!
You can also add LD_LIBRARY_PATH in front of the configure script:
LD_LIBRARY_PATH=/usr/local/lib64 ./configure --with-ssl --with-zlib

configure: error: CGAL library not found

My ultimate goal is to get python package graph_tool working on my system and also on ipynb if possible. I have already brew install graph-tool, as indicated here, but that's still insufficient.
So I follow Anaconda instructions here, and I make decent progress, until the CGAL Library could not be found.
Note: to comply with the Anaconda instructions, I installed anaconda3 and created a new conda environment (named py36env) to conda install all the required packages (packages that must also match with python 3.6)
The entire ./configure output. Below is a snippet:
(py36env) $ ./configure --prefix=/Users/tamtran/anaconda3/envs/py36env/ --with-python-module-path=/Users/tamtran/anaconda3/envs/py36env/lib/python3.6/site-packages --with-cgal=/Users/tamtran/anaconda3/envs/py36env/
.
.
checking whether CGAL is available in /Users/tamtran/anaconda3/envs/py36env/... no
configure: error: CGAL library not found.
The entire config.log. Below is a snippet:
configure:21200: checking whether CGAL is available in /Users/tamtran/anaconda3/envs/py36env/
configure:21236: g++ -std=gnu++14 -o conftest -fopenmp -O3 -fvisibility=default -fvisibility-inlines-hidden -Wno-deprecated -Wall -Wextra -ftemplate-backtrace-limit=0 -DNDEBUG -I/Users/tamtran/anaconda3/envs/py36env//include -pthread -I/usr/local/include -L/Users/tamtran/anaconda3/envs/py36env//lib -lCGAL -lCGAL_Core -lgmp -lboost_thread-mt -lpthread conftest.cpp -lgmp -lgmp >&5
| #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
| #include <CGAL/convex_hull_2.h>
| typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
| CGAL::convex_hull_2(points.begin(),points.end(),std::back_inserter(result));
configure:21278: error: CGAL library not found.
CGAL_CPPFLAGS='-I/Users/tamtran/anaconda3/envs/py36env//include'
CGAL_FLAGS=''
CGAL_LDFLAGS='-L/Users/tamtran/anaconda3/envs/py36env//lib -lCGAL -lCGAL_Core -lgmp -lboost_thread-mt -lpthread'
Note: Even without the --with-cgal tag, the same issue occurs. It's also important (I think) that the CGAL search directory is within py36env because CGAL matching with python3.6 is in there, whereas CGAL-python3.5 is in conda root environment. The only differences of ./configure output without the CGAL directory are:
checking whether CGAL is available in /usr... no
checking whether CGAL is available in /usr/local... no
checking whether CGAL is available in /opt... no
checking whether CGAL is available in /opt/local... no
on mac os x You must use -lcgal (is using brew)
for example on fedora linux -lCGAL

how can I fix ld not ignoring bad system libraries in favor of my local libraries?

I'm trying to build the newest gcc on my redhat box. I've downloaded and built the latest gmp, mpfr and mpc, per requirements and installed them in my local libraries. From the config.log file I have the following given below. Clearly the system version of mpfr is broken, and I want the configure to ignore it. I have set LIBRARY_PATH and LD_LIBRARY_PATH to point to my local installation /u/victor/lib. Since I'm running a configure script, it's not reasonable for me to try to change command line options for gcc. How do I fix this?
gcc -o conftest -g -O2 conftest.c -L/u/victor/lib -L/u/victor/lib -L/u/victor/lib -lmpc -lmpfr -lgmp >&5
/usr/bin/ld: warning: libmpfr.so.1, needed by /u/victor/lib/libmpc.so, may conflict with libmpfr.so.4
/usr/bin/ld: __gmpfr_cache_const_euler: TLS definition in /u/victor/lib/libmpfr.so section .tdata mismatches non-TLS definition in /usr/lib64/libmpfr.so.1 section .data
What's even more confusing, is that when I compile conftest.c and then
gcc -o conftest conftest.o -lmpc -lmpfr -lgmp
with export LD_LIBRARY_PATH=/u/victor/lib it gives the errors below. I've check libmfpr.so with nm and the three "undefined" symbols are there.
/u/victor/lib/libmpc.so: undefined reference to `mpfr_min_prec'
/u/victor/lib/libmpc.so: undefined reference to `mpfr_set_zero'
/u/victor/lib/libmpc.so: undefined reference to `mpfr_get_z_2exp'

Can't link with shared library

I can't link my program with shared library located in non-standart OSX lib directory. I've got this library from MacPorts and it's located in /opt/local/lib:
$ ls /opt/local/lib/libgmp*
/opt/local/lib/libgmp.10.dylib /opt/local/lib/libgmpxx.4.dylib
/opt/local/lib/libgmp.a /opt/local/lib/libgmpxx.a
/opt/local/lib/libgmp.dylib /opt/local/lib/libgmpxx.dylib
/opt/local/lib/libgmp.la /opt/local/lib/libgmpxx.la
I've found that one can use DYLD_FALLBACK_LIBRARY_PATH, but it not works for me:
$ DYLD_LIBRARY_PATH=/opt/local/lib gcc ab.c -lgmp
ld: library not found for -lgmp
collect2: ld returned 1 exit status
At runtime, DYLD_LIBRARY_PATH helps dynamic linker to locate libraries from non-standard directories.
In your case, you are still in compilation phase.
For gcc to know about these extra directories to search, you could use -L switch.
e.g.
gcc ab.c -L/opt/local/lib -lgmp

Mono mkbundle on OSX

I'm trying to create a standalone of my C# app using mono's mkbundle, I got Xcode installed and the Mono Developer Kit too (I'm sure it's MDK not the runtime). Yet I run mkbundle using
mkbundle test.exe
and I get these errors
Compiling:
as -o temp.o temp.s
cc -g -o a.out -Wall temp.c `pkg-config --cflags --libs mono-2` temp.o
sh: pkg-config: command not found
temp.c:1:10: fatal error: 'mono/metadata/mono-config.h' file not found
1 error generated.
[Fail]
What's happening?
pkg-config is stored at '/Library/Frameworks/Mono.framework/Commands'.
Solution (see here and here):
Prepend the "/Library/Frameworks/Mono.framework/Commands" folder to
your PATH variable:
export PATH=/Library/Frameworks/Mono.framework/Commands:$PATH
This is needed in addition to the architecture solution proposed by aiapatag and the objective-c runtime and CoreFoundation framework solution:
export AS="as -arch i386"
export CC="cc -arch i386 -framework CoreFoundation -lobjc -liconv"
It looks like the pkg-config tool is not found. Maybe it's not in the default paths.
Do you have a 'pkgconfig' directory somewhere? It should be a subdirectory of your Mono installation.
Try to see if you have a path looking like /Library/Frameworks/Mono.framework/Versions/XXXX/lib/pkgconfig
If yes, point the PKG_CONFIG_PATH environment variable to this path, you can specify it directly when running your mkbundle command (this is just an example):
$ PKG_CONFIG_PATH=/Library/Frameworks/Mono.framework/Versions/XXXX/lib/pkgconfig mkbundle ....

Resources