M
M
mr_blaze2018-07-22 09:35:07
C++ / C#
mr_blaze, 2018-07-22 09:35:07

How to fix undefined reference to existing function?

Hello! I've been writing in c++ for quite some time now. Trying to compile

This
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <RHVoice/core/engine.hpp>
#include <RHVoice/core/document.hpp>
#include <RHVoice/core/client.hpp>
#include <RHVoice/RHVoice.h>
#include <RHVoice/RHVoice_common.h>

using namespace std;
using namespace RHVoice;

int main(int argc, char **argv){
   RHVoice_init_params tts_params;
   RHVoice_tts_engine tts = RHVoice_new_tts_engine(&tts_params);
   cout << RHVoice_get_voices(tts) << endl;
   return 0;
}


team
g++ -I/usr/local/include/utf8 -I/usr/local/include/rapidxml -I/usr/local/include/RHVoice -I/usr/local/include  -o main main.cpp

But it throws an error
/tmp/ccAMF2oc.o: In function `main':
main.cpp:(.text+0x17): undefined reference to `RHVoice_new_tts_engine'
main.cpp:(.text+0x27): undefined reference to `RHVoice_get_voices'
collect2: error: ld returned 1 exit status

What flags do you need to add to g++ to make it work?
Thank you in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2018-07-22
@mr_blaze


main.cpp:(.text+0x17): undefined reference to `RHVoice_new_tts_engine'
main.cpp:(.text+0x27): undefined reference to `RHVoice_get_voices'

Judging by the path to the directory with headers, you need to add something like this: -L/usr/local/lib -lRHVoice. To find out for sure, you need to look where the RHVoice library (*.a or *.so) is installed and what it is called.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question