1

I am trying to include WebRTC VAD into my project, specifically I want the feature for distinguishing audio between voiced and unvoiced but having troubles including it. I am using gcc Built by MinGW-W64 project.

I tried its official repo and even its some community made repo as well but I just can't get them to work. I'm getting some unable to find files error then more unreferenced errors. Please help me how to structure my project to include all necessary files and a makefile would be appreciated. This is how I am including it:#include"webrtc/common_audio/vad/webrtc_vad.c" I tried making gcc use root directory (which contains webrtc) using I. but getting unreferenced, specifically:

gcc -I. main.c -o main
C:\Users\ALLAHI~1\AppData\Local\Temp\ccovjJHo.o:main.c:(.text+0x8f5): undefined reference to `WebRtcSpl_Init'
C:\Users\ALLAHI~1\AppData\Local\Temp\ccovjJHo.o:main.c:(.text+0x93e): undefined reference to `WebRtcVad_InitCore'
C:\Users\ALLAHI~1\AppData\Local\Temp\ccovjJHo.o:main.c:(.text+0x992): undefined reference to `WebRtcVad_set_mode_core'
C:\Users\ALLAHI~1\AppData\Local\Temp\ccovjJHo.o:main.c:(.text+0xa39): undefined reference to `WebRtcVad_CalcVad48khz'
C:\Users\ALLAHI~1\AppData\Local\Temp\ccovjJHo.o:main.c:(.text+0xa5e): undefined reference to `WebRtcVad_CalcVad32khz'
C:\Users\ALLAHI~1\AppData\Local\Temp\ccovjJHo.o:main.c:(.text+0xa83): undefined reference to `WebRtcVad_CalcVad16khz'
C:\Users\ALLAHI~1\AppData\Local\Temp\ccovjJHo.o:main.c:(.text+0xaa8): undefined reference to `WebRtcVad_CalcVad8khz'
collect2.exe: error: ld returned 1 exit status
1
  • tag compiler-errors is to mark questions about errors in compilers, not errors in your code Commented Aug 4 at 13:58

2 Answers 2

1

This is how I am including it:#include"webrtc/common_audio/vad/webrtc_vad.c"

It is definitelly wrong.

If you want to build from source - clone the repo, then follow the instruction of how to build the libray.

In your code:

  • include .h files contaning data definitions and function protitypes
  • link against the previously build library.

But building VAD & WebRTC is not easy if you are not familiar with build systems (Cmake & gn)

Sign up to request clarification or add additional context in comments.

2 Comments

Not easily usable is what bothering me, but I can't even find proper instructions on how to build it. Can you give link to its documentation, specifically telling how to build it?
repos vahe brief instructions - but of course they assume some level of build system knowledge
1

I finally after about hours of trying to get it to work I got it. Posting here how I did it so if anyone had trouble building like me they can benefit:

These are the commands for building:

gcc -c -I. webrtc/common_audio/signal_processing/*.c
gcc -c -I. webrtc/common_audio/vad/*.c
ar rcs libwebrtc_vad.lib *.o

You should keep your root directory clean from .o files before running this. You may need to rename your folder or change directory where you are running this. When you run those commands you may get error about some neon header ignore it they are not required. And one more file is required which you can make yourself. Give it name: stub_rtc.c this is what i used you can modify it except the function signature if you want to:

// stub_rtc.c
#include <stdio.h>
#include <stdlib.h>

void rtc_FatalMessage(const char* file, int line, const char* msg) {
    fprintf(stderr, "FATAL ERROR in %s:%d - %s\n", file, line, msg);
    exit(1);
}

and make its object file also. Now your directory will filled with .o files. Combine them into a single static library for easy use using this:

ar rcs libwebrtc_vad.lib *.o
Use .a extension for Unix/ Mac. You can now delete the webrtc folder but keep the header file which i used in my question. You can now compile your program which uses webrtc_vad using this:

gcc -c main.c
gcc main.o ./libwebrtc_vad.lib -o main

where main is the program you want to compile be sure the lib file are within the same directory or give proper path to it. You dont need to compile webrtc again just link the lib file with your project.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.