C++ inlining class methods causes undefined reference
The body of an inline function needs to be in the header so that the compiler can actually substitute it wherever required. See this: How do you tell the compiler to make a member function inline?
undefined reference when calling inline function
According to the manual, passing -std=gnu11
enables C99 instead of GNU inline semantics.
This means inline
, static inline
and extern inline
all behave differently. In particular, inline
expects an external definition in a separate translation unit (which you can provide without duplicating the definition - see this answer).
Undefined symbol error when use inline methods in C++
An inline function needs it's definition to be available in the file that is calling that function.
So if You define it in one cpp file and try to call it in a second cpp file, then it will not be found.
What You need to do is move this definition into the h file. (just cut & paste it after the class definition).
Or as @einpoklum has noticed, if You don't need it, remove the inline from all the definitions.
Error undefined reference to to some not-inline methods of a library
It seems the problem is caused by a broken cmake list. After several changes i can compile both now. However this looks realy strange to me, since all files existed in the cmakelists.
Related Topics
Why Is It Allowed to Pass R-Values by Const Reference But Not by Normal Reference
Overloading Operator<<: Cannot Bind Lvalue to 'Std::Basic_Ostream<Char>&&'
Variadic Function Template with Pack Expansion Not in Last Parameter
How to Parse Ini File with Boost
How to Use Boost Bind with a Member Function
Why Is the New Random Library Better Than Std::Rand()
How to Compose Output Streams, So Output Goes Multiple Places at Once
C++17 Class Template Partial Deduction
How to Run a Child Process That Requires Elevation and Wait
Passing Arguments to Std::Async by Reference Fails
How to Specify Preference of Library Path
How to Initialize C++ Object Member Variables in the Constructor