{"action":"created","issue":{"url":"https://api.github.com/repos/Araq/Nim/issues/2408","labels_url":"https://api.github.com/repos/Araq/Nim/issues/2408/labels{/name}","comments_url":"https://api.github.com/repos/Araq/Nim/issues/2408/comments","events_url":"https://api.github.com/repos/Araq/Nim/issues/2408/events","html_url":"https://github.com/Araq/Nim/issues/2408","id":64380713,"number":2408,"title":"\"Could not load\" dynamic library at runtime because of hidden dependency","user":{"login":"ziotom78","id":377795,"avatar_url":"https://avatars.githubusercontent.com/u/377795?v=3","gravatar_id":"","url":"https://api.github.com/users/ziotom78","html_url":"https://github.com/ziotom78","followers_url":"https://api.github.com/users/ziotom78/followers","following_url":"https://api.github.com/users/ziotom78/following{/other_user}","gists_url":"https://api.github.com/users/ziotom78/gists{/gist_id}","starred_url":"https://api.github.com/users/ziotom78/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ziotom78/subscriptions","organizations_url":"https://api.github.com/users/ziotom78/orgs","repos_url":"https://api.github.com/users/ziotom78/repos","events_url":"https://api.github.com/users/ziotom78/events{/privacy}","received_events_url":"https://api.github.com/users/ziotom78/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-03-25T21:47:39Z","updated_at":"2015-03-26T14:30:27Z","closed_at":null,"body":"I'm trying to call some functions defined in the [GNU GSL library](http://www.gnu.org/software/gsl/). Under Lubuntu 14.10 the following program will compile correctly:\r\n`````nim\r\nproc besselJ0(x : cdouble) : cdouble {. cdecl,\r\n                                        dynlib : \"libgsl.so\",\r\n                                        importc : \"gsl_sf_bessel_J0\" .}\r\n\r\necho besselJ0(1.0)\r\n`````\r\n\r\nHowever, at runtime it will fail with the following message:\r\n`````\r\n/usr/lib/libgsl.so: undefined symbol: cblas_dasum\r\ncould not load: libgsl.so\r\nError: execution of an external program failed\r\n`````\r\n(I uncommented a line in `lib/system/dyncalls.nim` to get the message about `cblas_dasum`.)\r\n\r\nThe `cblas_dasum` function is defined in `libgslcblas.so`, but this dependency does not seem to be encoded in the `libgsl.so` file:\r\n`````\r\n$ ldd /usr/lib/libgsl.so\r\n\tlinux-vdso.so.1 =>  (0x00007fff9fd0c000)\r\n\tlibm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f829a513000)\r\n\tlibc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f829a14f000)\r\n\t/lib64/ld-linux-x86-64.so.2 (0x00007f829ac61000)\r\n`````\r\n\r\nIf I import `cblas_dasum`, the error remains the same (`undefined symbol: cblas_dasum \\ could not load: libgsl.so`):\r\n`````nim\r\nproc besselJ0(x : cdouble) : cdouble {. cdecl,\r\n                                        dynlib : \"libgsl.so\",\r\n                                        importc : \"gsl_sf_bessel_J0\" .}\r\nproc cblas_dasum(n : cint, \r\n                 x : ptr cdouble, \r\n                 incX: int) : cdouble {. cdecl, \r\n                                         dynlib: \"libgslcblas.so\", \r\n                                         importc: \"cblas_dasum\" .}\r\necho besselJ0(1.0)\r\n`````\r\n\r\nNote that `libgslcblas.so` is readily available under the same path as `libgsl.so`:\r\n`````\r\n$ locate libgsl.so\r\n/usr/lib/libgsl.so\r\n/usr/lib/libgsl.so.0\r\n/usr/lib/libgsl.so.0.17.0\r\n$ locate libgslcblas.so\r\n/usr/lib/libgslcblas.so\r\n/usr/lib/libgslcblas.so.0\r\n/usr/lib/libgslcblas.so.0.0.0\r\n`````\r\n\r\nI tried to define `besselJ0` using two `dynlib`, but with no success:\r\n`````nim\r\n# This compiles fine but does not solve the problem\r\nproc besselJ0(x : cdouble) : cdouble {. cdecl,\r\n                                        dynlib : \"libgsl.so\",\r\n                                        dynlib : \"libgslcblas.so\",\r\n                                        importc : \"gsl_sf_bessel_J0\" .}\r\n`````\r\nSo far, the only workaround I found was to statically link GSL. "},"comment":{"url":"https://api.github.com/repos/Araq/Nim/issues/comments/86541274","html_url":"https://github.com/Araq/Nim/issues/2408#issuecomment-86541274","issue_url":"https://api.github.com/repos/Araq/Nim/issues/2408","id":86541274,"user":{"login":"Araq","id":287816,"avatar_url":"https://avatars.githubusercontent.com/u/287816?v=3","gravatar_id":"","url":"https://api.github.com/users/Araq","html_url":"https://github.com/Araq","followers_url":"https://api.github.com/users/Araq/followers","following_url":"https://api.github.com/users/Araq/following{/other_user}","gists_url":"https://api.github.com/users/Araq/gists{/gist_id}","starred_url":"https://api.github.com/users/Araq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Araq/subscriptions","organizations_url":"https://api.github.com/users/Araq/orgs","repos_url":"https://api.github.com/users/Araq/repos","events_url":"https://api.github.com/users/Araq/events{/privacy}","received_events_url":"https://api.github.com/users/Araq/received_events","type":"User","site_admin":false},"created_at":"2015-03-26T14:30:27Z","updated_at":"2015-03-26T14:30:27Z","body":"Hrm, I think you should just use ``dynlibOverride`` and explicit linking commands then."}}