I compiled a library with g++
and I want to link against it with gcc
.
Problem is I get an error while linking against it:
undefined reference to 'functionName`
(functionName is the function name in the library)
although the function exists in the symbols list and I specify the path to gcc
while linking.
It happens because the function appears in the list with surrounding characters (I think this is for overriding?):
Z12functionNameiSt9__va_list
I know that to remove these characters I should surround the function declaration with extern "C"
. And I did that:
//header.hpp
extern "C" int functionName(int argc, ...);
But the surrounding characters still appear around the function name in the symbols list. And that's why gcc
can't find it.
I'm cross compiling for linux arm yokto with arm-poky-linux-gnueabi-gcc
and arm-poky-linux-gnueabi-g++
on Ubuntu desktop 16.
Why aren't the surrounding characters being removed and how can I remove them? I will never override this function so if these are really for overriding then I don't need them.
edit:
Solved. The function signature in its declaration was different from the signature in its definition... So the extern
keyword was for nothing.
int functionName(int argc, ...); //declaration
int functionName(int argc, va_list args) //definition