Reputation: 91
I'm on ubuntu 18.04 and i'm trying to compile a .c file that came with an API that i'm working which is called vosk. The issue is that the python code works without any problems but if i try to
gcc test_vosk.c -o test_vosk
the .c file that they provide to run the API it gives me this error:
test_vosk.c:1:10: fatal error: vosk_api.h: No such file or directory
#include <vosk_api.h>
^~~~~~~~~~~~
compilation terminated.
so i tried to make
the Makefile which is in the same directory of the test_vosk.c file but it gives me:
g++ test_vosk.o -o test_vosk -L../src -lvosk -ldl -lpthread -Wl,-rpath=../src
/usr/bin/ld: cannot find -lvosk
collect2: error: ld returned 1 exit status
Makefile:8: recipe for target 'test_vosk' failed
make: *** [test_vosk] Error 1
which make sense as the directory /usr/bin/ld doesn't actually exists on my machine. Then i tried to move the vosk_api.h file from it's directory (which is a parent of the directory in which there is the test_vosk.c) to the same directory of the test_vosk.c file and change the
#include <vosk_api.h>
into a
#include "vosk_api.h"
and now if i compile again
gcc test_vosk.c -o test_vosk
it gives me:
/tmp/cct4dVqp.o: In function `main':
test_vosk.c:(.text+0x22): undefined reference to `vosk_model_new'
test_vosk.c:(.text+0x40): undefined reference to `vosk_recognizer_new'
test_vosk.c:(.text+0xc7): undefined reference to `vosk_recognizer_accept_waveform'
test_vosk.c:(.text+0xe5): undefined reference to `vosk_recognizer_result'
test_vosk.c:(.text+0xfe): undefined reference to `vosk_recognizer_partial_result'
test_vosk.c:(.text+0x12c): undefined reference to `vosk_recognizer_final_result'
test_vosk.c:(.text+0x143): undefined reference to `vosk_recognizer_free'
test_vosk.c:(.text+0x152): undefined reference to `vosk_model_free'
collect2: error: ld returned 1 exit status
I've been stuck on this for days now and i really don't know where to go, i'm pretty new at linux as i'm still learning the basics but if someone could help me it would be really appreciated. Thanks in advance!
Upvotes: 2
Views: 568
Reputation: 91
Thanks to both for the answer!!!!
So the test_vosk.c couldn't compile because it couldn't find the libvosk.so so i found a prebuilt binary of it and put it in the /lib directory and then run make
from the makefile which was in the same directory of test_vosk.c which compiled it ...
But now it can't run which drives me mad as the same script but in python runs without a problem.
I'll open a new issue so this one remains solved.
Upvotes: 2