Skip to content
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

Zstd compile fails - Linux #1426

Open
whacka opened this issue Nov 12, 2024 · 4 comments
Open

Zstd compile fails - Linux #1426

whacka opened this issue Nov 12, 2024 · 4 comments

Comments

@whacka
Copy link

whacka commented Nov 12, 2024

Hi,
I've been trying to build Play! on Fedora 41 and am having an issue with Zstd failing to compile due an implicit declaration.
I assume it might be an issue with my environment, though I'm not sure how to diagnose the issue further.
I'm running the build on Kinoite within a toolbox if relevant.
Currently attempting to build the current latest commit: aad9ef7.
If anyone can help I would really appreciate it, thank you.

Below is the output for gcc, I've also tested the clang compiler and gotten a similar error.

[  0%] Built target sqlite3static
[  2%] Built target zlib
[  8%] Built target libzstd_static
[  8%] Building C object Source/ui_qt/Source/Framework/zstd_zlibwrapper/CMakeFiles/libzstd_zlibwrapper_static.dir/__/__/zstd/zlibWrapper/gzlib.c.o
In file included from /var/home/user/git/Play-/deps/Dependencies/zstd/zlibWrapper/gzlib.c:9:
/var/home/user/git/Play-/deps/Dependencies/zstd/zlibWrapper/gzguts.h:129:17: warning: conflicting types for built-in function ‘malloc’; expected ‘void *(long unsigned int)’ [-Wbuiltin-declaration-mismatch]
  129 |   extern voidp  malloc _Z_OF((uInt size));
      |                 ^~~~~~
/var/home/user/git/Play-/deps/Dependencies/zstd/zlibWrapper/gzguts.h:38:1: note: ‘malloc’ is declared in header ‘<stdlib.h>’
   37 | #include <fcntl.h>
  +++ |+#include <stdlib.h>
   38 | 
/var/home/user/git/Play-/deps/Dependencies/zstd/zlibWrapper/gzlib.c: In function ‘gz_open’:
/var/home/user/git/Play-/deps/Dependencies/zstd/zlibWrapper/gzlib.c:202:15: error: implicit declaration of function ‘strlen’ [-Wimplicit-function-declaration]
  202 |         len = strlen((const char *)path);
      |               ^~~~~~
/var/home/user/git/Play-/deps/Dependencies/zstd/zlibWrapper/gzlib.c:10:1: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
    9 | #include "gzguts.h"
  +++ |+#include <string.h>
   10 | 
/var/home/user/git/Play-/deps/Dependencies/zstd/zlibWrapper/gzlib.c:202:15: warning: incompatible implicit declaration of built-in function ‘strlen’ [-Wbuiltin-declaration-mismatch]
  202 |         len = strlen((const char *)path);
      |               ^~~~~~
/var/home/user/git/Play-/deps/Dependencies/zstd/zlibWrapper/gzlib.c:202:15: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
/var/home/user/git/Play-/deps/Dependencies/zstd/zlibWrapper/gzlib.c: In function ‘gz_error’:
/var/home/user/git/Play-/deps/Dependencies/zstd/zlibWrapper/gzlib.c:608:44: warning: incompatible implicit declaration of built-in function ‘strlen’ [-Wbuiltin-declaration-mismatch]
  608 |     if ((state.state->msg = (char *)malloc(strlen(state.state->path) + strlen(msg) + 3)) ==
      |                                            ^~~~~~
/var/home/user/git/Play-/deps/Dependencies/zstd/zlibWrapper/gzlib.c:608:44: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
/var/home/user/git/Play-/deps/Dependencies/zstd/zlibWrapper/gzlib.c:614:38: warning: incompatible implicit declaration of built-in function ‘strlen’ [-Wbuiltin-declaration-mismatch]
  614 |     (void)snprintf(state.state->msg, strlen(state.state->path) + strlen(msg) + 3,
      |                                      ^~~~~~
/var/home/user/git/Play-/deps/Dependencies/zstd/zlibWrapper/gzlib.c:614:38: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
gmake[2]: *** [Source/ui_qt/Source/Framework/zstd_zlibwrapper/CMakeFiles/libzstd_zlibwrapper_static.dir/build.make:90: Source/ui_qt/Source/Framework/zstd_zlibwrapper/CMakeFiles/libzstd_zlibwrapper_static.dir/__/__/zstd/zlibWrapper/gzlib.c.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:810: Source/ui_qt/Source/Framework/zstd_zlibwrapper/CMakeFiles/libzstd_zlibwrapper_static.dir/all] Error 2
gmake: *** [Makefile:166: all] Error 2```
@FabioLolix
Copy link
Contributor

Hi whacka, v0.68 build fine for me on Arch Linux, while I have an issue building from the latest commit #1434

Your errors

/var/home/user/git/Play-/deps/Dependencies/zstd/zlibWrapper/gzguts.h:38:1: note: ‘malloc’ is declared in header ‘<stdlib.h>’
   37 | #include <fcntl.h>
  +++ |+#include <stdlib.h>
[...]
/var/home/user/git/Play-/deps/Dependencies/zstd/zlibWrapper/gzlib.c:10:1: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
    9 | #include "gzguts.h"
  +++ |+#include <string.h>

Could be solved by a patch that add the missing headers like it was for me with:

@kuunha
Copy link

kuunha commented Dec 30, 2024

Same error in tumbleweed.

To make it compile, I've commented out "find_package(ZLIB)" in
deps/Dependencies/build_cmake/zstd_zlibwrapper/CMakeLists.txt

# find_package(ZLIB)
# if(NOT ZLIB_FOUND)
	MESSAGE("-- Using Provided zlib source")
	if(NOT TARGET zlibstatic)
		add_subdirectory(
			${CMAKE_CURRENT_SOURCE_DIR}/../zlib-1.2.8
			${CMAKE_CURRENT_BINARY_DIR}/zlib-1.2.8
		)
	endif()
# endif(NOT ZLIB_FOUND)

This way, it compile using provided zlib source

@FabioLolix
Copy link
Contributor

@ kuunha Zstd and zlib aren't the same thing, and it will use the system's version if detected - Found ZLIB: /usr/lib/libz.so (found version "1.3.1") you can force anyway with a cmake flag -DWITH_SYSTEM_ZLIB=ON

@kuunha
Copy link

kuunha commented Dec 30, 2024

They are not the same, but zstd_zlibwrapper seems to requires building with zlib.

https://github.com/facebook/zstd/blob/release/zlibWrapper/README.md

Update:
In Opensuse Tumbleweed, I had zlib-ng-compat-devel installed instead of zlib-devel.
Now it works.

Setting -DWITH_SYSTEM_ZLIB=OFF with cmake didn't work though. But this is off topic

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

3 participants