evanpurkhiser / keyfinder-cli

A CLI wrapper for libkeyfinder. Making DJs lives easier.
GNU General Public License v3.0
111 stars 23 forks source link

Compiling under Ubuntu 14.04 #5

Closed iammordaty closed 9 years ago

iammordaty commented 9 years ago

Hello,

i have trouble compiling wrapper under Ubuntu 14.04. Could you provide build instructions or dependencies and its versions?

evanpurkhiser commented 9 years ago

Here are the dependencies:

That last dependency is kind of the tricky bit. ffmpeg split a while back into two projects, the original ffmpeg and a project known as libav. Unfortunately Ubuntu 14.04 ships with libav. You can read this StackOverflow answer to find out a little bit more about the spit.

The problem is, this project was written with ffmpeg in mind, not libav, so I can make no gaurentees to how this will build with libav. According to the SO answer it should be possible to install (I'm not sure if that would be replacing or just installing along side) ffmpeg on 14.04.

iammordaty commented 9 years ago

Thank you for your reply. I was unable to compilie keyfinder-cli in ubuntu 14.04, but due to the fact that I'm using Docker I try to compile your wrapper in 15.05 where the "real ffpmeg" exists. Is there a chance that the wrapper compiles in 15.05?

evanpurkhiser commented 9 years ago

It might compile, but it will link against ffmpegs shared objects.

iammordaty commented 9 years ago

Unfortunately, I was unable to compile the library. Compilation ends with:

root@23cdf49c4898:/data/keyfinder-cli# make
mkdir -p bin
g++ -std=c++11 -Wall -lkeyfinder -lboost_system -lm -lz -lavresample -lavformat -lavcodec -lavutil -o keyfinder-cli keyfinder_cli.cpp
/tmp/ccfzW8ZY.o: In function `fill_audio_data(char const*, KeyFinder::AudioData&)::{lambda()#1}::operator()() const':
keyfinder_cli.cpp:(.text+0xe5): undefined reference to `av_register_all'
/tmp/ccfzW8ZY.o: In function `fill_audio_data(char const*, KeyFinder::AudioData&)::{lambda(AVAudioResampleContext*)#2}::operator()(AVAudioResampleContext*) const':
keyfinder_cli.cpp:(.text+0x104): undefined reference to `avresample_free'
/tmp/ccfzW8ZY.o: In function `fill_audio_data(char const*, KeyFinder::AudioData&)':
keyfinder_cli.cpp:(.text+0x148): undefined reference to `avformat_alloc_context'
keyfinder_cli.cpp:(.text+0x16f): undefined reference to `avformat_open_input'
keyfinder_cli.cpp:(.text+0x1b5): undefined reference to `avformat_free_context'
keyfinder_cli.cpp:(.text+0x1d4): undefined reference to `avformat_find_stream_info'
keyfinder_cli.cpp:(.text+0x2ea): undefined reference to `avcodec_find_decoder'
keyfinder_cli.cpp:(.text+0x345): undefined reference to `avcodec_open2'
keyfinder_cli.cpp:(.text+0x37d): undefined reference to `avresample_alloc_context'
keyfinder_cli.cpp:(.text+0x3d8): undefined reference to `av_get_default_channel_layout'
keyfinder_cli.cpp:(.text+0x412): undefined reference to `av_opt_set_int'
keyfinder_cli.cpp:(.text+0x43b): undefined reference to `av_opt_set_int'
keyfinder_cli.cpp:(.text+0x465): undefined reference to `av_opt_set_int'
keyfinder_cli.cpp:(.text+0x483): undefined reference to `av_opt_set_int'
keyfinder_cli.cpp:(.text+0x4ac): undefined reference to `av_opt_set_int'
/tmp/ccfzW8ZY.o:keyfinder_cli.cpp:(.text+0x4d6): more undefined references to `av_opt_set_int' follow
/tmp/ccfzW8ZY.o: In function `fill_audio_data(char const*, KeyFinder::AudioData&)':
keyfinder_cli.cpp:(.text+0x4e5): undefined reference to `avresample_open'
keyfinder_cli.cpp:(.text+0x538): undefined reference to `KeyFinder::AudioData::setFrameRate(unsigned int)'
keyfinder_cli.cpp:(.text+0x558): undefined reference to `KeyFinder::AudioData::setChannels(unsigned int)'
keyfinder_cli.cpp:(.text+0x569): undefined reference to `av_frame_alloc'
keyfinder_cli.cpp:(.text+0x578): undefined reference to `av_free'
keyfinder_cli.cpp:(.text+0x65e): undefined reference to `avcodec_decode_audio4'
keyfinder_cli.cpp:(.text+0x718): undefined reference to `av_frame_alloc'
keyfinder_cli.cpp:(.text+0x727): undefined reference to `av_free'
keyfinder_cli.cpp:(.text+0x7dd): undefined reference to `avresample_convert_frame'
keyfinder_cli.cpp:(.text+0x885): undefined reference to `KeyFinder::AudioData::getSampleCount() const'
keyfinder_cli.cpp:(.text+0x8a2): undefined reference to `KeyFinder::AudioData::addToSampleCount(unsigned int)'
keyfinder_cli.cpp:(.text+0x8b1): undefined reference to `KeyFinder::AudioData::resetIterators()'
keyfinder_cli.cpp:(.text+0x8c8): undefined reference to `KeyFinder::AudioData::advanceWriteIterator(unsigned int)'
keyfinder_cli.cpp:(.text+0x917): undefined reference to `KeyFinder::AudioData::setSampleAtWriteIterator(double)'
keyfinder_cli.cpp:(.text+0x92b): undefined reference to `KeyFinder::AudioData::advanceWriteIterator(unsigned int)'
/tmp/ccfzW8ZY.o: In function `main':
keyfinder_cli.cpp:(.text+0xe11): undefined reference to `KeyFinder::AudioData::AudioData()'
keyfinder_cli.cpp:(.text+0xe28): undefined reference to `av_log_set_callback'
keyfinder_cli.cpp:(.text+0xe5a): undefined reference to `KeyFinder::KeyFinder::keyOfAudio(KeyFinder::AudioData const&)'
/tmp/ccfzW8ZY.o: In function `SafeAVPacket::SafeAVPacket()':
keyfinder_cli.cpp:(.text._ZN12SafeAVPacketC2Ev[_ZN12SafeAVPacketC5Ev]+0x14): undefined reference to `av_init_packet'
/tmp/ccfzW8ZY.o: In function `SafeAVPacket::~SafeAVPacket()':
keyfinder_cli.cpp:(.text._ZN12SafeAVPacketD2Ev[_ZN12SafeAVPacketD5Ev]+0x21): undefined reference to `av_free_packet'
/tmp/ccfzW8ZY.o: In function `SafeAVPacket::read(AVFormatContext*, int)':
keyfinder_cli.cpp:(.text._ZN12SafeAVPacket4readEP15AVFormatContexti[_ZN12SafeAVPacket4readEP15AVFormatContexti]+0x28): undefined reference to `av_free_packet'
keyfinder_cli.cpp:(.text._ZN12SafeAVPacket4readEP15AVFormatContexti[_ZN12SafeAVPacket4readEP15AVFormatContexti]+0x3b): undefined reference to `av_read_frame'
/tmp/ccfzW8ZY.o: In function `KeyFinder::KeyFinder::KeyFinder()':
keyfinder_cli.cpp:(.text._ZN9KeyFinder9KeyFinderC2Ev[_ZN9KeyFinder9KeyFinderC5Ev]+0x15): undefined reference to `KeyFinder::LowPassFilterFactory::LowPassFilterFactory()'
keyfinder_cli.cpp:(.text._ZN9KeyFinder9KeyFinderC2Ev[_ZN9KeyFinder9KeyFinderC5Ev]+0x25): undefined reference to `KeyFinder::ChromaTransformFactory::ChromaTransformFactory()'
keyfinder_cli.cpp:(.text._ZN9KeyFinder9KeyFinderC2Ev[_ZN9KeyFinder9KeyFinderC5Ev]+0x35): undefined reference to `KeyFinder::TemporalWindowFactory::TemporalWindowFactory()'
keyfinder_cli.cpp:(.text._ZN9KeyFinder9KeyFinderC2Ev[_ZN9KeyFinder9KeyFinderC5Ev]+0x4a): undefined reference to `KeyFinder::ChromaTransformFactory::~ChromaTransformFactory()'
keyfinder_cli.cpp:(.text._ZN9KeyFinder9KeyFinderC2Ev[_ZN9KeyFinder9KeyFinderC5Ev]+0x5b): undefined reference to `KeyFinder::LowPassFilterFactory::~LowPassFilterFactory()'
/tmp/ccfzW8ZY.o: In function `KeyFinder::KeyFinder::~KeyFinder()':
keyfinder_cli.cpp:(.text._ZN9KeyFinder9KeyFinderD2Ev[_ZN9KeyFinder9KeyFinderD5Ev]+0x18): undefined reference to `KeyFinder::TemporalWindowFactory::~TemporalWindowFactory()'
keyfinder_cli.cpp:(.text._ZN9KeyFinder9KeyFinderD2Ev[_ZN9KeyFinder9KeyFinderD5Ev]+0x28): undefined reference to `KeyFinder::ChromaTransformFactory::~ChromaTransformFactory()'
keyfinder_cli.cpp:(.text._ZN9KeyFinder9KeyFinderD2Ev[_ZN9KeyFinder9KeyFinderD5Ev]+0x34): undefined reference to `KeyFinder::LowPassFilterFactory::~LowPassFilterFactory()'
collect2: error: ld returned 1 exit status
Makefile:4: recipe for target 'keyfinder-cli' failed
make: *** [keyfinder-cli] Error 1
evanpurkhiser commented 9 years ago

What version of ffmpeg are you building against?

iammordaty commented 9 years ago
root@23cdf49c4898:/data/keyfinder-cli# apt-cache show libavresample-dev | grep Version
Version: 7:2.7.2-1build1
root@23cdf49c4898:/data/keyfinder-cli# apt-cache show libavcodec-dev | grep Version
Version: 7:2.7.2-1build1
root@23cdf49c4898:/data/keyfinder-cli# apt-cache show libavutil-dev | grep Version
Version: 7:2.7.2-1build1
root@23cdf49c4898:/data/keyfinder-cli# apt-cache show libavformat-dev | grep Version
Version: 7:2.7.2-1build1
evanpurkhiser commented 9 years ago

Are you sure that's ffmpeg and not libav. The whole thing between them is really confusing to be honest.

The ffmpeg version I have on my machine is 1:2.7

iammordaty commented 9 years ago

Yes, i'm sure - http://www.webupd8.org/2014/11/ffmpeg-returns-to-official-ubuntu.html

I've installed following packages:

apt-get install libavutil-ffmpeg-dev
apt-get install libavresample-ffmpeg-dev
apt-get install libavcodec-ffmpeg-dev
apt-get install libavformat-ffmpeg-dev

I use Ubuntu 15.10 from https://hub.docker.com/_/ubuntu/

iammordaty commented 9 years ago

Little update: on fresh docker image i've compiled ffmpeg (followed by https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu), but I'm still getting the following error.

root@0e5f2d7fbec2:~/keyfinder-cli# make
mkdir -p bin
g++ -std=c++11 -Wall -lkeyfinder -lboost_system -lavcodec -lavformat -lavutil -lavresample -o keyfinder-cli keyfinder_cli.cpp
/tmp/ccqlfYeL.o: In function `fill_audio_data(char const*, KeyFinder::AudioData&)::{lambda()#1}::operator()() const':
keyfinder_cli.cpp:(.text+0xe5): undefined reference to `av_register_all'
/tmp/ccqlfYeL.o: In function `fill_audio_data(char const*, KeyFinder::AudioData&)::{lambda(AVAudioResampleContext*)#2}::operator()(AVAudioResampleContext*) const':
keyfinder_cli.cpp:(.text+0x104): undefined reference to `avresample_free'
/tmp/ccqlfYeL.o: In function `fill_audio_data(char const*, KeyFinder::AudioData&)':
keyfinder_cli.cpp:(.text+0x148): undefined reference to `avformat_alloc_context'
keyfinder_cli.cpp:(.text+0x16f): undefined reference to `avformat_open_input'
keyfinder_cli.cpp:(.text+0x1b5): undefined reference to `avformat_free_context'
keyfinder_cli.cpp:(.text+0x1d4): undefined reference to `avformat_find_stream_info'
[...]
/tmp/ccqlfYeL.o: In function `KeyFinder::KeyFinder::KeyFinder()':
keyfinder_cli.cpp:(.text._ZN9KeyFinder9KeyFinderC2Ev[_ZN9KeyFinder9KeyFinderC5Ev]+0x15): undefined reference to `KeyFinder::LowPassFilterFactory::LowPassFilterFactory()'
keyfinder_cli.cpp:(.text._ZN9KeyFinder9KeyFinderC2Ev[_ZN9KeyFinder9KeyFinderC5Ev]+0x25): undefined reference to `KeyFinder::ChromaTransformFactory::ChromaTransformFactory()'
keyfinder_cli.cpp:(.text._ZN9KeyFinder9KeyFinderC2Ev[_ZN9KeyFinder9KeyFinderC5Ev]+0x35): undefined reference to `KeyFinder::TemporalWindowFactory::TemporalWindowFactory()'
keyfinder_cli.cpp:(.text._ZN9KeyFinder9KeyFinderC2Ev[_ZN9KeyFinder9KeyFinderC5Ev]+0x4a): undefined reference to `KeyFinder::ChromaTransformFactory::~ChromaTransformFactory()'
keyfinder_cli.cpp:(.text._ZN9KeyFinder9KeyFinderC2Ev[_ZN9KeyFinder9KeyFinderC5Ev]+0x5b): undefined reference to `KeyFinder::LowPassFilterFactory::~LowPassFilterFactory()'
/tmp/ccqlfYeL.o: In function `KeyFinder::KeyFinder::~KeyFinder()':
keyfinder_cli.cpp:(.text._ZN9KeyFinder9KeyFinderD2Ev[_ZN9KeyFinder9KeyFinderD5Ev]+0x18): undefined reference to `KeyFinder::TemporalWindowFactory::~TemporalWindowFactory()'
keyfinder_cli.cpp:(.text._ZN9KeyFinder9KeyFinderD2Ev[_ZN9KeyFinder9KeyFinderD5Ev]+0x28): undefined reference to `KeyFinder::ChromaTransformFactory::~ChromaTransformFactory()'
keyfinder_cli.cpp:(.text._ZN9KeyFinder9KeyFinderD2Ev[_ZN9KeyFinder9KeyFinderD5Ev]+0x34): undefined reference to `KeyFinder::LowPassFilterFactory::~LowPassFilterFactory()'
collect2: error: ld returned 1 exit status
Makefile:4: recipe for target 'keyfinder-cli' failed
make: *** [keyfinder-cli] Error 1

ffmpeg:

root@0e5f2d7fbec2:~/keyfinder-cli# ffmpeg   
ffmpeg version N-75077-g309fb6b Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 5.2.1 (Ubuntu 5.2.1-16ubuntu1) 20150903
  configuration: --prefix=/root/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/root/ffmpeg_build/include --extra-ldflags=-L/root/ffmpeg_build/lib --bindir=/root/bin --enable-gpl --enable-libass --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-nonfree --enable-avresample

My g++ version:

root@0e5f2d7fbec2:~/keyfinder-cli# g++ --version
g++ (Ubuntu 5.2.1-16ubuntu1) 5.2.1 20150903

Any advices?

evanpurkhiser commented 9 years ago

I'll mess about with this in a docker instance right now and see what I can do :-)

iammordaty commented 9 years ago

Thanks!

evanpurkhiser commented 9 years ago

TL;DR; I didn't actually see what I could do, oops

So I'm a little ashamed to say I actually hadn't even tried to build the project since you opened the issue a few weeks ago! Looks like @ibsh released a whole new version of libkeyfinder since I last built this tool! (Fingers crossed for more accurate key detection!)

There were some very minimal changes that need to be made for the project to successfully build, but I got a little side tracked fixing the ArchLinux AUR package for libkeyfinder and didn't have a chance to look into your particular build problem tonight.

ibsh commented 9 years ago

It has slightly more accurate key detection. =) http://ibrahimshaath.co.uk/keyfinder/comparison.pdf

evanpurkhiser commented 9 years ago

@iammordaty While setting up TravisCI for this project I came across what I believe is the solution to your problem. It definitely stems from my inexperience with compiling C/++ code :-)

From what I can tell, there's a difference between what is available on Arch and Ubuntu in terms of static and dynamic libraries. On Arch Linux things appear to be dynamically linked, when compiling on Ubuntu, things seem to be statically linked. I haven't found exactly what i want to confirm this theory by googling around so what I just said might be completely wrong.. but the flag order definitely doesn't matter on Arch.

Anyway, I've pushed out a fix to the Makefile that should hopefully solve this problem! f90cd0ebdc37864836ded06e2f8f7c2e91a989f0

Let me know if that fixes things!

PS: Sorry that it's taken me so long to look into this!

iammordaty commented 9 years ago

@EvanPurkhiser Yes, that was it! Thank you very much for your help!

root@3f1f77bfc4bf:/data/keyfinder-cli# make
g++ keyfinder_cli.cpp -std=c++11 -Wall -lkeyfinder -lavcodec -lavformat -lavutil -lavresample -o keyfinder-cli
root@3f1f77bfc4bf:/data/keyfinder-cli# make install
install -Dm 755 keyfinder-cli "/usr/local/bin/keyfinder-cli"
install -Dm 644 keyfinder-cli.1 "/usr/local/share/man/man1/keyfinder-cli.1"
root@3f1f77bfc4bf:/data/keyfinder-cli# keyfinder_cli file.mp3 
D
root@3f1f77bfc4bf:/data/keyfinder-cli#