can not compile headless on osx

MAC OS X specific questions, problems.
GereeNice

can not compile headless on osx

Post by GereeNice »

Hey!

Did anyone have success compiling a headless/nox version on osx? I tried to do so from qbittorrent-3.1.9.tar.gz, but I had lots of trouble. First of all libboost libraries were searched as .so files, had to modify the configure script to look for dylib-s. Probably had to make some symlinks too, I am unsure since after the first 5-6 hours I went berserk trying to fix it :D After "fixing", the code compiled, but specifying --disable-gui still generated a gui executable inside the app bundle in src/ .

Tried to brute-force modify files to switch to nox, but - of course - that didn't work out so well.

Since I could not find an official download, I have to ask if anyone had luck with it? Did I miss something? An answer or a compiled binary would be much appreciated :D

Thanks in advance!
sledgehammer_999
Administrator
Administrator
Posts: 2443
Joined: Sun Jan 23, 2011 1:17 pm

Re: can not compile headless on osx

Post by sledgehammer_999 »

Did you try to make a regular build first?
If not the building process is documented in the wiki: https://github.com/qbittorrent/qBittorr ... SX-systems
You could adapt it for -nox. (I haven't build on osx since I don't own a mac).
GereeNice

Re: can not compile headless on osx

Post by GereeNice »

Thanks for your time! Tried your suggestion in a freshly extracted folder.

From the guide qmake qbittorrent.pro is fine, but then make fails with "No targets specified and no makefile found". Trying the ./configure way it fails with libboost not found, but then replacing *.so to *.dylib at line 458 in configure lets me run make after.

And it creates a bundled gui app that runs well. After that I deleted the app, did a make clean and a ./configure --disable-gui && make , but the only output I found was a qbittorrent.app bundle in src/ and I could not find a qbittorrent-nox file neither in that bundle, nor anywhere else.

Summed up, normal seems to work but the headless switch feels like if it's not doing anything.
sledgehammer_999
Administrator
Administrator
Posts: 2443
Joined: Sun Jan 23, 2011 1:17 pm

Re: can not compile headless on osx

Post by sledgehammer_999 »

Maybe it doesn't name it qbittorrent-nox (not sure again)
Also the other 2 builders(stickies) didn't mention anything about boost extensions...
Btw do you build on mavericks?
GereeNice

Re: can not compile headless on osx

Post by GereeNice »

Nope, I'm on 10.8 (M. Lion).

Since you mentioned not having a mac, I'd like to point out that an app bundle is basically a directory ending with ".app", containing some required (and all other) files at specific places, including the binary itself. It virtually acts as a single-file application with its own icon (if you double click it, it gets executed instead of opening up), adding itself to the dock showing it's running, etc.. Just in case you are not familiar with it, sorry for the lecture if you were  :-\  :)

On the other hand, a simple binary is the same as on linux, one file that can be executed through terminal. Getting the full bundled app for a program that's supposed to run as a service is illogical, that's why I thought something is wrong. I am pretty sure compiling in headless mode should give a single unix executable file. Running from a bundle is not only unnecessary, but even prevents it from running in the background. And unfortunately the executable file in the directory structure is definitely a gui app, not just mistakenly put in there.

Can the nogui switch get lost somewhere while compiling due to some mac-specific additions or conditions in one of the scripts? I can't rule out that my system is broken but I pretty much followed the guide and the one modification I had to make is only formal and doesn't seem relevant.

I think it would be no surprise if noone tried to make a headless build on osx nowadays, since for the common mac user it would be useless :)
sledgehammer_999
Administrator
Administrator
Posts: 2443
Joined: Sun Jan 23, 2011 1:17 pm

Re: can not compile headless on osx

Post by sledgehammer_999 »

Actually in src.pro the binary name is defined as qbittorrent-nox
On linux it seems that the --disable-gui option is enough.
I don't know why this doesn't work on mac. Maybe qt problem(qmake is used for the build)?
I suggest building the nox version in a new folder. I read somewhere that osx caches the files, so even after "make clean" you might see the older files when doing a new build.
GereeNice

Re: can not compile headless on osx

Post by GereeNice »

I don't call quake directly but it is invoked in configure. Tried to build in a new folder again, only the nox version and it's all the same.

I tried to play with src.pro before and I realised that the "else" branch is the one that's executed at line 25. Meaning that configured with nogui it goes to target=qbittorrent for some reason. If I change that line to anything, it will make the bundled app with the name specified there. The TARGET = qbittorrent-nox block, and therefore probably all other nox-specific conditions are skipped.

That is what I meant in my first post as brute force fixing files, exchanging the nox related if-else blocks. But then I got a failure that a library is not x86_64 compatible or something and I just quit, saying it's too much hacking and I must have created more errors than solving.

nox {
  QT -= gui
  TARGET = qbittorrent-nox
  DEFINES += DISABLE_GUI

} else {
  QT += xml
  CONFIG(static) {
    DEFINES += QBT_STATIC_QT
    QTPLUGIN += qico
  }
  TARGET = qbittorrent
}
sledgehammer_999
Administrator
Administrator
Posts: 2443
Joined: Sun Jan 23, 2011 1:17 pm

Re: can not compile headless on osx

Post by sledgehammer_999 »

Let's track this down.
The configure script creates a conf.pri file in the root dir. What are its contents?
Try putting this line at the start of the file:

Code: Select all

CONFIG += nox
sledgehammer_999
Administrator
Administrator
Posts: 2443
Joined: Sun Jan 23, 2011 1:17 pm

Re: can not compile headless on osx

Post by sledgehammer_999 »

Oh and the src.pro probably should look like this:
(try this only if the above post fails and in combination with the above post)

Code: Select all

nox {
  QT -= gui
  TARGET = qbittorrent-nox
  DEFINES += DISABLE_GUI
} else {
  QT += xml
  CONFIG(static) {
    DEFINES += QBT_STATIC_QT
    QTPLUGIN += qico
    TARGET = qbittorrent
  }  
}
GereeNice

Re: can not compile headless on osx

Post by GereeNice »

conf.pri already had it, but to be sure, I added it right after the comment one more time. Didn't seem to have any effect.

Code: Select all

# qconf

{here}

PREFIX = /usr/local
BINDIR = /usr/local/bin
DATADIR = /usr/local/share

INCLUDEPATH += /usr/local/Cellar/libtorrent-rasterbar/0.16.15/include /usr/local/Cellar/libtorrent-rasterbar/0.16.15/include/libtorrent /usr/local/include
LIBS += -lboost_system-mt.dy
CONFIG += nox
CONFIG -= debug
CONFIG += release
MANPREFIX = $$PREFIX/share
Moving TARGET inside the config bracket in src.pro caused the output to be src.app instead of qbittorrent.app . It won't run by double clicking, but I can run the executable from inside manually, which opens up the gui app.

I did not try to mix them since the second attempt seemingly corrupts the output.
sledgehammer_999
Administrator
Administrator
Posts: 2443
Joined: Sun Jan 23, 2011 1:17 pm

Re: can not compile headless on osx

Post by sledgehammer_999 »

Pff the problem might be simpler than thought. I thought that osx used unixconf.pri too, but no it has it's own(macxconf.pri).
You can either put CONFIG += nox in there OR copy the relevant lines for the conf.pri from unixconf.pri.
I suggest doing the former first.
GereeNice

Re: can not compile headless on osx

Post by GereeNice »

The macxconf.pri addition is progress, now it makes a correctly named qbittorrent-nox bundle. (Though I still think it shouldn't pack it up like this).

Unfortunately I ran into some compilation issues, the same I had with my own brute force fixes. One step forward, one step back.

Code: Select all

Undefined symbols for architecture x86_64:
  "MainWindow::MainWindow(QWidget*, QStringList const&)", referenced from:
      _main in main.o
  "QMainWindow::~QMainWindow()", referenced from:
      MainWindow::~MainWindow() in main.o
  "QMessageBox::setWindowTitle(QString const&)", referenced from:
      ShutdownConfirmDlg::ShutdownConfirmDlg(QString const&) in qbtsession.o
      LegalNotice::userAgreesWithNotice() in main.o
  "QMessageBox::setIcon(QMessageBox::Icon)", referenced from:
      ShutdownConfirmDlg::ShutdownConfirmDlg(QString const&) in qbtsession.o
  "QMessageBox::setText(QString const&)", referenced from:
      ShutdownConfirmDlg::ShutdownConfirmDlg(QString const&) in qbtsession.o
      LegalNotice::userAgreesWithNotice() in main.o
  "QMessageBox::addButton(QMessageBox::StandardButton)", referenced from:
      ShutdownConfirmDlg::ShutdownConfirmDlg(QString const&) in qbtsession.o
  "QMessageBox::addButton(QString const&, QMessageBox::ButtonRole)", referenced from:
      LegalNotice::userAgreesWithNotice() in main.o
  "QMessageBox::QMessageBox(QWidget*)", referenced from:
      LegalNotice::userAgreesWithNotice() in main.o
  "QMessageBox::QMessageBox(QWidget*)", referenced from:
      ShutdownConfirmDlg::ShutdownConfirmDlg(QString const&) in qbtsession.o
  "QMessageBox::~QMessageBox()", referenced from:
      LegalNotice::userAgreesWithNotice() in main.o
  "QMessageBox::~QMessageBox()", referenced from:
      ShutdownConfirmDlg::askForConfirmation(QString const&) in qbtsession.o
      ShutdownConfirmDlg::~ShutdownConfirmDlg() in qbtsession.o
      non-virtual thunk to ShutdownConfirmDlg::~ShutdownConfirmDlg() in qbtsession.o
      ShutdownConfirmDlg::ShutdownConfirmDlg(QString const&) in qbtsession.o
      ShutdownConfirmDlg::~ShutdownConfirmDlg() in qbtsession.o
      non-virtual thunk to ShutdownConfirmDlg::~ShutdownConfirmDlg() in qbtsession.o
  "GeoIPManager::loadDatabase(libtorrent::session*)", referenced from:
      QBtSession::configureSession() in qbtsession.o
  "IconProvider::getIconPath(QString const&)", referenced from:
      HttpConnection::respond() in httpconnection.o
  "IconProvider::instance()", referenced from:
      HttpConnection::respond() in httpconnection.o
  "QApplication::setStyleSheet(QString const&)", referenced from:
      _main in main.o
  "QApplication::setLayoutDirection(Qt::LayoutDirection)", referenced from:
      _main in main.o
  "QApplication::setQuitOnLastWindowClosed(bool)", referenced from:
      _main in main.o
  "QApplication::exec()", referenced from:
      _main in main.o
  "QApplication::desktop()", referenced from:
      misc::screenCenter(QWidget*) in misc.o
  "QApplication::palette()", referenced from:
      QBtSession::QBtSession() in qbtsession.o
      QBtSession::configureSession() in qbtsession.o
      QBtSession::processBigRatios() in qbtsession.o
      QBtSession::deleteTorrent(QString const&, bool) in qbtsession.o
      QBtSession::initWebUi() in qbtsession.o
      QBtSession::addMagnetUri(QString, bool, bool, QString const&) in qbtsession.o
      QBtSession::addTorrent(QString, bool, QString, bool) in qbtsession.o
      ...
  "QApplication::~QApplication()", referenced from:
      _main in main.o
      QMacApplication::~QMacApplication() in main.o
      QMacApplication::~QMacApplication() in main.o
  "QFontMetrics::~QFontMetrics()", referenced from:
      _main in main.o
  "QSplashScreen::QSplashScreen(QPixmap const&, QFlags<Qt::WindowType>)", referenced from:
      _main in main.o
  "QMacApplication::setReadyToProcessEvents()", referenced from:
      _main in main.o
  "SessionApplication::SessionApplication(QString const&, int&, char**)", referenced from:
      _main in main.o
  "ShutdownConfirmDlg::staticMetaObject", referenced from:
      ShutdownConfirmDlg::ShutdownConfirmDlg(QString const&) in qbtsession.o
  "QtSingleApplication::sendMessage(QString const&, int)", referenced from:
      _main in main.o
  "QtSingleApplication::setActivationWindow(QWidget*, bool)", referenced from:
      _main in main.o
  "QtSingleApplication::isRunning()", referenced from:
      _main in main.o
  "QPen::QPen(QColor const&)", referenced from:
      _main in main.o
  "QPen::~QPen()", referenced from:
      _main in main.o
  "QFont::insertSubstitution(QString const&, QString const&)", referenced from:
      _main in main.o
  "QFont::QFont(QString const&, int, int, bool)", referenced from:
      _main in main.o
  "QFont::~QFont()", referenced from:
      _main in main.o
  "QColor::setNamedColor(QString const&)", referenced from:
      QBtSession::configureSession() in qbtsession.o
      QBtSession::setListeningPort(int) in qbtsession.o
      QBtSession::initWebUi() in qbtsession.o
      QBtSession::addTorrent(QString, bool, QString, bool) in qbtsession.o
      QBtSession::readAlerts() in qbtsession.o
      QBtSession::handleIPFilterError() in qbtsession.o
      Smtp::logError(QString const&) in smtp.o
      ...
  "QColor::QColor(Qt::GlobalColor)", referenced from:
      _main in main.o
  "QColor::QColor(unsigned int)", referenced from:
      QBtSession::downloadFromUrl(QString const&, QList<QNetworkCookie> const&) in qbtsession.o
  "QCursor::pos()", referenced from:
      misc::screenCenter(QWidget*) in misc.o
  "QDialog::exec()", referenced from:
      ShutdownConfirmDlg::askForConfirmation(QString const&) in qbtsession.o
      LegalNotice::userAgreesWithNotice() in main.o
  "QPixmap::QPixmap(QString const&, char const*, QFlags<Qt::ImageConversionFlag>)", referenced from:
      _main in main.o
  "QPixmap::~QPixmap()", referenced from:
      _main in main.o
  "QWidget::setWindowFlags(QFlags<Qt::WindowType>)", referenced from:
      ShutdownConfirmDlg::ShutdownConfirmDlg(QString const&) in qbtsession.o
  "QWidget::move(QPoint const&)", referenced from:
      ShutdownConfirmDlg::ShutdownConfirmDlg(QString const&) in qbtsession.o
      LegalNotice::userAgreesWithNotice() in main.o
  "QPainter::setPen(QPen const&)", referenced from:
      _main in main.o
  "QPainter::setFont(QFont const&)", referenced from:
      _main in main.o
  "QPainter::drawText(QPointF const&, QString const&)", referenced from:
      _main in main.o
  "QPainter::QPainter(QPaintDevice*)", referenced from:
      _main in main.o
  "QPainter::~QPainter()", referenced from:
      _main in main.o
  "QPalette::~QPalette()", referenced from:
      QBtSession::QBtSession() in qbtsession.o
      QBtSession::configureSession() in qbtsession.o
      QBtSession::processBigRatios() in qbtsession.o
      QBtSession::deleteTorrent(QString const&, bool) in qbtsession.o
      QBtSession::initWebUi() in qbtsession.o
      QBtSession::addMagnetUri(QString, bool, bool, QString const&) in qbtsession.o
      QBtSession::addTorrent(QString, bool, QString, bool) in qbtsession.o
      ...
  "QMessageBox::clickedButton() const", referenced from:
      LegalNotice::userAgreesWithNotice() in main.o
  "QFontMetrics::width(QString const&, int) const", referenced from:
      _main in main.o
  "QDesktopWidget::screenNumber(QWidget const*) const", referenced from:
      misc::screenCenter(QWidget*) in misc.o
  "QDesktopWidget::screenNumber(QPoint const&) const", referenced from:
      misc::screenCenter(QWidget*) in misc.o
  "QDesktopWidget::isVirtualDesktop() const", referenced from:
      misc::screenCenter(QWidget*) in misc.o
  "QDesktopWidget::availableGeometry(int) const", referenced from:
      misc::screenCenter(QWidget*) in misc.o
  "QColor::name() const", referenced from:
      QBtSession::addConsoleMessage(QString, QColor) in qbtsession.o
  "QDialog::result() const", referenced from:
      ShutdownConfirmDlg::askForConfirmation(QString const&) in qbtsession.o
  "QWidget::frameGeometry() const", referenced from:
      misc::screenCenter(QWidget*) in misc.o
  "QWidget::window() const", referenced from:
      misc::screenCenter(QWidget*) in misc.o
  "QPainter::fontMetrics() const", referenced from:
      _main in main.o
  "QPalette::brush(QPalette::ColorGroup, QPalette::ColorRole) const", referenced from:
      QBtSession::QBtSession() in qbtsession.o
      QBtSession::configureSession() in qbtsession.o
      QBtSession::processBigRatios() in qbtsession.o
      QBtSession::deleteTorrent(QString const&, bool) in qbtsession.o
      QBtSession::initWebUi() in qbtsession.o
      QBtSession::addMagnetUri(QString, bool, bool, QString const&) in qbtsession.o
      QBtSession::addTorrent(QString, bool, QString, bool) in qbtsession.o
      ...
  "vtable for MainWindow", referenced from:
      MainWindow::~MainWindow() in main.o
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
  "vtable for QMacApplication", referenced from:
      _main in main.o
      QMacApplication::~QMacApplication() in main.o
      QMacApplication::~QMacApplication() in main.o
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
  "vtable for ShutdownConfirmDlg", referenced from:
      ShutdownConfirmDlg::ShutdownConfirmDlg(QString const&) in qbtsession.o
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [qbittorrent-nox.app/Contents/MacOS/qbittorrent-nox] Error 1
make: *** [sub-src-make_default] Error 2
sledgehammer_999
Administrator
Administrator
Posts: 2443
Joined: Sun Jan 23, 2011 1:17 pm

Re: can not compile headless on osx

Post by sledgehammer_999 »

Did you try a clean compilation? All this references is for code disabled for the nox version...
GereeNice

Re: can not compile headless on osx

Post by GereeNice »

I might not have, gave it another try to be sure, sorry. Here are my exact steps:
  1. Delete folder, extract qbittorrent-3.1.9.tar.gz again
  2. Change *.so to *.dylib in configure at line 458
  3. Add "CONFIG += nox" to first line of macxconf.pri
  4. Copy GeoIP.dat to src/geoip/
  5. ./configure --disable-gui
  6. make
Among a lot of other warnings (which is normal I presume, had them on successful compile too) it fails with a font (uh?) issue. However weird, this is in line with the previous symptoms.

Code: Select all

/usr/local/Cellar/libtorrent-rasterbar/0.16.15/include/libtorrent/storage.hpp:291:45: warning: 
      unused parameter 'rd' [-Wunused-parameter]
                bool verify_resume_data(lazy_entry const& rd, ...
                                                          ^
/usr/local/Cellar/libtorrent-rasterbar/0.16.15/include/libtorrent/storage.hpp:291:61: warning: 
      unused parameter 'error' [-Wunused-parameter]
                bool verify_resume_data(lazy_entry const& rd, error_code& e...
                                                                          ^
/usr/local/Cellar/libtorrent-rasterbar/0.16.15/include/libtorrent/storage.hpp:292:33: warning: 
      unused parameter 'rd' [-Wunused-parameter]
                bool write_resume_data(entry& rd) const { return false; }
                                              ^
main.cpp:195:5: error: incomplete type 'QFont' named in nested name specifier
    QFont::insertSubstitution(".Lucida Grande UI", "Lucida Grande");
    ^~~~~~~
/usr/local/Cellar/qt/4.8.5/include/QtCore/qmetatype.h:319:7: note: forward
      declaration of 'QFont'
class QFont;
      ^
27 warnings and 1 error generated.
make[1]: *** [main.o] Error 1
make: *** [sub-src-make_default] Error 2
sledgehammer_999
Administrator
Administrator
Posts: 2443
Joined: Sun Jan 23, 2011 1:17 pm

Re: can not compile headless on osx

Post by sledgehammer_999 »

OK. This is simple and it actually makes sense since the nox version was never tested on osx.
Go to main.cpp:190 and change the ifdef to this:

Code: Select all

#if defined(Q_OS_MACX) && !defined(DISABLE_GUI)
Sidenote: It appears that the configure script is totally useless on osx. It only benefits linux. So instead of ./configure --disable-gui, just do "qmake qbittorrent.pro" to reproduce the makefile.
(of course you'll still need to edit macxconf.pri for the CONFIG += nox)
Post Reply