/usr/bin/ld: cannot find local libmpifort.so - c++

environment
ubuntu 18.04
I want to install ISSM (ice sheet system model)
In this process, it needs to install many external packages.
In the make, I got the following error message.
/usr/bin/ld: cannot find -l/home/testuser/issm/trunk//externalpackages/mpich/install/lib/libmpifort.so
I follow two(?) general solutions, but I don't yet find a fittable solution.
I wonder -l<NameOfLibrary>, but, in my case, I got -l<AddrOfLibrary>.
Is this a normal case?
Is there a general solution?
My original question:
/usr/bin/ld: cannot find ld -l
I install CMake in a docker container with volume sharing.
So, I can finish to execute ./configure.sh.
But among make, I got these error /usr/bin/ld: cannot find -l<xxx>
CXXLD libISSMCore.la
*** Warning: Linking the shared library libISSMCore.la against the
*** static library /home/testuser/issm/trunk//externalpackages/m1qn3/install/libm1qn3.a is not portable!
*** Warning: Linking the shared library libISSMCore.la against the
*** static library /home/testuser/issm/trunk//externalpackages/m1qn3/install/libddot.a is not portable!
/usr/bin/ld: cannot find -l/home/testuser/issm/trunk//externalpackages/mpich/install/lib/libmpifort.so
collect2: error: ld returned 1 exit status
Makefile:4505: recipe for target 'libISSMCore.la' failed
make[3]: *** [libISSMCore.la] Error 1
make[3]: Leaving directory '/home/testuser/issm/trunk/src/c'
Makefile:460: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory '/home/testuser/issm/trunk/src'
Makefile:582: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/testuser/issm/trunk'
Makefile:479: recipe for target 'all' failed
make: *** [all] Error 2
user01#opendataserver:/home/testuser/issm/trunk$ ls ./externalpackages/mpich/install/lib/
libfmpich.so libmpicxx.la libmpifort.so libmpi.so.12.1.0
libmpi.a libmpicxx.so libmpifort.so.12 libmpl.so
libmpichcxx.so libmpicxx.so.12 libmpifort.so.12.1.0 libopa.so
libmpichf90.so libmpicxx.so.12.1.0 libmpi.la pkgconfig
libmpich.so libmpifort.a libmpi.so
libmpicxx.a libmpifort.la libmpi.so.12
Question in ISSM forum
Solution1: general solution ~ FAILED
/usr/bin/ld: cannot find -lpgm
이는 링크 단계에서 libpgm.so.<숫자> 인 라이브러리를 링크시키지 못했다는 말입니다.
1) find / -name libpgm* -print 를 하여 libpgm.so.x 파일이 존재하는지를 파악하고, 없으면 라이브러리가 제대로 설치가 안된 것입니다.
2) 파일이 존재한다면 LD_LIBRARY_PATH 에 해당 디렉토리가 들어가 있지 않기 때문입니다.
bash의 경우 (libpgm.so.x 파일이 /xxx/xxx1/xxx2/ 디렉토리 밑에 존재한다면)
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/xxx/xxx1/xxx2/
3) 다시 컴파일 해보길.. 행운을 빕니다.
Nothing will be happen.
Done
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/testuser/issm/trunk/externalpackages/mpich/install/lib/
Ref
Solution2: similar solution ~ FAILED
First, you need to know the naming rule of lxxx:
/usr/bin/ld: cannot find -lc
/usr/bin/ld: cannot find -lltdl
/usr/bin/ld: cannot find -lXtst
lc means libc.so, lltdl means libltdl.so, lXtst means libXts.so.
So, it is lib + lib-name + .so
Once we know the name, we can use locate to find the path of this lxxx.so file.
$ locate libiconv.so
/home/user/anaconda3/lib/libiconv.so # <-- right here
/home/user/anaconda3/lib/libiconv.so.2
/home/user/anaconda3/lib/libiconv.so.2.5.1
/home/user/anaconda3/lib/preloadable_libiconv.so
/home/user/anaconda3/pkgs/libiconv-1.14-0/lib/libiconv.so
/home/user/anaconda3/pkgs/libiconv-1.14-0/lib/libiconv.so.2
/home/user/anaconda3/pkgs/libiconv-1.14-0/lib/libiconv.so.2.5.1
/home/user/anaconda3/pkgs/libiconv-1.14-0/lib/preloadable_libiconv.so
If you cannot find it, you need to install it by yum (I use CentOS). Usually you have this file, but it does not link to right place.
Link it to the right place, usually it is /lib64 or /usr/lib64
$ sudo ln -s /home/user/anaconda3/lib/libiconv.so /usr/lib64/
Done!
ref: https://i-pogo.blogspot.jp/2010/01/usrbinld-cannot-find-lxxx.html
Done
sudo ln -s /home/testuser/issm/trunk/externalpackages/mpich/install/lib/libmpifort.so /usr/lib/
Ref

The -l (lower-case L) option is to specify a library name not a path.
To add a path to search for libraries use the -L option.
You can also list the full path of the library as an input file, but then without any options.
So either use the options -L/home/testuser/issm/trunk/externalpackages/mpich/install/lib -lmpifort
Or use plain /home/testuser/issm/trunk//externalpackages/mpich/install/lib/libmpifort.so as an inout file (after the other object files).

Related

Using OPCUA Library in a New Cmake Project

In this time, I want to use Freeopcua to create a library to use in other project.
I have install all the tools in debian.soft file and build with following command sudo sh build.sh, cmake ., make, sudo make install. Although, in directory /usr/local/include and /usr/local/lib, there are opc directory and libopc*.so respectively, when I create a new cmake project, there is an error. Hope someone can help me or give some suggest. Thanks everyone~~~
I have refer to Libraries in /usr/local/lib not found, but it doesn't work for me
CMakeLists.txt
cmake_minimum_required(VERSION 2.8.12)
project(OPCUAIndependent)
include_directories(/usr/local/include/)
link_directories(/usr/local/lib/)
add_executable(sourceCode sourceCode.cpp)
target_link_libraries(sourceCode opc)
Error
[ 50%] Linking CXX executable sourceCode
/usr/bin/ld: cannot find -lopc
collect2: error: ld returned 1 exit status
CMakeFiles/sourceCode.dir/build.make:96: recipe for target 'sourceCode' failed
make[2]: *** [sourceCode] Error 1
CMakeFiles/Makefile2:82: recipe for target 'CMakeFiles/sourceCode.dir/all' failed
make[1]: *** [CMakeFiles/sourceCode.dir/all] Error 2
Makefile:90: recipe for target 'all' failed
make: *** [all] Error 2

static link glibc & boost_python36 for python extension

I'm writting a extension for pyton3.6. My develop machine run gcc7.3, and production environment os is centos6. I use the following link option to static link glibc to avoid upgrade glibc2.12 to glibc2.14+.
-Wl,-Bdynamic -lpython3.6m -Wl,-Bstatic -lboost_python36
But get error:
[ 50%] Linking CXX shared module helloext.so
/usr/bin/x86_64-linux-gnu-ld: cannot find -lgcc_s
/usr/bin/x86_64-linux-gnu-ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status
CMakeFiles/helloext.dir/build.make:94: recipe for target 'helloext.so' failed
make[2]: *** [helloext.so] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/helloext.dir/all' failed
make[1]: *** [CMakeFiles/helloext.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
Anyone known? Thanks.
The reason might be although libgcc is present it may not be in the paths known to ldconfig. Check this by doing
/sbin/ldconfig -p | grep libgcc
Does the output show that there is a link to libgcc corresponds to paths that you have listed above?
A work around for you may be to add the link to the relevant library to your compile command e.g.
... -L /usr/lib/gcc/x86_64-linux-gnu/4.6/
Another may be to create a symbolic link to the library yourself.
ln -s /usr/lib/gcc/x86_64-linux-gnu/4.6/libgcc_s.so /usr/lib/gcc/libgcc_s.so
You have not informed us about Linux you are using. Update 4.6 with the proper number in the command above.

linking error cxx: cannot find -lvulkan

When I tried to compile example from Anvil framework for Vulkan I get following errors:
[ 97%] Linking CXX executable OutOfOrderRasterization
/usr/bin/ld: cannot find -lvulkan
collect2: error: ld returned 1 exit status
CMakeFiles/OutOfOrderRasterization.dir/build.make:126: recipe for target 'OutOfOrderRasterization' failed
make[2]: *** [OutOfOrderRasterization] Error 1
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/OutOfOrderRasterization.dir/all' failed
make[1]: *** [CMakeFiles/OutOfOrderRasterization.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
How i need to configure Vulkan to resolve it? (Ubuntu)
Check you LIBRARY paths. You might need to download and install vulkan. There should a .so file in one your library paths(/usr/lib{,64},/lib{,64}, /usr/share/lib{,64}) named to the effect of libvulkan.numbers.so.
See this ask ubuntu question: https://askubuntu.com/questions/796442/ld-cannot-find-lvulkan
CMake versions 3.7 and later ship with a FindVulkan.cmake module that finds the Vulkan includes and library for you if you have a Vulkan SDK installed and the VULKAN_SDK environment variable set. The CMake module also finds the includes and library if you have installed a Vulkan package to your system directories. The Getting Started guide on the LunarXchange website has some additional detail.

"make" command for rcssmonitor project

I'm installing rcssmonitor for soccer2d sim and there is a problem in making this project, here's the error:
/usr/bin/ld: cannot find -lfontconfig
collect2: error: ld returned 1 exit status
Makefile:477: recipe for target 'rcssmonitor' failed
make[2]: *** [rcssmonitor] Error 1
make[2]: Leaving directory '/rccserver/rcssmonitor/src'
Makefile:382: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/rccserver/rcssmonitor'
Makefile:322: recipe for target 'all' failed
make: *** [all] Error 2
I downloaded the latest version from sourceforge
how can I fix it?
In a fresh enough Debian/Ubuntu the required package is called libfontconfig1-dev. Perform apt install libfontconfig1-dev (almost) as #krzaq suggested.
But likely you will need other development packages as well. If linker blames on -lsome, then you need a shared library libsome.so, usually located in /usr/lib or /usr/lib32 (there could be other variations like /lib, /usr/lib64 etc). Perhaps the easiest way to understand what package a given file belongs to is to install apt-file package and then to query required libraries.

failed to build shared libraries with boost 1.48

I am trying to build boost 1.48 on an amd64 machine however shared libraries are not built due to a relocation error. Which I assumed due to -fPIC and that is the reason however could not fix that.
More specifically, here is what I get, with the boost from the trunk,
$ ./b2
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.4.5/libstdc++.a(codecvt.o): relocation R_X86_64_32S against `vtable for std::codecvt<wchar_t, char, __mbstate_t>' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-linux-gnu/4.4.5/libstdc++.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
I also tried these
./bjam -d2
./bjam address-model=64 cxxflags=-fPIC
as explained/discussed here
http://boost.2283326.n4.nabble.com/fPIC-option-for-boost-td3176976.html
however did not help. I could not manage to build the shared libraries that I configure with boostrap.sh.
I had a similar issue trying to build mosh-1.2.2 on a standard debian squeeze installation. The following worked for me:
# cd /usr/lib/gcc/x86_64-linux-gnu/4.4.5
# rm libstdc++.so
# ln -s ../../../x86_64-linux-gnu/libstdc++.so.6 libstdc++.so
To explain in a more detail, the existing symlink was pointing to a non-existent file:
# cd /usr/lib/gcc/x86_64-linux-gnu/4.4.5
# ls -l libstdc++.so
..
lrwxrwxrwx 1 root root 23 May 3 2011 libstdc++.so -> ../../../libstdc++.so.6
..
I located the correct file location
# dpkg -S 'libstdc'
..
libstdc++6: /usr/lib/x86_64-linux-gnu/libstdc++.so.6
..
Then repaired the symlink as described in the first code segment.
The error I was getting during compiling was:
make[3]: *** [mosh-client] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.4.5/libstdc++.a(functexcept.o): relocation R_X86_64_32 against `std::bad_typeid::~bad_typeid()' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-linux-gnu/4.4.5/libstdc++.a: could not read symbols: Bad value
No idea how this particular debian squeeze server broke. I've been compiling on other squeeze systems with no trouble.