Closed gbschenkel closed 8 months ago
correct. it depends on the native windows api, it wont compile on linux for now.
I'll add this as an enhancement to maybe support it in a further update, but I have to mention that this is REALLY low priority to me.
also this error
[1/46] Building CXX object util/CMakeFiles/util.dir/StringTable.cpp.o
FAILED: util/CMakeFiles/util.dir/StringTable.cpp.o
/usr/local/bin/c++ -DFMT_HEADER_ONLY=1 -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_NO_DEBUG -DQT_WEBSOCKETS_LIB -DQT_WIDGETS_LIB -Iutil -I../util -Iutil/util_autogen/include -I../ThirdParty/tinyxml2/include -I../ThirdParty/nlohmann_json/include -I../ThirdParty/fmt/include -I../ThirdParty/zip/src -I../gui -I../Resources -I../framelessHelper -isystem /usr/include/qt5 -isystem /usr/include/qt5/QtCore -isystem /usr/lib64/qt5/mkspecs/linux-g++ -isystem /usr/include/qt5/QtWebSockets -isystem /usr/include/qt5/QtNetwork -isystem /usr/include/qt5/QtWidgets -isystem /usr/include/qt5/QtGui -fPIC -std=gnu++2a -MD -MT util/CMakeFiles/util.dir/StringTable.cpp.o -MF util/CMakeFiles/util.dir/StringTable.cpp.o.d -o util/CMakeFiles/util.dir/StringTable.cpp.o -c ../util/StringTable.cpp
In file included from ../util/StringTable.cpp:3:
../util/StringTable.hpp:12:10: fatal error: StringTableKeys.i: No such file or directory
12 | #include "StringTableKeys.i"
| ^~~~~~~~~~~~~~~~~~~
compilation terminated.
is because you need to generate the stringtable header by running Resources/generate_translations.py
Some progress has been made by separating all platform specific code into Foobar.win32.cpp
and Foobar.linux.cpp
, some of which still need to be implemented. Check branch https://github.com/razaqq/PotatoAlert/tree/3.1.0
@gbschenkel okay linux support is now here in feature branch https://github.com/razaqq/PotatoAlert/tree/3.1.0 check the README for detailed build instructions would be very useful if you could report back if you got it working
i will put it on AUR (for arch based distros) in the next couple days
Hi, sorry about the delay, I quit playing World of Warships, but at least I could try build your project:
I got this initial problem:
$ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld" -DCMAKE_CXX_FLAGS="-stdlib=libc++ -lc++abi" ..
-- The C compiler identification is Clang 13.0.1
-- The CXX compiler identification is Clang 13.0.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonInterp: /usr/bin/python (found version "2.7.18")
Generating stringtable...
File "/home/schenkel/Development/gitrepo/PotatoAlert/Resources/generate_translations.py", line 22
f.write(','.join([f'"{lang}"' for lang in languages]) + '\n')
^
SyntaxError: invalid syntax
CMake Error at CMakeLists.txt:41 (message):
Failed to generate stringtable
-- Configuring incomplete, errors occurred!
I saw is needed Clang 14 and I using 13.0.1 but I don't think is related, also /usr/bin/python3
need be called to use python 3.9.12
Since both WIndows and Linux will use Clang and Python I made a few ajust on CMakeList.txt
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3f69253f..63239649 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,6 +6,10 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
+set(CMAKE_C_COMPILER clang)
+set(CMAKE_CXX_COMPILER clang++)
+set(CMAKE_GENERATOR "Ninja")
+
enable_testing()
option(PA_PROFILE "Enable Profiling Output" OFF)
@@ -32,7 +36,7 @@ generate_product_version(
)
# generate stringtable headers
-find_package(PythonInterp REQUIRED)
+find_package(Python 3.7 REQUIRED)
message("Generating stringtable...")
execute_process(COMMAND "${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/Resources/generate_translations.py"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
Hi, sorry about the delay, I quit playing World of Warships, but at least I could try build your project:
I got this initial problem:
$ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld" -DCMAKE_CXX_FLAGS="-stdlib=libc++ -lc++abi" .. -- The C compiler identification is Clang 13.0.1 -- The CXX compiler identification is Clang 13.0.1 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/clang - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/clang++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Found PythonInterp: /usr/bin/python (found version "2.7.18") Generating stringtable... File "/home/schenkel/Development/gitrepo/PotatoAlert/Resources/generate_translations.py", line 22 f.write(','.join([f'"{lang}"' for lang in languages]) + '\n') ^ SyntaxError: invalid syntax CMake Error at CMakeLists.txt:41 (message): Failed to generate stringtable -- Configuring incomplete, errors occurred!
I saw is needed Clang 14 and I using 13.0.1 but I don't think is related, also
/usr/bin/python3
need be called to use python 3.9.12
correct, it requires python3 and libc++14
Since both WIndows and Linux will use Clang and Python I made a few ajust on CMakeList.txt
diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f69253f..63239649 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,10 @@ set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake) +set(CMAKE_C_COMPILER clang) +set(CMAKE_CXX_COMPILER clang++) +set(CMAKE_GENERATOR "Ninja") + enable_testing() option(PA_PROFILE "Enable Profiling Output" OFF) @@ -32,7 +36,7 @@ generate_product_version( ) # generate stringtable headers -find_package(PythonInterp REQUIRED) +find_package(Python 3.7 REQUIRED) message("Generating stringtable...") execute_process(COMMAND "${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/Resources/generate_translations.py" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
forcing a compiler is not a good idea, in theory you can use g++ (if the stdlib is new enough) or msvc to build this too
Is Linux still supported? I couldn't build the project successfully on Linux without modifying it.
In theory yes, in praxis probably not without modification. The issue was always that the standard libraries on linux (libstd++, libc++, etc) were always super far behind on new cpp features compared to ms stl. There was never much demand for a linux build to begin with, so i kinda stopped caring. If you want one, i can try to update the project and get it to build, it shouldnt be too difficult and the standard libs hopefully caught up a bit. What distro are you on and what clang/gcc versions are available?
Arch Linux; gcc 13.2; clang 16
Actually I'm trying to get a working build myself, and I almost succeeded: it can be built successfully, and the first run is okay. See https://github.com/Henry-ZHR/PotatoAlert/commit/5967eb2b9bf2880e011541fb9dda7462319be6c6 (not intended for pull request etc because of the bad code quality)
Currently the problem is the stub functions in Core/src/FileMapping.linux.cpp
Changes:
std::format
working with clang. Maybe https://stackoverflow.com/a/71778011.Im on arch too, i can get it on AUR once i get the linux build working.
<chrono>
and <filesystem>
, but i wanted to switch to fmt/format
a while ago already because of these reasons. Its already added as a dependency and already used in some placeswchar_t
char on linux, but std::filesystem::path::value_type
is going to be char
. This shouldnt really be an issue since PA uses fs::path
everywhere, not raw stringsIm on arch too, i can get it on AUR once i get the linux build working.
That would be great
Yeah having a member variable with the same name as a type is allowed by clang but throws and error on gcc. I prefer to use clang as a compiler. Maybe gcc has a flag to allow it
Maybe -Wno-changes-meaning
? I haven't tried yet
So after some reading i would choose libstdc++ as the standard library over libc++, because otherwise stuff like<expected>
, floating point from_chars
etc is missing and i dont want to deal with that.
Maybe
-Wno-changes-meaning
? I haven't tried yet
I think -fms-extensions
is the way to go.
Also one thing i never tested was the directory structure of wows on linux and if it differs than the one on windows.
Also one thing i never tested was the directory structure of wows on linux and if it differs than the one on windows.
There is no native WoWS yet. "WoWS for Linux" is actually "WoWS for Windows" with Wine/Proton/etc, so the directory structure should be almost the same.
Another problem: I keep getting SSLError without ignoreSslErrors
PotatoAlert: Server reponded with error to submit: SSL handshake failed: The issuer certificate of a locally looked up certificate could not be found
This is weird since a simple program with the same procedure works well, even when the url
and data
changed to be the same used by PA
Update:
Using system OpenSSL instead of the one in ThirdParty/ fixes this issue.
diff --git a/Core/CMakeLists.txt b/Core/CMakeLists.txt
index 18e6f19..d4d463f 100644
--- a/Core/CMakeLists.txt
+++ b/Core/CMakeLists.txt
@@ -69,9 +69,10 @@ find_package(Qt6 COMPONENTS Core Widgets QUIET)
if (NOT Qt6_FOUND)
find_package(Qt5 COMPONENTS Core Widgets REQUIRED)
endif()
+find_package(OpenSSL REQUIRED)
set_target_properties(Core PROPERTIES CXX_STANDARD 23 CXX_STANDARD_REQUIRED true)
-target_link_libraries(Core PRIVATE sqlite3 OpenSSL zip ZLIB::ZLIB)
+target_link_libraries(Core PRIVATE sqlite3 OpenSSL::SSL zip ZLIB::ZLIB)
target_link_libraries(Core PUBLIC Qt::Core Qt::Widgets RapidJson fmt::fmt spdlog tinyxml2)
target_include_directories(Core PUBLIC include)
include(CompilerFlags)
diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt
index e2e60cb..7f092ad 100644
--- a/ThirdParty/CMakeLists.txt
+++ b/ThirdParty/CMakeLists.txt
@@ -6,7 +6,7 @@ set(FMT_SYSTEM_HEADERS ON)
set(FMT_MODULE OFF)
set(FMT_INSTALL OFF)
add_subdirectory(fmt)
-add_subdirectory(openssl)
+# add_subdirectory(openssl)
set(QWINDOWKIT_BUILD_STATIC ON)
set(QWINDOWKIT_BUILD_QUICK OFF)
set(QWINDOWKIT_BUILD_EXAMPLES OFF)
And could we use system ones for other libraries in ThirdParty/ too? The size of the binary is about 29MB on my machine, which sounds terrible.
Using system SSL is preferred on linux, on windows its not that simple. Those static linux openssl libs are probably ancient and not compatible with Qt6.
Did you build in release mode with debug symbols stripped? Also dont forget that there are tons of resources (fonts, icons, ...) embedded in the file.
I pushed some changes that should fix some issues.
One issue which i havent fixed yet is the following:
https://github.com/razaqq/PotatoAlert/blob/833d8e483a949d4033887ca6e7d876d6789f8b12/Client/src/Game.cpp#L49
In order to find the corrent Wows\bin\<version>\bin64
directory, PotatoAlert gets the embedded version from WorldOfWarships64.exe
using some win32 functions. Nothing similar is available on linux. In order to do the same, i have to write some PE Parser to extract the same information or come up with a different solution.
This issue doesnt break the core functionality, but stuff like the replay parser wont work because game files cannot be unpacked.
The whole game path detection needs to be rewritten at some point, its pretty messy (tbf the game doesnt make this easy).
So here are the issues i noticed:
Using system SSL is preferred on linux, on windows its not that simple.
Well I just meant using system libraries on Linux
Did you build in release mode with debug symbols stripped? Also dont forget that there are tons of resources (fonts, icons, ...) embedded in the file.
The stripped one is still large. The current size is 24.3MB/19.0MB (original/stripped) after using system OpenSSL.
I pushed some changes that should fix some issues.
It works on my machine.
https://github.com/razaqq/PotatoAlert/blob/bcd29bd746394b35167570319097b7eb85acdc68/ThirdParty/openssl/CMakeLists.txt#L2-L5 But should these lines be in if (WIN32)
?
Well I just meant using system libraries on Linux
Which ones? All other dependencies are just headers with sources. There is no benefit to install them via system.
The stripped one is still large. The current size is 24.3MB/19.0MB (original/stripped) after using system OpenSSL.
19MB for a project of this size is not very large
https://github.com/razaqq/PotatoAlert/blob/bcd29bd746394b35167570319097b7eb85acdc68/ThirdParty/openssl/CMakeLists.txt#L2-L5 But should these lines should be in
if (WIN32)
?
Yes, good catch
There is no benefit to install them via system.
There is. It saves memory. It can keep dependencies up-to-date without updating the project. (Although this sometimes causes problems...)
And that's what we usually do on Linux.
19MB for a project of this size is not very large
Of couse it is not large on Windows. But I'd say that's not the case on Linux.
Anyway, I do agree that this is not so important. Don't care about this before we get everything work. :)
There is. It saves memory. It can keep dependencies up-to-date without updating the project. (Although this sometimes causes problems...) And that's what we usually do on Linux.
You are wrong here, it does not save any memory at all. First of all most of these arent available as shared libs anyways. And even if they were you still have those on disk (plus a couple extra ones that come with the lib, but im not even using). In fact most people just want to run the app, not have lots of dev headers and unused shared libs installed. Modern compilers are very good at eliminating unused code, the total file size will be lower than getting all deps as shared libs. Also shared libs get updated constantly, breaking API and compability. On some distros they might be available, on other distros not at all or different versions. Its a nightmare to deal with and im not not going to do that.
Of couse it is not large on Windows. But I'd say that's not the case on Linux.
Im using lots of native compiled binaries on linux with sizes >20MB, its completely normal for a gui app. What difference does it make which OS you are on? The machine code will be the exact same in both binaries, just the binary format is different. About half the size will be embedded resources.
First of all most of these arent available as shared libs anyways.
available: catch2(test only) fmt spdlog sqlite3 tinyxml2 zlib unavailable: qwindowkit rapidjson(available but header only) zip(where is it from??)
6/9. I'd say most of these are available as shared libs.
Modern compilers are very good at eliminating unused code, the total file size will be lower than getting all deps as shared libs.
When multiple programs use the same lib, the total size will be lower if everyone uses shared libs.
Also shared libs get updated constantly, breaking API and compability. On some distros they might be available, on other distros not at all or different versions. Its a nightmare to deal with and im not not going to do that.
This is true.
What difference does it make which OS you are on? The machine code will be the exact same in both binaries, just the binary format is different.
On Windows we prefer static libs, while on Linux we prefer shared libs.
6/9. I'd say most of these are available as shared libs.
that might be the case for arch (which is notoriously fast in getting stuff updated). what about ubuntu, debian, fedora, centos, gentoo, ...? just as an example on debian we have fmt (outdated 9.X version, wont work because of limited chrono support), zlib (outdated 1.2 version, might have breaking api changes), sqlite3, libtinyxml2, spdlog (outdated 1.12 version). 2/9 are usable. how do people on these distros get the shared libs then? you cant just tell everyone to build from source then. It simply is not an option.
When multiple programs use the same lib, the total size will be lower if everyone uses shared libs.
and for all the libs other programs dont use you end up with more.
On Windows we prefer static libs, while on Linux we prefer shared libs.
No im sorry, but thats not true either. dlls make just as much sense on windows as they make sense on linux.
that might be the case for arch (which is notoriously fast in getting stuff updated). what about ubuntu, debian, fedora, centos, gentoo, ...? just as an example on debian we have fmt (outdated 9.X version, wont work because of limited chrono support), zlib (outdated 1.2 version, might have breaking api changes), sqlite3, libtinyxml2, spdlog (outdated 1.12 version). 2/9 are usable. how do people on these distros get the shared libs then? you cant just tell everyone to build from source then. It simply is not an option.
On Debian 10 (Current LTS), there is only gcc 8. Do you want to support it?
You can't support all distros while using the latest things at the same time.
and for all the libs other programs dont use you end up with more.
That's true. But we can't assume that they are not used by other programs.
No im sorry, but thats not true either. dlls make just as much sense on windows as they make sense on linux.
You are right.
What I wanted to say is, on Windows, almost every program is shipped with their dependencies, no matter shared or static; on Linux, most program isn't.
On Debian 10 (Current LTS), there is only gcc 8. Do you want to support it? You can't support all distros while using the latest things at the same time.
well if they got gcc 11 from some other repo they could compile it, even tho most other deps arent available. otherwise you could probably compile with static libc etc on another system, but im not going to put any time into it
What I wanted to say is, on Windows, almost every program is shipped with their dependencies, no matter shared or static; on Linux, most program isn't.
thats why from my own experience dependencies break pretty regularly on linux, especially on rolling release distros like arch. its the exact reason i use docker for all my server stuff on linux, i just cant have a system update break half my server apps.
no need to discuss this any further, the downsides outweight the upsides by a lot.
everything except popups in the match history should work now
Alright, everything should work now. There is also an AUR Package available. Since linux builds are now in CI, im going to close this issue. Thank you @gbschenkel and @Henry-ZHR for testing and providing feedback.
CMake 3.20.3 Qt 5.15.2 GCC 10.3.0
Using Ninja for building also get me trouble Ninja 1.10.2