arvidn / libtorrent

an efficient feature complete C++ bittorrent implementation
http://libtorrent.org
Other
5.15k stars 994 forks source link

Trubles during compilation by OpenWRT #6449

Closed Deema35 closed 2 years ago

Deema35 commented 3 years ago

libtorrent version (or branch):2.0.4

platform/architecture: OpenWRT crosplatform compail

compiler and compiler version: gcc

Hi. I try compile libtorrent 2.0.4 with qbittorrent for OpenWRT. And when I do it I have got errors such:

_In file included from /usr/include/bits/local_lim.h:38,
                 from /usr/include/bits/posix1_lim.h:161,
                 from /usr/include/limits.h:183,
                 from ../../qt-everywhere-src-5.15.2/ipkg-install/usr/include/QtCore/qlist.h:60,
                 from ../../qt-everywhere-src-5.15.2/ipkg-install/usr/include/QtCore/qobject.h:49,
                 from ../../qt-everywhere-src-5.15.2/ipkg-install/usr/include/QtCore/QObject:1,
                 from app/applicationinstancemanager.h:31,
                 from app/applicationinstancemanager.cpp:29:
/usr/include/linux/limits.h:7: warning: "NGROUPS_MAX" redefined
    7 | #define NGROUPS_MAX    65536 /* supplemental group IDs are available */
      | 
In file included from /usr/include/limits.h:124,
                 from ../../qt-everywhere-src-5.15.2/ipkg-install/usr/include/QtCore/qlist.h:60,
                 from ../../qt-everywhere-src-5.15.2/ipkg-install/usr/include/QtCore/qobject.h:49,
                 from ../../qt-everywhere-src-5.15.2/ipkg-install/usr/include/QtCore/qiodevice.h:45,
                 from ../../qt-everywhere-src-5.15.2/ipkg-install/usr/include/QtCore/qfiledevice.h:43,
                 from ../../qt-everywhere-src-5.15.2/ipkg-install/usr/include/QtCore/qfile.h:44,
                 from ../../qt-everywhere-src-5.15.2/ipkg-install/usr/include/QtCore/QFile:1,
                 from app/filelogger.h:31,
                 from app/filelogger.cpp:29:
/home/dmitriy/MyProk/openwrt/staging_dir/toolchain-aarch64_cortex-a53_gcc-10.3.0_musl/include/limits.h:46: note: this is the location of the previous definition
   46 | #define NGROUPS_MAX 32_

And also I have got this warning from cmake:

CMake Warning (dev) at torrent-rasterbar-pkgconfig/compile-settings-expanded.cmake:3 (set):
  Policy CMP0053 is not set: Simplify variable reference and escape sequence
  evaluation.  Run "cmake --help-policy CMP0053" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  For input:

    ';@CMAKE_INSTALL_PREFIX@/include'

  the old evaluation rules produce:

    ';/usr/include'

  but the new evaluation rules produce:

    ';@CMAKE_INSTALL_PREFIX@/include

  Using the old result for compatibility since the policy is not set.
Call Stack (most recent call first):
  torrent-rasterbar-pkgconfig/generate-pkg-config.cmake:1 (include)
  cmake_install.cmake:46 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at torrent-rasterbar-pkgconfig/generate-pkg-config.cmake:5 (list):
  Policy CMP0007 is not set: list command no longer ignores empty elements.
  Run "cmake --help-policy CMP0007" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.  List has value =
  [TORRENT_LINKING_SHARED;;BOOST_ASIO_ENABLE_CANCELIO;BOOST_ASIO_NO_DEPRECATED;TORRENT_USE_OPENSSL;TORRENT_USE_LIBCRYPTO;TORRENT_SSL_PEERS;OPENSSL_NO_SSL2].
Call Stack (most recent call first):
  torrent-rasterbar-pkgconfig/generate-pkg-config.cmake:46 (cmake_list_to_pkg_config)
  cmake_install.cmake:46 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at torrent-rasterbar-pkgconfig/generate-pkg-config.cmake:5 (list):
  Policy CMP0007 is not set: list command no longer ignores empty elements.
  Run "cmake --help-policy CMP0007" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.  List has value =
  [;/usr/include].
Call Stack (most recent call first):
  torrent-rasterbar-pkgconfig/generate-pkg-config.cmake:47 (cmake_list_to_pkg_config)
  cmake_install.cmake:46 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

This is file torrent-rasterbar-pkgconfig/compile-settings-expanded.cmake:

set(_TARGET_INTERFACE_LINK_LIBRARIES "/home/dmitriy/MyProk/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/lib/libssl.so;/home/dmitriy/MyProk/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/lib/libcrypto.so")
set(_TARGET_INTERFACE_COMPILE_OPTIONS "-fexceptions")
set(_TARGET_INTERFACE_INCLUDE_DIRS ";@CMAKE_INSTALL_PREFIX@/include")
set(_TARGET_INTERFACE_DEFINITIONS "TORRENT_LINKING_SHARED;;BOOST_ASIO_ENABLE_CANCELIO;BOOST_ASIO_NO_DEPRECATED;TORRENT_USE_OPENSSL;TORRENT_USE_LIBCRYPTO;TORRENT_SSL_PEERS;OPENSSL_NO_SSL2")
set(_TARGET_OUTPUT_NAME "torrent-rasterbar")

set(_INSTALL_LIBDIR "lib")
set(_INSTALL_INCLUDEDIR "include")
set(_SHARED_LIBRARY_PREFIX "lib")

set(_PROJECT_NAME "libtorrent")
set(_PROJECT_DESCRIPTION "Bittorrent library")
set(_PROJECT_VERSION "2.0.4")

I have removed symbol @ from line:

set(_TARGET_INTERFACE_INCLUDE_DIRS ";@CMAKE_INSTALL_PREFIX@/include")

And It has been compiled right.

userdocs commented 2 years ago

What I cannot see is if libtorrent actually built successfully so do this using these commands

boost_version='77'
build_dir="$HOME/lt-build"
mkdir "$HOME/lt-build" && cd "${build_dir}"

Download boost

curl -sNLk https://boostorg.jfrog.io/artifactory/main/release/1.${boost_version}.0/source/boost_1_${boost_version}_0.tar.gz --create-dirs -o "${build_dir}/boost_1_${boost_version}_0.tar.gz"
tar xf "${build_dir}/boost_1_${boost_version}_0.tar.gz" -C "${build_dir}"
pushd "${build_dir}/boost_1_${boost_version}_0/" || exit
"${build_dir}/boost_1_${boost_version}_0/bootstrap.sh"

Build libtorrent

export BOOST_BUILD_PATH="${build_dir}/boost_1_${boost_version}_0"
git clone --single-branch --branch RC_2_0 --shallow-submodules --recurse-submodules --depth 1 https://github.com/arvidn/libtorrent "${build_dir}/libtorrent"
pushd "${build_dir}/libtorrent" || exit
"${build_dir}/boost_1_${boost_version}_0/b2" -j"$(nproc)" optimization=speed crypto=openssl cxxstd=17 variant=release threading=multi link=static boost-link=static install --prefix="${build_dir}/libs"

Are there any errors in the build at that end? You want to see something like this

gcc.archive bin/gcc-8/release/crypto-openssl/cxxstd-17-iso/link-static/threading-multi/visibility-hidden/libtorrent-rasterbar.a
common.copy /home/username/lt-build/libs/lib/libtorrent-rasterbar.a
...updated 480 targets...
Deema35 commented 2 years ago

Not you don't understen me. Libtorrent build is right. But it generate file torrent-rasterbar-pkgconfig/compile-settings-expanded.cmake with symbols @ and errors appears durring Qbittorrent building. If I remove symbols @ building Qbittorrent prossed too.

I compile Qbittorrent for OpenWRT and it compile with OpenWRT SDK, because of this I can't change building procedure.

userdocs commented 2 years ago

I really don't understand. There is a hard language barrier here.

Taking into account this https://github.com/qbittorrent/qBittorrent/issues/15425 and that you want to use cmake instead of b2

Here is a guide i made for Alpine using cmake and it might help

https://github.com/qbittorrent/qBittorrent/wiki/Compilation:-Alpine-Linux

Deema35 commented 2 years ago

OpenWRT this is not Alpine Linux, this is OS for routers. It have different build system when you build your software with router's firmware together. You can read there https://openwrt.org/docs/guide-developer/package-policies

Yes qbittorrent 4.4.0beta3 not run after compilation, but this is beta release.

I can build Qbittorrent, but every time I need remove symbols @ from file: torrent-rasterbar-pkgconfig/compile-settings-expanded.cmake.

userdocs commented 2 years ago

I think you are not understanding since Alpine linux uses musl and busybox. The working method i gave you for Alpine might help you on this platform.

https://en.wikipedia.org/wiki/OpenWrt > The main components are Linux, util-linux, musl,[4] and BusyBox.

Deema35 commented 2 years ago

I want the file torrent-rasterbar-pkgconfig/compile-settings-expanded.cmake to be generated without simbols @, because it breake qbittorrent building. How this is tutorial can help me?

This is make file for Libtorrent in OpenWRT https://github.com/openwrt/packages/blob/master/libs/libtorrent-rasterbar/Makefile.

userdocs commented 2 years ago

Here is a build made on alpine. The matching aarch should work on your OS.

https://github.com/userdocs/test/releases/tag/release-4.4.0beta3_RC_2_0

You need to show exactly what are you are doing and how. What steps to build , what commands.

Please, show all the commands and steps you use to build otherwise this is very difficult to understand, for me anyway.

Deema35 commented 2 years ago

Yes it's work in spite of my router haven't boost, libtorrent and qt.

What I am doing: 1)git clone https://github.com/openwrt/openwrt 1a) cd openwrt 1b)./scripts/feeds update -a 1c)./scripts/feeds install -a 2) cd package 3)git clone https://github.com/Deema35/qBittorrent-openwrt-package.

Only change version to 4.4.0beta3 and hash in makefile for qbittorrent. And replace depends +rblibtorrent to +libtorrent-rasterbar, because libtorrent 2.0.4 already present in Openwrt. (I am add this file to comment Makefile.zip)

4)make menuconfig - set architecture and board(I use meiateck arm mt7622 banan pi R64) and pick qbittorrent (network/torrent/qbittorrent). 5)make tools/install 6)make toolchain/install 7)make package/qBittorrent/compile

If you want build OpenWRT entirely enter only make.

8)make package/index - create signature (key-build need put in openwrt folder)

Generate keys for signature: 1)git clone https://git.openwrt.org/project/usign.git 2)cd usign 3)cmake . 4)make 5)usign -G -c 'openwrt test repo' -s key-build -p key-build.pub 6)ln -s which usign staging_dir/host/bin/usign

Execute in router: 1)Copy .pub key to /etc/opkg/keys/ key need rename to signature ID in file Packages.sig 2)file:///opt >> /etc/opkg/customfeeds.conf - Add local repository in folder /opt 3) Move file from folder bin/packages/archetecture to folder opt on router 4)opkg update 5)opkg install qbittorrent

Deema35 commented 2 years ago

I found out why Qbittoren don't work https://github.com/qbittorrent/qBittorrent/issues/15425 in short this becose of mismathing my OpenWRT version and version OpenWRT on whitch I compile Qbittorrent.

arvidn commented 2 years ago

so, this is not related to libtorrent, then?

Deema35 commented 2 years ago

Not last post answer to userdocs. Issue described in first post with torrent-rasterbar-pkgconfig/compile-settings-expanded.cmake file.

userdocs commented 2 years ago

If your issue is solved you can close the issue?

Deema35 commented 2 years ago

Not solved.

arvidn commented 2 years ago

@Deema35 as far as I can tell from your description, QT is including a linux header file, and your app includes a musl header file, and they conflict. I don't see how this has anything to do with libtorrent.

Deema35 commented 2 years ago

I don't know cause of trubble. But Qbittorrent had began building only after I have edited file torrent-rasterbar-pkgconfig/compile-settings-expanded.cmake. Early I use libtorrent 1.2.14 and it building good (make file 1.2.14 but when I build Qbittorrent with libtorrent 2.0.4(make file 2.0.4) I have got this trubble.

Deema35 commented 2 years ago

In log you can see that during building system address to /usr/include dir. But It must addres to /toolchain/include dir. This is happen during Qbittorrent compile not Libtorrent but it depends from file torrent-rasterbar-pkgconfig/compile-settings-expanded.cmake witch generate libtorrent.

arvidn commented 2 years ago

Is libtorrent adding this include path to the system includes, and that causes problems?

Deema35 commented 2 years ago

Yes after I had edited torrent-rasterbar-pkgconfig/compile-settings-expanded.cmake this problem disappeared.

Deema35 commented 2 years ago

Hi I have avoid this trouble by moving to Cmake from Autotools for Qbittorrent https://github.com/Deema35/qBittorrent-openwrt-package