Skip to content

Support building Core Lightning as a static library for C/C++ integration #8240

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

Open
erickcestari opened this issue Apr 16, 2025 · 0 comments

Comments

@erickcestari
Copy link
Contributor

erickcestari commented Apr 16, 2025

It would be valuable for Core Lightning (CLN) to officially support building as a static library (.a) that can be easily linked into external C or C++ projects. This would simplify and standardize integration of CLN functionality into other codebases.

Current Workaround

While working on integrating Core Lightning into bitcoinfuzz, I implemented a workaround by appending the following rule to the end of the Makefile:

libcln.a: libccan.a $(BITCOIN_OBJS) $(COMMON_OBJS) $(WIRE_OBJS) $(EXTERNAL_LIBS) $(CCAN_OBJS)
	@$(call VERBOSE, "ar $@", $(AR) r $@ $(BITCOIN_OBJS) $(COMMON_OBJS) $(WIRE_OBJS) $(CCAN_OBJS))
	@echo "Extracting external libraries..."
	@for lib in ${EXTERNAL_LIBS}; do \
    echo "Processing $$lib"; \
    if [ -f "$$lib" ]; then \
        tmpdir=$$(mktemp -d); \
        echo "Created temp dir: $$tmpdir"; \
        fullpath="$$(pwd)/$$lib"; \
        echo "Full path: $$fullpath"; \
        (cd $$tmpdir && $(AR) x "$$fullpath" && echo "Extraction completed successfully"); \
        if [ -n "$$(ls -A $$tmpdir)" ]; then \
            echo "Found object files: $$(ls $$tmpdir)"; \
            $(AR) r $@ $$tmpdir/*.o; \
        else \
            echo "Warning: No object files found in $$lib"; \
        fi; \
        rm -rf $$tmpdir; \
    else \
        echo "Warning: Library $$lib not found"; \
    fi; \
done

Request

I believe that officially supporting static library builds would benefit many integration projects beyond bitcoinfuzz. This would provide a more maintainable and supported approach to linking CLN components into other projects.

Potential Benefits

  • Simplified integration with external C/C++ projects
  • Reduced setup complexity for projects needing CLN functionality
  • Better compatibility with various build systems
  • Improved developer experience when incorporating CLN
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

1 participant