Tuesday, November 22, 2022

Statically linked binaries with Haskell GHC

TL;DR Use AppImage

I am working on a nostr-project Futr written in Haskell. Since I don't want users of the application to install a bunch of dependencies manually upfront in order to use it, I digged deep into statically linking binaries with Haskell. I tried the nix build system, which didn't bring me to success, I only lost many many hours recompiling the same things again and again. My main requirements are secp256k1 (C-lib), glew and SDL2 (for monomer). What should have been "a not too hard task to solve" took me actually several weeks to find out. So I gave AppImage a try and it worked great basically from the first try on.

It'a two-step-process

1) Compile the haskell binary as usual
2) Build the AppImage

The resulting binary can then be shipped to the users. Compilation first (I'm using stack here): `stack build` - that part was easy!

First I need a build directory, my application is called "futr", so I name the directory "futr.AppDir". Within there I need two files:

"AppRun":
#!/bin/sh
SELF=$(readlink -f "$0")
HERE=${SELF%/*}
EXEC="${HERE}/usr/bin/futr"
exec "${EXEC}"
and "futr.desktop":
[Desktop Entry]
Name=futr
Exec=futr
Icon=futr-icon
Type=Application
Categories=Network
X-AppImage-Version=4702f2f


The latter is "only" for the desktop entry. Okay, so my binary requires some assets to live alongside the binary in the same directory, so let's add those:
cp -R assets futr.AppDir/usr/bin
cp assets/icons/futr-icon.png futr.AppDir


And all there is left is to create the final AppImage:
APPIMAGE_EXTRACT_AND_RUN=1 linuxdeploy-x86_64.AppImage --appdir futr.AppDir
ARCH=x86_64 appimagetool-x86_64.AppImage futr.AppDir


My project already uses Github Action, so I can automate the whole process and attach a binary to each release. Check the repository for the configuration: Futr Github Action

13 comments:

  1. As a statistics project helper, I appreciate the in-depth explanation of statically linked binaries with Haskell GHC. This information will undoubtedly be useful to many programmers and developers out there looking to optimize their workflow and improve the efficiency of their projects.

    ReplyDelete
  2. Use Stack, Stack is a popular Haskell build tool that simplifies managing dependencies and building projects like freebase vape. Ensure you have Stack installed on your system.

    ReplyDelete
  3. Apply Stack, A well-liked Haskell build tool called Stack makes it easier to manage dependencies and build projects like come close vr. Make sure Stack is set up on your computer.

    ReplyDelete
  4. It's always frustrating when what seems like a simple task becomes a time-consuming headache. Statically linking binaries with Haskell can be a challenge, but it's great that you found success with AppImage. It's impressive how technology has made it possible to create applications without requiring users to manually install dependencies. On a completely different topic, if you're considering a cosmetic procedure like Buccal Fat Removal Dubai, be sure to do your research and consult with a qualified professional.

    ReplyDelete
  5. Statically linked binaries with Haskell GHC offer enhanced portability and ease of deployment. By eliminating external dependencies, these binaries become self-contained and resilient, resembling waterproof stickers that withstand any environment. This empowers developers to confidently distribute their Haskell applications, ensuring seamless execution across diverse systems. The resulting convenience and reliability make statically linked Haskell GHC binaries a valuable asset for developers and users alike.





    ReplyDelete
  6. Statically linked binaries with Haskell GHC offer a reliable solution for software deployment. By eliminating external dependencies, the resulting executables become portable and efficient, ensuring compatibility across platforms. This advancement could greatly benefit a basement waterproofing company in Farmington Hills, enhancing their software's performance and ease of installation. With statically linked binaries, the company can streamline their operations and focus on delivering exceptional services to their customers without worrying about compatibility issues.





    ReplyDelete
  7. For those seeking efficient and self-contained software deployments, statically linked binaries offer a reliable solution. When using the Haskell GHC compiler, it becomes possible to create such binaries, which contain all necessary libraries and dependencies, eliminating the need for external installations. This blog post explores the advantages and considerations of utilizing statically linked binaries with Haskell GHC, providing valuable insights for developers and enthusiasts. Additionally, if you're in need of professional WordPress web design services, our team of experts can create visually stunning and highly functional websites tailored to your specific needs. From custom themes to responsive layouts, our WordPress web design services ensure a seamless online presence for your business or personal brand.

    ReplyDelete
  8. Statically linked binaries with Haskell GHC provide numerous advantages, including portability and ease of deployment. By eliminating external dependencies, these binaries ensure consistent performance across different environments. Whether it's developing software or delivering reliable services like Basement Waterproofing Services in Clarkston, Haskell GHC's statically linked binaries offer a solid foundation for efficient and secure applications.




    ReplyDelete
  9. Your Christian-Based Video Production Company in Houston, Texas
    Welcome to Starmade Production, your premier Christian-based video production company in Houston, Texas. We specialize in providing top-notch video production services tailored to meet the unique needs of our clients while adhering to Christian values and principles.

    ReplyDelete
  10. At Sigma Wholesale, unlock exclusive deals on vape, tobacco, hookah, and vaporizers. Elevate your smoking experience with our premium essentials. Shop now and indulge in the best!

    ReplyDelete

  11. ChatGPT
    Introducing the Mustard Handmade Clutch Bag, where elegance meets functionality in a stunning fusion of style and craftsmanship. Handcrafted with meticulous attention to detail, this clutch is a true labor of love, showcasing the skill and dedication of its creators. The luxurious mustard hue adds a touch of warmth and sophistication to any look, while the compact yet spacious design ensures ample room for your essentials. Whether you're stepping out for a night on the town or a daytime brunch, this versatile accessory effortlessly elevates your ensemble with its timeless charm and impeccable quality. Make a bold statement and exude confidence with the Mustard Handmade Clutch Bag, the perfect companion for any occasion.
    https://londonroadboutique.com/products/mustard-hand-made-clutch-bag

    ReplyDelete

  12. Finding a digital marketing agency near you can be a game-changer for your business. Not only does it provide convenience for face-to-face meetings and collaborations, but it also often means they have a better understanding of local market dynamics. To find one, try searching online directories, such as Google Maps or Yelp, and use keywords like "digital marketing agency" followed by your city or region. Additionally, you can ask for recommendations from fellow business owners or industry colleagues who have worked with local agencies. This way, you can ensure personalized service and support to your specific geographical area and business needs
    https://digitalception.com/




    ReplyDelete
  13. A digital marketing agency specializes in creating and executing online marketing strategies to help businesses grow their online presence and reach their target audience. These agencies offer a range of services, including search engine optimization (SEO), pay-per-click (PPC) advertising, social media management, content creation, email marketing, and website design. By leveraging the latest digital tools and techniques, a digital marketing agency can enhance brand visibility, drive traffic, and boost conversions, ultimately contributing to the success of their clients' marketing goals.
    https://www.digitalwebaffinity.com/

    ReplyDelete