I’m experimenting with mac’s deprecated reflective loading functionalities. I’ve a go program that invokes the go compiler to create binaries, however apple’s implementation of reflective loading is reliant on C++ for exception dealing with.
As I perceive it, CGO is just for C and requires a C wrapper to make use of C++ code, however I can not work out of it’s doable to simply hyperlink normal libraries. I attempted passing -lc++ and -lc++abi as linker flags together with -L /usr/lib, and another issues, however no luck.
What could be the only approach to do that? Please be at liberty to ask for elaboration if crucial, I’m new to programming, go, and nonetheless studying the C toolchain, and taking part in with software program that’s barely above my paygrade, so I may need missed some necessary ideas.
The only methodology ought to be:
1.go->c++: go as a launcher
Export your c++ code to a c library, after which go makes use of cgo to name it.
2.c+±>go: c++ as a launcher
Export your go code to a c library by way of cgo, after which your c++ code calls it.
3. Discover the corresponding go code implementation and study
Okay, I found out I used to be linking the libraries the mistaken approach. As a substitute of setting go env to CGO_LDFLAGS=‘-lc++ -lc++abi’ I used to be attempting to set them within the command with the -ldflags flag. Now, I can efficiently hyperlink the libs, however am nonetheless getting the error, which signifies an error with my software program. Thanks
Whats up!
I’m glad to see the difficulty is now solved. Thanks for updating us with the end result.