The objective is to allow the end-user to configure the library using Go build tags. For example:
lib.go --------------------------- package lib #include "cpplib/common.cpp" #include "cpplib/wrapper.cpp" import "C" --------------------------- backend1.go --------------------------- // +build backend1 package lib #include "cpplib/backend1.cpp" import "C" --------------------------- backend2.go --------------------------- // +build backend2 package lib #include "cpplib/backend2.cpp" import "C" --------------------------- So the user build the library for different backends: >go install -tags backend1 or >go install -tags backend2 On Monday, November 1, 2021 at 5:13:14 PM UTC-3 Ian Lance Taylor wrote: > On Sun, Oct 31, 2021 at 10:17 AM Elemer Pixard <elp...@gmail.com> wrote: > > > > I am developing a binding to a C++ library > > using a wrapper module (using extern "C" directive). > > The C++ library files are in a subdirectory of the package. > > > > If I create a file in the package directory such as: > > > > lib.cpp > > -------------- > > #include "cpplib/file.cpp" > > #include "cpplib/wrapper.cpp" > > -------------- > > > > It works, but if I create a Go file instead such as: > > > > lib.go > > -------------- > > package lib > > > > // #include "cpplib/file.cpp" > > // #include "cpplib/wrapper.cpp" > > import "C" > > ... > > -------------- > > > > This doesn't compile because cgo uses gcc instead of g++. > > I would prefer this second way because I need to > > configure the build using tags. > > Is there a way to solve this ? > > There is no way to get this to work using #include "cpplib/file.cpp" > in the cgo comment. > > I don't understand why the lib.cpp approach doesn't work, though. You > say that it needs tags, but what tags does it need? > > Ian > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/ba041b6b-764c-4b30-90cb-c2cc28479935n%40googlegroups.com.