4

I am trying to use VLFeat library in C, as given on the website http://www.vlfeat.org/gcc.html.

I downloaded and installed the library. I use the glnxa64 architecture. The library is located at /A/B/C/vlfeat-0.9.18

My code is as follows:

    extern "C" {
    #include <vl/generic.h>
    #include <vl/sift.h>
    }

    int main (int argc, const char * argv[]) 
    {
    VL_PRINT ("Hello world!") ;
    return 0;
    }

I compile my code using the following statement,

g++ main.cpp -o vlfeat-test -I/A/B/C/vlfeat-0.9.18 -L/A/B/C/vlfeat-0.9.18/bin/glnxa64/ -lvl

But when I run it, I get the following error

./vlfeat-test: error while loading shared libraries: libvl.so: cannot open shared object file: No such file or directory
gevang
  • 4,994
  • 25
  • 33
user2948166
  • 599
  • 1
  • 9
  • 17
  • possible duplicate of [Why is my shared library not found?](http://stackoverflow.com/questions/11111293/why-is-my-shared-library-not-found) – indiv Apr 05 '14 at 23:22
  • But I am working on a server and do not have admin rights. The solution given in the above link does not work for me. – user2948166 Apr 06 '14 at 02:14
  • 1
    You don't need to be admin to change your LD_LIBRARY_PATH environment variable. You can also try various linker flags like the ones described here: http://stackoverflow.com/questions/2484265/how-do-i-get-rid-of-ld-library-path-at-run-time – indiv Apr 06 '14 at 15:51

4 Answers4

2

When your program is loaded, linux loads the necessary libraries.

You need to create a symbolic link in /usr/lib/ to your libvl.so file

sudo ln -s /home/[YourPATH]/vlfeat-0.9.20/bin/[YourArchitecture]/libvl.so /usr/lib/libvl.so
slat
  • 21
  • 3
1

Before running your test, in the same console:

export LD_LIBRARY_PATH=/A/B/C/vlfeat-0.9.18/bin/glnxa64:$LD_LIBRARY_PATH

then

./vlfeat-test
remi
  • 3,914
  • 1
  • 19
  • 37
1

I think the problem is when your program load. Linux doesn't know where your vl library is.

copy libvl.so to /usr/lib

sudo cp [VLFEAT_PATH]/bin/[YOUR_ARCHITECTURE]/libvl.so /usr/lib
MooMoo
  • 1,086
  • 12
  • 22
0

[This worked for same problem when using the .mex files through MATLAB in Ubuntu].

You may need to update the links and cache to the recent shared libraries by running

sudo ldconfig

You can permanently add the library path /A/B/C/vlfeat-0.9.18/bin/glnxa64 or a custom directory with your (links to) shared libraries, e.g., /home/username/lib in the ldconfig files:

sudo vim /etc/ld.so.conf

to add the line(s)

/A/B/C/vlfeat-0.9.18/bin/glnxa64

Verify by running

ldconfig -v | grep libvl.so
gevang
  • 4,994
  • 25
  • 33