c++ - Portable way of linking libgfortran with CMAKE -


one of executables requires libgfortran.so. typically i'd add -lgfortran switch compile line , links automatically g++. however, i'm trying find library cmake using:

find_library(gfortran_library names gfortran) target_link_libraries(ncorr_test ${gfortran_library}) 

however, fails find library. turns out way has worked far if include entire library name so:

find_library(gfortran_library names libgfortran.so.3) target_link_libraries(ncorr_test ${gfortran_library}) 

then, link properly:

/usr/bin/c++ ... /usr/lib/x86_64-linux-gnu/libgfortran.so.3 ... 

however, including whole .so.3 not portable. know of better way this? typically libraries need use installed in /usr/local/lib , searching library name without "lib" , extension works (i.e. find_library(fftw_library names fftw3) find libfftw3.a in /usr/local/lib fine).

edit:

find_library(gfortran_library names libgfortran.so) not work either. libgfortran.so.3 has worked far.

using locate libgfortran outputs:

/usr/lib/gcc/x86_64-linux-gnu/4.8/libgfortran.a /usr/lib/gcc/x86_64-linux-gnu/4.8/libgfortran.so /usr/lib/gcc/x86_64-linux-gnu/4.8/libgfortran.spec /usr/lib/gcc/x86_64-linux-gnu/4.8/libgfortranbegin.a /usr/lib/x86_64-linux-gnu/libgfortran.so.3 /usr/lib/x86_64-linux-gnu/libgfortran.so.3.0.0 /usr/local/matlab/r2014a/sys/os/glnxa64/libgfortran.so.3 /usr/local/matlab/r2014a/sys/os/glnxa64/libgfortran.so.3.0.0 /usr/share/doc/libgfortran-4.8-dev /usr/share/doc/libgfortran3 /var/lib/dpkg/info/libgfortran-4.8-dev:amd64.list /var/lib/dpkg/info/libgfortran-4.8-dev:amd64.md5sums /var/lib/dpkg/info/libgfortran3:amd64.list /var/lib/dpkg/info/libgfortran3:amd64.md5sums /var/lib/dpkg/info/libgfortran3:amd64.postinst /var/lib/dpkg/info/libgfortran3:amd64.postrm /var/lib/dpkg/info/libgfortran3:amd64.shlibs /var/lib/dpkg/info/libgfortran3:amd64.symbols 

edit2:

for i'll require user copy libgfortran.a on usr\local\lib directory

looks either miss dev package on linux distribution, should install .so link, or path such link located missing when cmake lookup. try find lingfortran.so link, located same place .so.3 is, if cannot find install missing dev package, if can check why path not included in cmake.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -