Skip to content

Failed to compile on Linux due to missing lib #125

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

Closed
KHN190 opened this issue Jun 30, 2020 · 16 comments
Closed

Failed to compile on Linux due to missing lib #125

KHN190 opened this issue Jun 30, 2020 · 16 comments

Comments

@KHN190
Copy link

KHN190 commented Jun 30, 2020

I tried to compile rpfm on Ubuntu 18.04 and failed on building rfpm-ui:

  = note: /usr/bin/ld: cannot find -lqt_subclasses
          collect2: error: ld returned 1 exit status

This is due to a missing lib qt_subclasses. Though I see the command using local ./libs directory which contains a qt_subclasses.lib, I think .lib is not usable for Linux. Can I compile the .so myself using source code?

@Frodo45127
Copy link
Owner

qt_subclasses is compiled from the rpfm_ui/qt_subclasses folder when you compile rpfm_ui. If it's not finding it and you haven't touched the build.rs... maybe there was some error while compiling it? Do you have qt and qmake installed?

@KHN190
Copy link
Author

KHN190 commented Jun 30, 2020

@Frodo45127 I have Qt 5.13.0 built from source (tried 5.15 but it says can't recognize the version and is falling back to closest version 5.13), I also didn't edit source code yet, and for the all 285 building tasks it is the only error I have in compilation..

Does Qt version matter here? In doc and readme the numbers don't meet.

$ qmake --version
QMake version 3.1
Using Qt version 5.13.0 in /usr/local/Qt-5.13.0/lib

@KHN190
Copy link
Author

KHN190 commented Jun 30, 2020

Or if it's easier to add a compiled dylib for Linux under ./libs?

@Frodo45127
Copy link
Owner

any version of qt above 5.8 is enough. You can check why it doesn't compile by compiling it manually. Just go to rpfm_ui/qt_subclasses, then launch qmake, then make. That's really what cargo does when compiling the UI.

@KHN190
Copy link
Author

KHN190 commented Jun 30, 2020

Thanks, that's helpful! I got the error:

$ qmake
Project ERROR: Unknown module(s) in QT: KTextEditor

Means kde framework missing? Tried install libkf5texteditor-dev and libktexteditor4 but neither fix it.

@Madcliff
Copy link

I am getting this same error when trying to build on Arch...

@Frodo45127
Copy link
Owner

Frodo45127 commented Jun 30, 2020

Here on arch, I just needed qt and the ktexteditor (kf5) package, make and qt with qmake. If that doesn't work.... try compiling it with qt-creator. Sometimes that works. Sadly, this falls into the "weird c++ magic" category. Works as-is in some systems, needs modifications and dark rituals on others. And I have no idea why.

@KHN190
Copy link
Author

KHN190 commented Jul 1, 2020

I had some progress today building kf5 from source - the reason I think libkf5texteditor-dev doesn't work is that my Qt is built from source, and so here I had new kde framwork 5: /usr/lib/x86_64-linux-gnu/*.so including libKF5TextEditor.so.

However, when I enter qt_subclasses and manually do qmake I still got:

Project ERROR: Unknown module(s) in QT: KTextEditor

How do I link kf5 to this project (or, the Qt it is using)? This didn't work:

# edit qt_subclasses.pro
LIBS += /usr/lib/x86_64-linux-gnu/

ps. This guideline builds the whole kf5, even though we don't actually need all of them but it's quite informative. Also this post on GitHub helped.

Thanks!

@Frodo45127
Copy link
Owner

After checking a bit on my side, you may need the ktexteditor.pri file. On arch, it gets installed as part of the ktexteditor package, on /usr/lib/qt/mkspecs/modules/qt_KTextEditor.pri. Not sure where it gets installed in other distros, but it may be a clue to why KTextEditor it's not getting found. Also, I'm going to pin this issue, as it may be quite useful to others too in the future.

@Frodo45127 Frodo45127 pinned this issue Jul 1, 2020
@KHN190
Copy link
Author

KHN190 commented Jul 1, 2020

Finally, got it running. :D For anyone who needs to build kf5 with Qt, have a look at the gist.

  1. install Qt, mine was in /usr/local/Qt-5.13.0/
  2. download kf5 source code
  3. in kf5 source code directory run install.sh
  4. verify in qt_subclass dir with qmake
  5. in rpfm run cargo build

@KHN190 KHN190 closed this as completed Jul 1, 2020
@drage0
Copy link

drage0 commented Mar 21, 2021

on fedora 33, fixed by installing kf5-* and adding -I/usr/include/KF5/ to INCPATH in rpfm_ui/qt_subclasses/Makefile. (because /usr/include/KF5/KTextEditor/ktexteditor/editor.h includes <KSyntaxHighlighting/Theme>...)
i have also ran make inside rpfm_ui/qt_subclasses/ before running cargo build again.

@Frodo45127
Copy link
Owner

I got that one too on both arch and windows. The solution for me was to change <KSyntaxHighlighting/Theme> with <KF5/KSyntaxHighlighting/Theme> in editor.h and view.h.

@Madcliff
Copy link

This error is occurring again on the most recent PKGBUILD

@Frodo45127
Copy link
Owner

That error will happen anytime you update/reinstall ktexteditor. It's explained in the docs how to fix it: https://frodo45127.github.io/rpfm/chapter_comp.html

@AaronBPaden
Copy link

@Frodo45127 Hiya, I have an alternative for Arch users.

0001-Add-include-for-Arch.patch

From 5d3a4c43eec2a3a42fcd3b75acf4737430448824 Mon Sep 17 00:00:00 2001
From: Aaron Paden <aaronbpaden@gmail.com>
Date: Mon, 5 Sep 2022 18:46:06 -0500
Subject: [PATCH] Add include for Arch

---
 rpfm_ui/qt_subclasses/qt_subclasses.pro | 1 +
 1 file changed, 1 insertion(+)

diff --git a/rpfm_ui/qt_subclasses/qt_subclasses.pro b/rpfm_ui/qt_subclasses/qt_subclasses.pro
index ca8e6925..a5a443de 100644
--- a/rpfm_ui/qt_subclasses/qt_subclasses.pro
+++ b/rpfm_ui/qt_subclasses/qt_subclasses.pro
@@ -89,6 +89,7 @@ debug:UI_DIR = debug/.ui
 unix {
 
     # For some reason, these flags fuck up compilation on windows, so we leave them linux only.
+    INCLUDEPATH += /usr/include/KF5/KSyntaxHighlighting
     QMAKE_CXXFLAGS = -Wl,-rpath='${ORIGIN}'
 }
 
-- 
2.37.3

We can add this patch to the PKGBUILD like this:

# Maintainer: Frodo45127 <frodo_gv@hotmail.com>
pkgname=('rpfm-git')
pkgver=3.0.14.2611.gfd33755d
pkgrel=1
pkgdesc="Rusted PackFile Manager (RPFM) is a modding tool for modern (since Empire) Total War games."
arch=('x86_64')
url="https://github.com/Frodo45127/rpfm.git"
license=('MIT')
depends=('qt5-base' 'qt5-imageformats' 'xz' 'p7zip')
makedepends=('git' 'rust' 'cmake')
provides=('rpfm')
source=("git+https://github.com/Frodo45127/rpfm.git"
"0001-Add-include-for-Arch.patch")
sha256sums=('SKIP'
            '64b335ea9f4652f2846316ea0883f6da44777cbb1dd62948690335526501841c')
_programname=('rpfm')

pkgver() {
    cd $_programname
    echo "$(grep '^version =' $srcdir/$_programname/rpfm_ui/Cargo.toml|cut -d\" -f2).$(git rev-list --count HEAD).g$(git rev-parse --short HEAD)"
}

prepare() {
    cd $_programname
    patch -p1 <"../0001-Add-include-for-Arch.patch"
}

build() {
    cd $_programname
    env CARGO_INCREMENTAL=0 cargo build --release
}

package() {

    # The executables.
    install -D -m755 "$srcdir/$_programname/target/release/rpfm_ui" "$pkgdir/usr/bin/rpfm_ui"
    install -D -m755 "$srcdir/$_programname/target/release/rpfm_cli" "$pkgdir/usr/bin/rpfm_cli"

    # The icons.
    mkdir -p "$pkgdir/usr/share/$_programname/icons"
    for image in "$srcdir/$_programname/icons/."; do
        cp -R $image "$pkgdir/usr/share/$_programname/icons/"
    done

    # The language files.
    mkdir -p "$pkgdir/usr/share/$_programname/locale"
    for locale in "$srcdir/$_programname/locale/."; do
        cp -R $locale "$pkgdir/usr/share/$_programname/locale/"
    done

    # The UI files.
    mkdir -p "$pkgdir/usr/share/$_programname/ui"
    for ui_template in "$srcdir/$_programname/rpfm_ui/ui_templates/."; do
        cp -R $ui_template "$pkgdir/usr/share/$_programname/ui/"
    done

    # Shortcuts.
    install -D -m644 "$srcdir/$_programname/install/arch/rpfm.desktop" "$pkgdir/usr/share/applications/rpfm.desktop"

    # License.
    install -D -m644 "$srcdir/$_programname/LICENSE" "$pkgdir/usr/share/licenses/$_programname/LICENSE"

    # This one is not in the qt5-imageformats package by default since Qt 5.8.
    #install -D -m644 "$srcdir/$_programname/imageformats/libqdds.so" "$pkgdir/usr/lib/qt/plugins/imageformats/libqdds.so"
}

This way we can avoid running sed on files owned by root.

@Frodo45127
Copy link
Owner

@AaronBPaden Been testing this in develop for a few days, and seems to work quite well. I've replaced the seds with the patch to the pro file for the next version.

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

5 participants