请教,当我使用cgo集成时,发生了一些不理解的错误。
tonyupup opened this issue · 1 comments
tonyupup commented
同样的command.h我使用cgo链接动态库时,产生大量后缀为"_I.pcm"的静音文件。但是我用vad-demo 测试同样的音频文件 ,可以生成正确的后缀为"_A.pcm"的文件。不知道是怎么回事?可以帮我看一下吗?这是我的部分代码。
music.go
package trans
/*
#cgo LDFLAGS: -Wl,-rpath="/home/admin/goproj/trans/lib"
#cgo LDFLAGS: -L./lib -lvad
int split(const char *,const char *);
#include "stdlib.h"
*/
import "C"
...
split.c
int split(const char *filename,const char *output_dir) {
const char output_filename_prefix[] = "16k"; // 保存的文件名
FILE *fp = fopen(filename, "rb");
if (fp == NULL) {
...
main.c
extern int split(const char *,const char *);
int main(int argc,char *argv[]){
return split(argv[1],argv[2]);
}
CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
set(CMAKE_VERBOSE_MAKEFILE on)
project(vad-demo)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
#set(CMAKE_C_STANDARD 99)
file(GLOB SRC_FILES src/*.c src/*.h thirdparty/webrtc/common_audio/*/*.c thirdparty/webrtc/rtc_base/*.c*)
include_directories(thirdparty/webrtc) #thirdparty/include/webrtc
add_library(vad SHARED ${SRC_FILES})
add_executable(vad-demo main.c)
target_link_libraries(vad-demo vad pthread)
tonyupup commented
this is my program bug.