SWI-Prolog / issues

Dummy repository for issue tracking
7 stars 3 forks source link

Default installation path of swipl shared library not in ld.so.conf #47

Closed JoergStrebel closed 8 years ago

JoergStrebel commented 8 years ago

Hello! I downloaded SWI Prolog from http://www.swi-prolog.org/download/stable (http://www.swi-prolog.org/download/stable/src/swipl-7.2.3.tar.gz). I build the software according to INSTALL and README.linux

I created a C program that calls SWI Prolog; I could successfully compile and link the C code by manually providing suitable paths using -I and -L on the gcc command line. However, I could not run it, as the default installation path of swipl shared library is not contained in /etc/ld.so.conf. The shared library is copied to the predefined library directory (/usr/local/lib64/swipl-7.2.3/lib/x86_64-linux/ in my case), but it seems, ldconfig is not called correctly afterwards. So the linker cannot resolve the reference to the shared lib when the binary is executed, as the libswipl is not in the ldconfig cache. I know there is a workaround using LD_LIBRARY_PATH, but that is just for debugging purposes.

The version of SWI-Prolog you use: 7.2.3 The operating system: openSuse Linux 13.2

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <SWI-Prolog.h>

int main(void)
{
  static char * av[] = {"kb1.plg", NULL};
  if( ! PL_initialise(1,av))
  {
    fprintf(stderr, "error initializing");
    PL_halt(1);
  }
  else 
    {
      printf("success initializing!");
    }
 PL_halt(0);
 return 0;
}
JanWielemaker commented 8 years ago

As quite a few people have multiple versions around, the .so file is in the self-contained hierarchy of SWI-Prolog. If you link either using pkg-config provided flags or swipl-ld, you will use --rpath to get to right version of the shared lib:

ct2 (~) 4_> pkg-config --libs swipl
-L/home/jan/lib/swipl/lib/x86_64-linux -rdynamic -O2 -pthread -Wl,-rpath=/home/jan/lib/swipl/lib/x86_64-linux -lswipl
JoergStrebel commented 8 years ago

Thanks, very interesting!

Am 01.10.2016 um 17:04 schrieb Jan Wielemaker:

As quite a few people have multiple versions around, the .so file is in the self-contained hierarchy of SWI-Prolog. If you link either using |pkg-config| provided flags or |swipl-ld|, you will use |--rpath| to get to right version of the shared lib:

|ct2 (~) 4_> pkg-config --libs swipl -L/home/jan/lib/swipl/lib/x86_64-linux -rdynamic -O2 -pthread -Wl,-rpath=/home/jan/lib/swipl/lib/x86_64-linux -lswipl |

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/SWI-Prolog/issues/issues/47#issuecomment-250917018, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ_RWHNUnCtZ0J_BT7rUrtGiLnxtB7dxks5qvnZtgaJpZM4KLvEw.

Jörg Strebel Aachener Straße 2 80804 München