Using cgo gives fatal error

image
I need to access a variable (DefTerm,rovalue and greet) and a function (driv) under .cpp files

image

I am using cgo for first and not sure about the syntax.
I wrote the Go program to access the variable and function from .go file
But I get the error as " fatal error: ‘stdlib.h’ file not found".

package main

// #include <stdio.h>
// #include <errno.h>
import “C”

import main/cdir

dterm = cdir.DefTerm

func test() {
cvalue = cdir.World(“dd”,“@cyu”)

}

How to write the efficient code. Thanks

cgo only lets you access C, not C++. You have to define C wrappers around the C++ code and then use those C wrappers from Go.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.