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

Build/Embed Chez Scheme with larger C/C++ program #851

Open
ValorZard opened this issue Jul 12, 2024 · 3 comments
Open

Build/Embed Chez Scheme with larger C/C++ program #851

ValorZard opened this issue Jul 12, 2024 · 3 comments

Comments

@ValorZard
Copy link

Hello!
I've been diving into the world of Lisp/Scheme recently, and I wanted to see if I could embed chez scheme into a c++ program. I've see these two resources before on the web: https://www.reddit.com/r/scheme/comments/a3oogf/questions_on_embedding_chez_scheme_into_a_c_app/ed2b3us/ and https://cisco.github.io/ChezScheme/csug9.5/foreign.html#g34 but it's still not really clear to me how to build everything together.

I tried following the steps in the reddit post, and got far enough to link the dll mentioned but then I would get this error:
image
Is there an easier way to mix chez and C++ together? It would be nice if I could just have Chez as a git submodule or something, and build everything together with CMake.

@mflatt
Copy link
Contributor

mflatt commented Jul 16, 2024

It looks like linking fails because zlib and lz4 libraries are missing. Those libraries are referenced by functions in csv1000mt.lib, and the librareies are created when building Chez Scheme from source — but I see that the libraries are not included in the boot directory of the release archive, and maybe they should be. Meanwhile, you can download or build those separately, you could build Chez Scheme from source to get them, or you can try using some copies that I put here: https://users.cs.utah.edu/~mflatt/tmp/ta6nt/

The bin directory of the distribution has a DLL and csv1000.lib for linking to the DLL. That DLL incorporates zlib and lz4, so there's no external dependency, but it means that you'd need to keep the DLL with your executable.

@LiberalArtist
Copy link
Contributor

There is a somewhat-related problem on Unix-like systems (at least, it seems related to the very limited extent that I understand Windows linking) that programs linking to libkernel.a need different flags if Chez was built with ZLIB=-lz LZ4=-llz4 than if Chez was built with its own libraries.

My impression is that the idiomatic solution for Unix-like systems, at least, would be to generate and install a pkg-config file, which I believe would also be understood by CMake and other tools. I just haven't made time to try that, yet. Alternatively, I think there is some way of embedding these directives into libkernel.a using linker script, but that seems painful. A hypothetical libchezscheme.so.10.0.0 (see also #811 (comment) and #836 (comment)) wouldn't have this problem, since it would record the dependencies if shared libraries were used, but we'd want to continue to support static linking anyway.

@ValorZard
Copy link
Author

Personally, I would like if something like https://github.com/gwatt/chez-exe was included as part of Chez itself. It would make life a lot easily in my opinion.

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