I have a go file (print.go):
import (
"C"
"fmt"
)
//export SumPrint
func SumPrint(a, b int) C.int {
fmt.Println("Sum printed form GO code = ", a+b)
return C.int(a + b)
}
func main() {}
and C++ file (main.cpp), which will use the method SumPrint.
#include <iostream>
#include "libprinter.h"
int main() {
int a, b;
std::cin >> a >> b;
std::cout << "Sum of " << a << " and " << b << " is : " << SumPrint(a, b) << std::endl;
return 0;
}
When generating .dll file from go code it is giving error:
E:\Test> go build -buildmode=c-shared -o libprinter.dll print.go
go: no Go source files
I installed mingw gcc compiler and added the path in ENV, then it is building perfectly.
But the issue is the library im not able to use in Visual Studio to build the C++ code (which is using cl compiler).
So, I want to generate the go library with cl compiler so that I can use it in Visual Studio.