Re: [go-nuts] Using C++ code with cgo

2019-04-11 Thread av
Works like charm. Thanks a lot. Here is my code: aptwrap.h #ifdef __cplusplus extern "C" { #endif void print(); #ifdef __cplusplus } #endif aptwrap.cpp #include "aptwrap.h" #include #include #include #ifdef __cplusplus extern "C" { #endif void print() { std::cout << "

[go-nuts] Compile C++ with cgo

2019-04-11 Thread av
Hi *, I want to compile C++ code, because the library I need is C++ only. Here is my wrapper.hpp: #include void print() { std::cout << "Xx"; } And here is my main.go: package main // #cgo CXXFLAGS: -I. // #cgo CFLAGS: -I. // #cgo LDFLAGS: // #include "wrapper.hpp" import "C" func main() {