bug-libtool
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

libtool-2.2.6a - wrong "file not found" message


From: Sergei Steshenko
Subject: libtool-2.2.6a - wrong "file not found" message
Date: Sun, 24 May 2009 17:10:42 -0700 (PDT)

Hello,

I've been trying to run the following program:

#include <stdio.h>
#include <stdlib.h>
#include <ltdl.h>

int main(int argc, char *argv[])
  {
  lt_dlhandle handle;
  const char *lib_file_to_open = "./library.o";

  if(0 != lt_dlinit())
    {
    fprintf(stderr, ":ERROR: failure executing 'lt_dlinit()', the error message 
was: %s\n", lt_dlerror());
    exit(EXIT_FAILURE);
    }

  handle = lt_dlopen(lib_file_to_open);
  if(!handle)
    {
    fprintf(stderr, ":ERROR: could not open '%s' file, the error message: 
%s\n", lib_file_to_open, lt_dlerror());
    exit(EXIT_FAILURE);
    }

   unsigned (*lib_function)(double input);
  *(void **) (&lib_function) = lt_dlsym(handle, "lib_function");

  if(NULL == lib_function)
    {
    fprintf(stderr, ":ERROR: couldn't perform lookup of 'lib_function' dymbol, 
the error message: %s\n", lt_dlerror());
    exit(EXIT_FAILURE);
    }

  fprintf(stderr, "result: %d\n", (*lib_function)(2.34));

  if(lt_dlexit())
    {
    fprintf(stderr, ":ERROR: failure executing lt_dlexit()\n");
    exit(EXIT_FAILURE);
    }

  exit(EXIT_SUCCESS);
  }
.

An immediate disclaimer - the program most likely should _not_ work, the
faulty line is

  const char *lib_file_to_open = "./library.o";

, and when the line is

  const char *lib_file_to_open = "./library.so";

, the program works as expected.


The command line I used to compile and link was:

gcc -I /mnt/sdb8/sergei/AFSWD_debug/install/libtool-2.2.6a/include -rdynamic 
-O2 main.c -o main 
/mnt/sdb8/sergei/AFSWD_debug/install/libtool-2.2.6a/lib/libltdl.a -ldl

- no warnings/errors.


The command line used to run the program and screen output were:

"
address@hidden:~/try_ltdl> (export LTDL_LIBRARY_PATH=`pwd`/; echo 
$LTDL_LIBRARY_PATH;ls -ltr library.o;./main)
/home/sergei/try_ltdl/
-rw-r--r-- 1 sergei users 2124 2009-05-24 15:51 library.o
:ERROR: could not open './library.o' file, the error message: file not found
address@hidden:~/try_ltdl>        
".

Please note that 'library.o' exists in CWD, so the "file not found" message
is wrong.

Without setting LTDL_LIBRARY_PATH behavior is the same:

"
ls -ltr library.o;./main
-rw-r--r-- 1 sergei users 2124 2009-05-24 15:51 library.o
:ERROR: could not open './library.o' file, the error message: file not found
address@hidden:~/try_ltdl> 
".

I did nothing to make library.o loadable, it wasn't compiled using
'libtool', maybe it's not even possible to load plain .o file (I have to
reread the documentation and think more on that), but, still, the message
is wrong.

Also, the message is not user friendly - it doesn't say what file was not
found - often file names are programmatically composed, so there can be
mistakes in the composition, and functions which try to find/open should
at least print file name or better yet full path or paths it tried while
searching.

Thanks,
  Sergei.

P.S. If one wants to play with the test case, here is also the source of
'library.c'; command lines used to compile and link it are in the comment
block at the bottom:

unsigned lib_function(double input)
  {
  return (unsigned)input;
  }

/*

gcc -Wall -Wextra -O2 -fPIC -DPIC -g -c library.c
gcc -shared library.o -Wl,-soname -o library.so

*/








      




reply via email to

[Prev in Thread] Current Thread [Next in Thread]