Conflicting libraries in /usr/local/lib and /usr/lib/x86_64-linux-gnu

7,422

Not sure if this is the best fix, but I just added:

-L/usr/local/lib/

to my linker flags (right after I included the libraries for opencv per https://stackoverflow.com/a/15975490/229311) and it effectively got rid of the error.

Share:
7,422

Related videos on Youtube

t2k32316
Author by

t2k32316

Updated on September 18, 2022

Comments

  • t2k32316
    t2k32316 over 1 year

    So I manually installed the latest ffmpeg a while ago, because one of my projects needs the latest .55 ffmpeg libraries (I think I used this: https://trac.ffmpeg.org/wiki/UbuntuCompilationGuide). So now in /usr/local/lib, I have:

    /usr/local/lib/libavcodec.a  /usr/local/lib/libavcodec.so
    /usr/local/lib/libavcodec.so.55  /usr/local/lib/libavcodec.so.55.38.101
    

    The problem is that in /usr/lib/x86_64-linux-gnu, I have:

    /usr/lib/x86_64-linux-gnu/libavcodec.a   /usr/lib/x86_64-linux-gnu/libavcodec.so.53
    /usr/lib/x86_64-linux-gnu/libavcodec.so  /usr/lib/x86_64-linux-gnu/libavcodec.so.53.35.0
    

    When I compile my code, I get this linker error:

    /usr/bin/ld: warning: libavcodec.so.55, needed by /usr/local/lib/libopencv_highgui.so, may conflict with libavcodec.so.53
    /usr/bin/ld: obj/h264_decoder.o: undefined reference to symbol 'avcodec_free_frame@@LIBAVCODEC_55'
    /usr/bin/ld: note: 'avcodec_free_frame@@LIBAVCODEC_55' is defined in DSO /usr/local/lib/libavcodec.so.55 so try adding it to the linker command line
    /usr/local/lib/libavcodec.so.55: could not read symbols: Invalid operation
    collect2: ld returned 1 exit status
    

    If I get rid of the conflicting library files in /usr/lib/x86_64-linux-gnu, then my code compiles with no errors. However, then other programs (e.g. the Movie Player) stop working. What's the best way to solve this problem?

    • t2k32316
      t2k32316 over 10 years
      Hmm.. I guess I must have not followed it exactly. Yes, I remember enabling shared libraries and I guess I did not follow their install directory locations fully. On my other machine, I have the .55's in /usr/local/lib and .53's in /usr/lib/x86_64-linux-gnu/ and everything seems to work fine...
    • t2k32316
      t2k32316 over 10 years
      Actually, it doesn't work on my other machine either.