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

Lack of documentation, can't build the cpp code #2

Closed
cecton opened this issue Jul 11, 2018 · 13 comments
Closed

Lack of documentation, can't build the cpp code #2

cecton opened this issue Jul 11, 2018 · 13 comments

Comments

@cecton
Copy link

cecton commented Jul 11, 2018

I would like to try things out but I didn't succeed to compile the code properly.

Here is what I installed:

apt-get install libboost-python-dev

Then I ran:

python3 setup.py build

And I ended up with:

running build
running build_py
warning: build_py: byte-compiling is disabled, skipping.

running build_ext
building 'bard_ext' extension
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-MLq5fN/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DMAJOR_VERSION=1 -DMINOR_VERSION=0 -D_GLIBCXX_PARALLEL -I/usr/include/boost -I/usr/include/python3.5m -c bard/bard_ext.cpp -o build/temp.linux-x86_64-3.5/bard/bard_ext.o -std=gnu++17 -fopenmp -Ofast -march=native -mtune=native -funroll-loops
cc1plus: warning: command line option _-Wstrict-prototypes_ is valid for C/ObjC but not for C++
bard/bard_ext.cpp: In lambda function:
bard/bard_ext.cpp:133:20: error: expected unqualified-id before _[_ token
             auto & [itSongID, itFingerprint] = itSong;
                    ^
bard/bard_ext.cpp:133:20: error: expected initializer before _[_ token
bard/bard_ext.cpp:134:18: error: expected unqualified-id before _[_ token
             auto [offset, similarity] = compareChromaprintFingerprintsAndOffset(itFingerprint, v, cancelThreshold);
                  ^
bard/bard_ext.cpp:135:17: error: _similarity_ was not declared in this scope
             if (similarity > cancelThreshold)
                 ^~~~~~~~~~
bard/bard_ext.cpp:138:57: error: _itSongID_ was not declared in this scope
                 result.append(boost::python::make_tuple(itSongID, offset, similarity));
                                                         ^~~~~~~~
bard/bard_ext.cpp:138:67: error: _offset_ was not declared in this scope
                 result.append(boost::python::make_tuple(itSongID, offset, similarity));
                                                                   ^~~~~~
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

I'm running on Debian on WSL

@antlarr
Copy link
Owner

antlarr commented Jul 11, 2018

Hmm, what gcc version are you using? According to the gcc c++ status page, gcc 7 was the first version to support structured bindings. I know for sure gcc 7.3.x and gcc 8.1.x should work fine .

@cecton
Copy link
Author

cecton commented Jul 11, 2018

gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516

Ok thanks! 😖

@antlarr
Copy link
Owner

antlarr commented Jul 11, 2018

I'm sorry but I really want to use modern C++ features since it makes the code much nicer.

I checked and there's a gcc-7 package in sid, so maybe you can try installing just that package from sid?

In any case, thanks for the report!

@cecton
Copy link
Author

cecton commented Jul 11, 2018

Yes this is no problem for me, I just really want to try out XD

If you don't mind helping me (I don't know anything about C++).

Now I keep hitting this:

/usr/bin/ld: cannot find -lboost_python-py3

I made a Dockerfile that might be useful to you if you want to let people build it more easily:

#FROM gcc:7
FROM debian:testing

ADD https://raw.githubusercontent.com/guilhem/apt-get-install/master/apt-get-install /usr/bin/
RUN chmod +x /usr/bin/apt-get-install
RUN apt-get-install libboost-python-dev


ADD . /src

RUN apt-get-install python3-setuptools
RUN apt-get-install build-essential
WORKDIR /src
RUN python3 setup.py build

(It's not cleaned as you can see but I'll produce a proper version when I will succeed to build it)

Full output:

Step 9/9 : RUN python3 setup.py build
 ---> Running in c10ffe7bcd75
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/bard
copying bard/config.py -> build/lib.linux-x86_64-3.6/bard
copying bard/ffprobemetadata.py -> build/lib.linux-x86_64-3.6/bard
copying bard/__init__.py -> build/lib.linux-x86_64-3.6/bard
copying bard/terminalcolors.py -> build/lib.linux-x86_64-3.6/bard
copying bard/musicdatabase.py -> build/lib.linux-x86_64-3.6/bard
copying bard/song.py -> build/lib.linux-x86_64-3.6/bard
copying bard/comparesongs.py -> build/lib.linux-x86_64-3.6/bard
copying bard/bard.py -> build/lib.linux-x86_64-3.6/bard
copying bard/utils.py -> build/lib.linux-x86_64-3.6/bard
copying bard/normalizetags.py -> build/lib.linux-x86_64-3.6/bard
copying bard/__main__.py -> build/lib.linux-x86_64-3.6/bard
running build_ext
building 'bard_ext' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/bard
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DMAJOR_VERSION=1 -DMINOR_VERSION=0 -D_GLIBCXX_PARALLEL -I/usr/include/boost -I/usr/include/python3.6m -c bard/bard_ext.cpp -o build/temp.linux-x86_64-3.6/bard/bard_ext.o -std=gnu++17 -fopenmp -Ofast -march=native -mtune=native -funroll-loops
x86_64-linux-gnu-g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,relro -g -fstack-protector-strong -Wformat
-Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.6/bard/bard_ext.o -lboost_python-py3 -o build/lib.linux-x86_64-3.6/bard_ext.cpython-36m-x86_64-linux-gnu.so
/usr/bin/ld: cannot find -lboost_python-py3
collect2: error: ld returned 1 exit status
error: command 'x86_64-linux-gnu-g++' failed with exit status 1
The command '/bin/sh -c python3 setup.py build' returned a non-zero code: 1

@antlarr
Copy link
Owner

antlarr commented Jul 11, 2018

Can you try changing libraries=['boost_python-py3'], to libraries=['boost_python-py36'], in setup.py? (that is, py3 to py36)

@antlarr
Copy link
Owner

antlarr commented Jul 11, 2018

Btw, you need the mpv player if you want to use the "bard play" command. I'm not sure I documented that anywhere (yes, I should add more documentation, but I wanted to focus on the features first, and the blog post gave it more exposure than I expected :) )

@cecton
Copy link
Author

cecton commented Jul 11, 2018

Thanks Phoronix for that XD

@cecton
Copy link
Author

cecton commented Jul 11, 2018

Success!

Step 7/7 : RUN python3 setup.py build
 ---> Running in e0b375516d7e
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/bard
copying bard/config.py -> build/lib.linux-x86_64-3.6/bard
copying bard/ffprobemetadata.py -> build/lib.linux-x86_64-3.6/bard
copying bard/__init__.py -> build/lib.linux-x86_64-3.6/bard
copying bard/terminalcolors.py -> build/lib.linux-x86_64-3.6/bard
copying bard/musicdatabase.py -> build/lib.linux-x86_64-3.6/bard
copying bard/song.py -> build/lib.linux-x86_64-3.6/bard
copying bard/comparesongs.py -> build/lib.linux-x86_64-3.6/bard
copying bard/bard.py -> build/lib.linux-x86_64-3.6/bard
copying bard/utils.py -> build/lib.linux-x86_64-3.6/bard
copying bard/normalizetags.py -> build/lib.linux-x86_64-3.6/bard
copying bard/__main__.py -> build/lib.linux-x86_64-3.6/bard
running build_ext
building 'bard_ext' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/bard
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DMAJOR_VERSION=1 -DMINOR_VERSION=0 -D_GLIBCXX_PARALLEL -I/usr/include/boost -I/usr/include/python3.6m -c bard/bard_ext.cpp -o build/temp.linux-x86_64-3.6/bard/bard_ext.o -std=gnu++17 -fopenmp -Ofast -march=native -mtune=native -funroll-loops
x86_64-linux-gnu-g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.6/bard/bard_ext.o -lboost_python-py36 -o build/lib.linux-x86_64-3.6/bard_ext.cpython-36m-x86_64-linux-gnu.so
running build_scripts
creating build/scripts-3.6
copying and adjusting scripts/bard -> build/scripts-3.6
changing mode of build/scripts-3.6/bard from 644 to 755
Removing intermediate container e0b375516d7e
 ---> 337f54c11afe
Successfully built 337f54c11afe
Successfully tagged bard:latest

@antlarr
Copy link
Owner

antlarr commented Jul 11, 2018

Great! Congrats, you're probably the first person to build Bard (apart from me :) )

Since I actually didn't test a clean installation yet and I don't currently have much time to work on this, I'll give you here an example config file you can put at ~/.config/bard. You can change all paths to something that make sense to you (the database should be created automatically, you shouldn't have to worry about that).

{ 
    "tmpdir": "/tmp/",
    "databasePath": "/home/antonio/.local/share/bard/music.db",
    "musicPaths": [
        "/home/antonio/music",
        "/home/antonio/music2"
    ],
    "translatePaths": false,
    "pathTranslationMap": [],
    "immutableDatabase" : false,
    "username" : "antonio"
}

@cecton
Copy link
Author

cecton commented Jul 11, 2018

Thanks! I will need that too.

There are a few dependencies probably missing in the setup.py and also the __main__.py should be this:

# -*- coding: utf-8 -*-

from bard.bard import main # was: from bard import main

main()

Dependencies: pydub, gmpy, numpy, dbus-python (not sure if it should be installed that way...),

@cecton
Copy link
Author

cecton commented Jul 11, 2018

FROM debian:testing

ADD https://raw.githubusercontent.com/guilhem/apt-get-install/master/apt-get-install /usr/bin/
RUN chmod +x /usr/bin/apt-get-install
RUN apt-get-install libboost-python-dev python3-setuptools build-essential libchromaprint-dev ca-certificates ffmpeg python3-dbus libgmp-dev
RUN python3 /usr/lib/python3/dist-packages/easy_install.py pyacoustid mutagen Pillow pydub numpy gmpy

ADD . /src
WORKDIR /src

RUN python3 setup.py build

VOLUME /data
VOLUME /music
RUN mkdir -p ~/.config && echo '{"databasePath":"/data/music.db","musicPaths":["/music"]}' > ~/.config/bard

CMD ["python3", "-mbard"]

(not yet finished but better... will finish another day)

antlarr added a commit that referenced this issue Jul 11, 2018
Thanks to @cecton for noticing the missing dependencies in #2
@antlarr
Copy link
Owner

antlarr commented Jul 11, 2018

You can install the scripts/bard file to /usr/bin to execute bard nicely, but yes, you're right I should update __main__.py too. Btw, thanks for the list of missing dependencies! I just removed some unused code so gmpy isn't actually needed anymore.

@cecton
Copy link
Author

cecton commented Jan 7, 2021

Inactive, closing

@cecton cecton closed this as completed Jan 7, 2021
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

2 participants