I am trying to use a library called libRNA. I installed it following the instructions on their website.
If I am calling functions of that library in a main.c
file, I can compile it using the gcc compiler and it works like charm:
gcc -g -Wall -fopenmp -std=c++11 test.c -lRNA -lm -o test.out
But if we rename the file to main.cpp
and compiling it with gcc
gcc -g -Wall -fopenmp -std=c++11 test.cpp -lRNA -lm -lstdc++ -o test.out
none of the referenced functions of the RNA lib can be found:
/home/joachim/tutorial_libs/test.cpp:18: undefined reference to `vrna_alloc(unsigned int)'
/home/joachim/tutorial_libs/test.cpp:19: undefined reference to `vrna_alloc(unsigned int)'
etc...
I read that gcc treats .cpp files as c++ files and .c files as c files. Does this mean I can not link the library with a c++ file? But how can it then be achieved to use the library within a c++ application? (needless to say that using g++ would not change the situation.)
I am thankful for any hint or suggestion for additional reading! Thanks in advance!