successfully called Racket CS from C. I'll try what you suggest re calling C from Racket at some point and report any problems.
Thank you! On Sunday, 29 March 2020 21:41:46 UTC+1, Matthew Flatt wrote: > > At Sun, 29 Mar 2020 13:13:08 -0700 (PDT), zeRusski wrote: > > First, CS snapshots in Utah and NW mirrors offer no libracketcs.a so I > went > > ahead and attempted to build CS from the github master. Sadly its `raco` > > tool is unaware of the `ctool` subcommand, so I'm guessing snapshots are > > built from your own private fork or something. > > Snapshot builds use the public GitHub repo's master. > > `raco ctool` is provided by the "cext-lib" package. That package is > part of "main-distribution", but maybe you installed a subset of > packages when building? > > > I then started mixing and > > matching stuff from snapshot and freshly built github: > > - raco, boot files and headers from the snapshot, > > - libracketcs.a from github > > That could work. > > > Linking against `libracketcs.a` however failed with a bunch of > > unresolved symbols like e.g. `CFLocaleCopyCurrent` most of them > referenced > > from `rktio_convert.o`. > > You will need to link to some standard libraries and frameworks on Mac > OS: `-framework CoreFoundation`, `-liconv`, and `-lncurses`. > > I didn't try to write this down because it varies so much across > platforms, and I expect C programmers to just know. :) But it should be > written down or made more automatic. > > > It wouldn't work anyway since `declare_modules` > > also failed to resolve and I'm guessing I really need the > `libracketcs.a` > > from the snapshot for that. > > `declare_modules` should be defined in the file generated by `raco > ctool --c-mods`. > > > Another, probably unrelated issue where I'm likely not using the right > > incantation is linking in Racket.framework. Even with -F path supplied > as > > needed `-framework racket` wasn't found. `man ld` for my platform shows > it > > expects to find (in our case) Racket under Racket.framework so > > Racket.framework/Racket but all the frameworks you ship have > intermediate > > dirs Version/blabla/Racket. I just copied Racket and boot/ under > > Racket.framework there to shut the linker up. Am I doing it wrong? > > A better strategy may be to use `install_name_tool` to update the > framework reference to be relative to the executable: > > install_name_tool -change \ > "Racket.framework/Versions/7.6.0.18_CS/Racket" \ > > "@excutable_path/rel/to/Racket.framework/Versions/7.6.0.18_CS/Racket" \ > path_to_your_executable > > I don't know of a flag to the linker that will do this in the first > place. > > > https://www.cs.utah.edu/plt/snapshots/current/doc/inside/cs.html is atm > > quite about calling C. Is it possible or at least in the cards? I'd like > to > > use the API defined in C from Racket. > > Calling C from Racket is mostly left to the FFI documentation: > > https://docs.racket-lang.org/foreign/index.html > > So, if you link your executable in such a way that `(get-ffi-obj name > #f ....)` can find the functions, then that's all you need. > > > There's also a way to publish C functions to make them visible at the > Chez Scheme level: > > https://cisco.github.io/ChezScheme/csug9.5/foreign.html#./foreign:s272 > > Then you'd have to propagate that to the Racket level somehow --- maybe > by using `vm-eval` from `ffi/unsafe/vm` to access Chez Scheme directly > on the Racket side. I haven't given that much thought, so far. > > -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/743f1f10-cf27-4e24-a43e-6cf56c52049c%40googlegroups.com.

