Undefined reference in one function; other functions are fine

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Undefined reference in one function; other functions are fine

ソリューションへジャンプ
34,758件の閲覧回数
chadgraham
Contributor V

Hello,

I have a very large project that consists of numerous libraries and a ThreadX RTOS application.  In one of the libraries, I have a C++ class that handles mutexes and I can compile that library without issues.  However, when I compile the code application, I get an error "undefined reference to `_txe_mutex_info_get'".

I have double checked the includes, the include paths, the libraries, the library paths, but everything seems correct.  (Commenting out the "tx_mutex_info_get()" function call kills the error.)  To make it more frustrating, both the library and the application code have been playing nice for over a year and the function call "tx_mutex_info_get()" is used in other functions in the same class without errors.  I've walked all of the changes I've made since the last compile, but that too has proven unfruitful.

Does anyone have any suggestions?

UINT RtController_Mutexes::_getMutexOwner(
TX_MUTEX * mutex,
TX_THREAD ** owner)
{
UINT status;
std::string msg;
CHAR ** name = NULL;
ULONG * count = NULL;
TX_THREAD ** first_suspended = NULL;
ULONG * suspend_count = NULL;
TX_MUTEX ** next_mutex = NULL;

status = tx_mutex_info_get(
mutex,
name,
count,
owner,
first_suspended,
suspend_count,
next_mutex);

// Check for log file controller creation error.
if( status != TX_SUCCESS)
{
// Error stuff
} else
return( status);
}

 

0 件の賞賛
返信
1 解決策
34,739件の閲覧回数
ErichStyger
Specialist I

'undefined reference' means that you are calling that method/function/object, but the linker cannot find it.

A few things to check:

- is txe_mutex_info_get called with C or C++ name mangling? It could be that it has been compiled with C++, but you are calling it with C naming? (note: extern "C")

- use the IDE image info: is that object in question present in the binary or not?

- provide a dummy/empty txe_mutex_info_get() in your application, just to make the linker happy. Then check the map file what happend with the one from the OS

- are you using higher level of optimizations? I have seen cases with some 'not so clean code' where the compiler/linker have removed objects, which had lead to such errors

 

I hope this helps,

Erich

元の投稿で解決策を見る

2 返答(返信)
34,740件の閲覧回数
ErichStyger
Specialist I

'undefined reference' means that you are calling that method/function/object, but the linker cannot find it.

A few things to check:

- is txe_mutex_info_get called with C or C++ name mangling? It could be that it has been compiled with C++, but you are calling it with C naming? (note: extern "C")

- use the IDE image info: is that object in question present in the binary or not?

- provide a dummy/empty txe_mutex_info_get() in your application, just to make the linker happy. Then check the map file what happend with the one from the OS

- are you using higher level of optimizations? I have seen cases with some 'not so clean code' where the compiler/linker have removed objects, which had lead to such errors

 

I hope this helps,

Erich

34,702件の閲覧回数
chadgraham
Contributor V

Thanks Erich!  I was able to determine that the functions were in the library, but the functions were indeed mangled.  I ended up revamping the includes and added "extern "C"" to the "#include" statements and I'm moving forward again.  Thanks!

0 件の賞賛
返信