Skip to content

Fix build on macOS#35

Open
azuwis wants to merge 2 commits intogyunaev:masterfrom
azuwis:macOS
Open

Fix build on macOS#35
azuwis wants to merge 2 commits intogyunaev:masterfrom
azuwis:macOS

Conversation

@azuwis
Copy link
Contributor

@azuwis azuwis commented Nov 13, 2024

  • Q_WS_MAC -> Q_OS_MACOS
  • Make loadFile a public member
kchmviewerapp.cpp:66:11: error: 'loadFile' is a private member of 'MainWindow'
    main->loadFile(m_filePath);
          ^
./mainwindow.h:169:9: note: declared private here
                bool            loadFile( const QString &fileName,  bool call_open_page = true );
                                ^

Q_WS_MAC is no longer defined in Qt 5 and later[1].

[1]: https://doc.qt.io/qt-6/macos-issues.html#compile-time-flags
Fix build on macOS:

```
kchmviewerapp.cpp:66:11: error: 'loadFile' is a private member of 'MainWindow'
    main->loadFile(m_filePath);
          ^
./mainwindow.h:169:9: note: declared private here
                bool            loadFile( const QString &fileName,  bool call_open_page = true );
                                ^
```
@u-235
Copy link
Contributor

u-235 commented Nov 13, 2024

Hi.
Have you tried removing the kchmviewerapp.h and kchmviewerapp.cpp files from the project and make a build for macos?

@azuwis
Copy link
Contributor Author

azuwis commented Nov 13, 2024

Do you mean? :

diff --git a/src/src.pro b/src/src.pro
index 14c31a1..046a12e 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -72,8 +72,6 @@ linux-g++-32: {
 
 # General per-platform settings
 macx: {
-    HEADERS += kchmviewerapp.h
-    SOURCES += kchmviewerapp.cpp
     QMAKE_INFO_PLIST=resources/Info.plist
     QMAKE_POST_LINK += cp resources/*.icns ${DESTDIR}/kchmviewer.app/Contents/Resources;
     LIBS += ../lib/libebook/libebook.a

Give error:

Undefined symbols for architecture arm64:
  "KchmviewerApp::KchmviewerApp(int&, char**, int)", referenced from:
      _main in main.o
  "KchmviewerApp::~KchmviewerApp()", referenced from:
      _main in main.o
ld: symbol(s) not found for architecture arm64
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)

@u-235
Copy link
Contributor

u-235 commented Nov 13, 2024

This is not enough, main.cpp must also be changed so that there are no differences between macos and other platforms.

As far as I understand, KchmViewer used to not be able to open files from command line arguments and KchmviewerApp added this feature for macos.

@azuwis
Copy link
Contributor Author

azuwis commented Nov 13, 2024

It does build using this patch:

index da7d917..3747400 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -31,11 +31,7 @@
 	#include <kaboutdata.h>
 #endif
 
-#if defined (Q_OS_MACOS)
-        #include "kchmviewerapp.h"
-#else
-        typedef QApplication  KchmviewerApp;
-#endif
+typedef QApplication  KchmviewerApp;
 
 MainWindow * mainWindow;
 
diff --git a/src/src.pro b/src/src.pro
index 14c31a1..046a12e 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -72,8 +72,6 @@ linux-g++-32: {
 
 # General per-platform settings
 macx: {
-    HEADERS += kchmviewerapp.h
-    SOURCES += kchmviewerapp.cpp
     QMAKE_INFO_PLIST=resources/Info.plist
     QMAKE_POST_LINK += cp resources/*.icns ${DESTDIR}/kchmviewer.app/Contents/Resources;
     LIBS += ../lib/libebook/libebook.a

I don't quite understand why kchmviewerapp.cpp and kchmviewerapp.h was added in the first place.

@u-235
Copy link
Contributor

u-235 commented Nov 13, 2024

I found the reason for these files, they should not be deleted.

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

Successfully merging this pull request may close these issues.

2 participants