Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kbehouse/go_call_cxx_so
golang call c++ shared library(.so)
https://github.com/kbehouse/go_call_cxx_so
c-plus-plus go golang shared-library
Last synced: about 2 months ago
JSON representation
golang call c++ shared library(.so)
- Host: GitHub
- URL: https://github.com/kbehouse/go_call_cxx_so
- Owner: kbehouse
- Created: 2019-08-21T09:11:58.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-08-22T07:48:06.000Z (over 5 years ago)
- Last Synced: 2024-08-03T23:29:53.003Z (5 months ago)
- Topics: c-plus-plus, go, golang, shared-library
- Language: C++
- Homepage:
- Size: 25.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-golang-repositories - go_call_cxx_so
README
# Call C++ from Go with shared library
Modify From: https://github.com/draffensperger/go-interlang/tree/master/go_to_cxx/c_wrapper
## Build & Run
```
sh build_and_run.sh
```### Build .so
```
cd cpp/
mkdir build/
cd build/
cmake ..
make -j4
cp libmyso.so ../../libmyso.so
```### copy .hxx
```
cd ../
cp wrap_point.hxx ../
```### build go
```
cd ../
go build -o exe
```### Run
```
export LD_LIBRARY_PATH=.
./exe
```## Note
1. Add *#cgo LDFLAGS: -L"${SRCDIR}/libs"* to main.go
2. Generate .so look CMakeLists.txt