Skip to content

Bundling VLC libs on Desktop #149

Open

Description

@orsson9

Hi!

I’m having trouble bundling the VLC native libraries with my Compose Multiplatform application. Currently, the video library assumes that the VLC native libraries are installed globally on the system, rather than being shipped together with the app.

However, for production builds and distribution outside of development environments, it’s usually much better (and often necessary) to include the native VLC binaries directly inside the application package, so that users don’t have to install anything manually.

I’ve looked for solutions on how to bundle the VLC libraries, but the only guidance I’ve found is in this ticket: #52. There, a method for bundling is described, but it requires code changes at the library discovery stage.

Based on that solution I prepared:

  • vlc-libs directory with following structure:

composeApp/vlc-libs/common
-libclc.dll
-libvlcore.dll
-plugins

  • Added vlc-libs inside build.gradle:
compose.desktop {
    application {
       (...)
        nativeDistributions {
          (...)
            appResourcesRootDir.set(project.layout.projectDirectory.dir("vlc-libs"))
        }
    }
}
  • Build app to msi, install app,
  • Provided libs are visible under:

appName/app/resources

  • VLC plugins discovery is not able to see them, everything is working fine when libs are moved to "appName" dir.

I have searched but could not find any way to change or override this default resource path or to move these files from the resources folder to the app root folder via Gradle or Compose Multiplatform configuration.

Regarding the way VLC native library discovery currently works, I see code like this in the library:

if (!NativeDiscovery().discover()) {
    error(MediaPlayerError.VlcNotFound)
    return
}

I would like to suggest changing this logic so that the library first tries to find VLC libraries in a user-provided directory (for example, via a parameter or configuration option). If the libraries are not found at that location, then it should fall back to the default NativeDiscovery() mechanism.

This would allow much more flexibility for bundling and deployment scenarios, where the native libraries are packaged in a specific location with the application.

Example pseudocode:

if (!tryDiscoverFrom(customPath)) {
    if (!NativeDiscovery().discover()) {
        error(MediaPlayerError.VlcNotFound)
        return
    }
}

This change would make it possible to specify the VLC library location explicitly and simplify native bundling and deployment for Compose Multiplatform applications.

In summary, I haven’t found a straightforward way to change the default resource directory where these libraries are placed, nor a way to specify their location for the native discovery process.
Is there any recommended or supported approach I might have missed for proper bundling of VLC native libs?

Also, would it be possible to consider implementing the suggestion to allow explicitly specifying the VLC library path before falling back to the default discovery?

Thank you for your time and support!

Activity

  1. orsson9 commented on Aug 8, 2025

    @orsson9
    Author

    I managed to resolve the VLC bundling issue by implementing a custom setup function that properly configures the JNA library path for VLC resources:

     fun setupVLC() {
         val appResourcesPath = System.getProperty("compose.application.resources.dir")
         if (appResourcesPath != null) {
             System.setProperty("jna.library.path", appResourcesPath)
         } else {
             Log.e("VLC", "compose.application.resources.dir is not set.")
        }
     }
    

    Function placement: This function must be called before any VLC initialization or media player creation
    Execution context: Should be invoked in the main application startup, preferably in your main() function or application initialization block

    fun main() = application {
        setupVLC() // Call before any VLC operations
        Window(onCloseRequest = ::exitApplication) {
            App()
        }
    }
    

    This solution has been tested and verified only on Windows platform.

    For cross-platform deployment (macOS, Linux), the VLC libraries must be:
    Placed in appropriate directory structure for each target platform
    Use platform-specific native libraries (not Windows libraries for macOS/Linux)

  2. rohan-paudel commented on Jan 13, 2026

    @rohan-paudel

    can you help me for mac?

  3. rohan-paudel commented on Jan 13, 2026

    @rohan-paudel

    done for macos 🤗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions