What is the purpose of __cxa_pure_virtual?
If anywhere in the runtime of your program an object is created with a virtual function pointer not filled in, and when the corresponding function is called, you will be calling a 'pure virtual function'.
The handler you describe should be defined in the default libraries that come with your development environment. If you happen to omit the default libraries, you will find this handler undefined: the linker sees a declaration, but no definition. That's when you need to provide your own version.
The infinite loop is acceptable because it's a 'loud' error: users of your software will immediately notice it. Any other 'loud' implementation is acceptable, too.
gcc undefined _cxa_pure_virtual
The lib in question is a C++ library and the __cxa_pure_virtual is needed by the C++ runtime. Suggest that you try first linking with g++ command instead of gcc.
Read more under this question: What is the purpose of cxa pure virtual
undefined symbol: __cxa_pure_virtual error when loading library from java
After rechecking all the answers related to my question on stackoverflow, I found out the answer by
Mark Seaborn to question: What is the purpose of __cxa_pure_virtual? fixed my problem.
As my jni library is managed by autotools, after adding "-Wl,--gc-sections -fPIC -shared -lstdc++" to AM_LDFLAGS of Makefile.am problems solved. libstdc++ might not necessary if code is compiled by a c++ compiler (e.g. g++).
Hope this could help others who have the same problem.
Linker errors when adding firebase framework to ios project
Sorry. We pushed a new version today that added a new dependency on libc++.dylib If you add that, it should build.
Note that there's also an issue with the current build that prevents building for arm64. Given that, you may want to just use the previous build: https://cdn.firebase.com/ObjC/Firebase.framework-1.0.9.zip
Else wait a day or so and we'll get the latest build straightened out.
Sorry for the inconvenience!
Where do pure virtual function call crashes come from?
They can result if you try to make a virtual function call from a constructor or destructor. Since you can't make a virtual function call from a constructor or destructor (the derived class object hasn't been constructed or has already been destroyed), it calls the base class version, which in the case of a pure virtual function, doesn't exist.
class Base
{
public:
Base() { reallyDoIt(); }
void reallyDoIt() { doIt(); } // DON'T DO THIS
virtual void doIt() = 0;
};
class Derived : public Base
{
void doIt() {}
};
int main(void)
{
Derived d; // This will cause "pure virtual function call" error
}
See also Raymond Chen's 2 articles on the subject
Related Topics
Creating, Opening and Printing a Word File from C++
How to Check Whether Multiple Variables Are Equal to the Same Value
Double Delete in Initializer_List VS 2013
How to Print to Console When Using Qt
Why Would I Prefer Using Vector to Deque
Windows C++ Compiler with Full C++11 Support (Should Work with Qt)
Questions About Hinnant's Stack Allocator
Why Use Precompiled Headers (C/C++)
Difference Between Enum and Define Statements
Why Does Boost.Asio Not Support an Event-Based Interface
Xxxxxx.Exe Is Not a Valid Win32 Application
What Does 'Auto && E' Do in Range-Based For-Loops
Why Was 1 << 31 Changed to Be Implementation-Defined in C++14
How to Generate Random Variable Names in C++ Using MACros
Global Function Definition in Header File - How to Avoid Duplicated Symbol Linkage Error