Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linking error on Ubuntu 14.04 32 bit #215

Closed
trappedinspacetime opened this issue Jul 6, 2014 · 10 comments
Closed

linking error on Ubuntu 14.04 32 bit #215

trappedinspacetime opened this issue Jul 6, 2014 · 10 comments

Comments

@trappedinspacetime
Copy link

Hi;

Thank you for nice project. I cloned your repo here and run ./simple-build-and-install in the source directory, all went well till linking process. I got ./.libs/libsimplescreenrecorder-target-ssse3.a -lQtGui -lQtCore -lrt -lavformat -lavcodec -lavutil -lswscale -lX11 -lXext -lXfixes -lXi -lasound -lpulse -ljack -pthread AV/simplescreenrecorder-AVWrapper.o: In functionAVFrameWrapper::AVFrameWrapper(std::shared_ptr const&)':
AVWrapper.cpp:(.text+0x123): undefined reference to av_frame_alloc' AV/simplescreenrecorder-AVWrapper.o: In functionAVFrameWrapper::~AVFrameWrapper()':
AVWrapper.cpp:(.text+0x22d): undefined reference to av_frame_free' collect2: error: ld returned 1 exit status

error message. I googled it a bit some say that it stems from linker order http://stackoverflow.com/questions/16885314/c-code-using-ffmpeg-libraries-compilation-error, another says it stems from outdated ffmpeg installation, and another guy points out encompassing FFmpeg includes using extern "C"."
http://stackoverflow.com/questions/9701764/undefined-reference-using-ffmpeg-library-avcodec-on-ubuntu-64-bits-system
How can I fix that error?
Regards
Kenn

@MaartenBaert
Copy link
Owner

This should not happen, I suspect there's something wrong with your ffmpeg/libav installation. Did you accidentally install two versions of ffmpeg/libav at the same time?

@trappedinspacetime
Copy link
Author

Did you accidentally install two versions of ffmpeg/libav at the same time?

I think so, I manually installed ffmpeg in the past. This link http://askubuntu.com/questions/432542/is-ffmpeg-missing-from-the-official-repositories-in-14-04 states that ffmpeg is not compatible with 14.04 so it's dropped. From which source code can I install it and with which parameters?

@MaartenBaert
Copy link
Owner

ffmpeg is compatible with Ubuntu 14.04, but the old 'ffmpeg' package isn't the real ffmpeg. Ubuntu uses libav (a fork of ffmpeg). You can't really install ffmpeg and libav at the same time, and you probably can't uninstall the libav packages because lots of applications depend on it.

If you want the real ffmpeg, you may want to try this PPA:
https://launchpad.net/~jon-severinsson/+archive/ffmpeg
However you should still remove the manually installed version of ffmpeg first.

@trappedinspacetime
Copy link
Author

I removed libav-tools and installed ffmpeg from ppa:jon-severinsson/ffmpeg but I still get the same error. FYI some suggest adding ffmpeg finding modules to cmake but your code doesn't use cmake

http://answers.ros.org/question/171326/catkin-linking-order-undefined-reference-to-symbol/
http://libav-users.943685.n4.nabble.com/Libav-user-undefined-reference-to-av-frame-alloc-free-td4659880.html
http://stackoverflow.com/questions/20386846/ffmpeg-linking-problems-using-cmake

@MaartenBaert
Copy link
Owner

The problem is that your headers (/usr/include) don't match your libraries (/usr/lib). That probably means you still have some old version of ffmpeg/libav lying around somewhere. Installing new versions won't help unless you also remove the old version. Try running locate -b libavcodec.so and locate -b libavformat.so to find out where the libraries are. They could be in /usr/lib or in /usr/local/lib or maybe even somewhere else. You can find all possible library locations with cat /etc/ld.so.conf.d/*.

@trappedinspacetime
Copy link
Author

I am sorry for taking your time. It appears that I have a few libavcodec.so files.
Here is the output

 locate -b libavcodec.so
 /home/kenn/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/usr/lib/x86_64-linux-gnu/libavcodec.so.53
 /home/kenn/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/usr/lib/x86_64-linux-gnu/libavcodec.so.53.35.0
 /home/kenn/.local/share/Steam/ubuntu12_32/steam-runtime/i386/usr/lib/i386-linux-gnu/libavcodec.so.53
 /home/kenn/.local/share/Steam/ubuntu12_32/steam-runtime/i386/usr/lib/i386-linux-gnu/libavcodec.so.53.35.0
 /home/kenn/.local/share/Steam/ubuntu12_32/steam-runtime/i386/usr/lib/i386-linux-gnu/i686/cmov/libavcodec.so.53
 /home/kenn/.local/share/Steam/ubuntu12_32/steam-runtime/i386/usr/lib/i386-linux-gnu/i686/cmov/libavcodec.so.53.35.0
 /usr/lib/i386-linux-gnu/libavcodec.so
 /usr/lib/i386-linux-gnu/libavcodec.so.53
 /usr/lib/i386-linux-gnu/libavcodec.so.53.35.0
 /usr/lib/i386-linux-gnu/libavcodec.so.54
 /usr/lib/i386-linux-gnu/libavcodec.so.54.92.100
 /usr/lib/i386-linux-gnu/i686/cmov/libavcodec.so
 /usr/lib/i386-linux-gnu/i686/cmov/libavcodec.so.53
 /usr/lib/i386-linux-gnu/i686/cmov/libavcodec.so.53.35.0
 /usr/lib/i386-linux-gnu/i686/cmov/libavcodec.so.54
 /usr/lib/i386-linux-gnu/i686/cmov/libavcodec.so.54.92.100
 /usr/local/lib/libavcodec.so
 /usr/local/lib/libavcodec.so.55
 /usr/local/lib/libavcodec.so.55.58.103

@MaartenBaert
Copy link
Owner

I think you should remove the following files:

/usr/lib/i386-linux-gnu/libavcodec.so.53
/usr/lib/i386-linux-gnu/libavcodec.so.53.35.0
/usr/lib/i386-linux-gnu/i686/cmov/libavcodec.so.53
/usr/lib/i386-linux-gnu/i686/cmov/libavcodec.so.53.35.0
/usr/local/lib/libavcodec.so
/usr/local/lib/libavcodec.so.55
/usr/local/lib/libavcodec.so.55.58.103

But you should do the same for libavformat, libavutil, libswscale, libswresample, libavresample, libavfilter, ... so it is probably better to find the real source of the files rather than just manually deleting them.

The ones in /usr/local/lib were probably installed manually with make install. The right way to uninstall them is by running make uninstall in the original build directory.

I'm not sure where the libavcodec.so.53 files came from, those belong in Ubuntu 12.04, not 14.04 ...

@saiarcot895
Copy link

For the record, I was able to do the 64-bit part of the compilation using the standard avconv library in Ubuntu (without using the PPA). The 32-bit part didn't get through the configuration portion (something about a missing XOpenWindow), and I haven't tested it to see if it works.

@trappedinspacetime
Copy link
Author

@saiarcot895
Thank you being helpful. I renamed /usr/local/ directory then I removed ffmpeg, When I issuedwhereis ffmpeg it reported a few locations then I removed all of them manually. When I run ./simple-build-and-install it still finds ffmpeg.

@trappedinspacetime
Copy link
Author

@MaartenBaert @saiarcot895

I managed to compile it at last. I think your solution worked saiarcot895 Thank both of you for all your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants