JueWangDeMengXin 2021-08-12 20:44 采纳率: 0%
浏览 22
已结题

ubuntu20.04,golang引用c++,引用。cpp文件可以,引用.h文件报错

报错未定义的引用

//test.cpp
#include <stdio.h>
#include "test.h"
void print(char* path){
     printf("%s\n",path);
};


//test.h
#include <stdio.h>
void print(char* path);


//test.go
package main
/*
#include "test.h"
*/
import "C"

func main(){
    cpath := C.CString("hello")
    C.print(cpath)
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 8月20日
    • 修改了问题 8月12日
    • 修改了问题 8月12日
    • 创建了问题 8月12日