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

static linking #225

Open
audetto opened this issue Jan 19, 2025 · 6 comments
Open

static linking #225

audetto opened this issue Jan 19, 2025 · 6 comments

Comments

@audetto
Copy link
Owner

audetto commented Jan 19, 2025

Add ability to link statically as much as possible.

It is particularly important for msys2, where non-Windows DLLs cannot be easily found when exes are executes outside a msys2 environment.

But it will help other cases too.

@daguile
Copy link

daguile commented Jan 21, 2025

Hello. Tried to compile the static-working branch on mingw64 and I got the following error message:

C:/apps/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/l
d.exe: C:/apps/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../lib\libminizip.a(
unzip.o):(.text+0x1e60): undefined reference to `BZ2_bzDecompress'

Looks like bzip2 is a dependency of minizip and is not included in the static link. I will try to install the bzip2 package and see how it goes

@audetto
Copy link
Owner Author

audetto commented Jan 21, 2025

It is not ready. I am trying (and so far failing) to understand static linking in cmake.

@daguile
Copy link

daguile commented Jan 21, 2025

No problem, it was just to give a feedback, no complain here 😉By the way, I did manage to have a successful compilation with this patch:

diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index c6863bef..982278ac 100644
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -3,6 +3,7 @@ include(FindPkgConfig)
 pkg_search_module(ZLIB REQUIRED zlib)
 pkg_search_module(YAML REQUIRED yaml-0.1)
 pkg_search_module(MINIZIP REQUIRED minizip)
+pkg_search_module(BZIP2 REQUIRED bzip2)
 
 if (NOT WIN32)
   pkg_search_module(SLIRP slirp)
diff --git a/source/frontends/libretro/CMakeLists.txt b/source/frontends/libretro/CMakeLists.txt
index ff849025..0cb5d088 100644
--- a/source/frontends/libretro/CMakeLists.txt
+++ b/source/frontends/libretro/CMakeLists.txt
@@ -51,6 +51,7 @@ target_link_libraries(applewin_libretro PRIVATE
   ${YAML_STATIC_LIBRARIES}
   ${PCAP_STATIC_LIBRARIES}
   ${SLIRP_STATIC_LIBRARIES}
+  ${BZIP2_STATIC_LIBRARIES}
   -Wl,-Bdynamic
   ${ZLIB_LIBRARIES}
   )
``` 
However, it does not work when I put it in RA, with or without extra dll.

@audetto
Copy link
Owner Author

audetto commented Jan 21, 2025

The branch now works in linux and static links as much as I think it is humanly possible.

In msys2 it compiles, looks to be more static, but I was not able to test it for real. Will do it in the next days.

ldd still shows 1 non-windows dll

libwinpthread-1.dll => /mingw64/bin/libwinpthread-1.dll (0x7ffef2450000)

does it matter?

#230

@daguile
Copy link

daguile commented Jan 21, 2025

libwinpthread is distributed with retroarch, so I think it's ok 😊

@daguile
Copy link

daguile commented Jan 21, 2025

I can confirm that it now works perfectly in retroarh without any added dll. Thanks !

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

2 participants