It is in essence an C++ and compiler problem. But I will describe how does this error occur.
I am writing mathematica librarylink function using C++ and Eigen library, which is as follows
libsource = "#include \"WolframLibrary.h\"
#include <Eigen/Dense>
EXTERN_C DLLEXPORT int donothing(WolframLibraryData libData,mint \
Argc,MArgument*Args,MArgument Res) {
using namespace std;
using namespace Eigen;
Matrix2d a;
a<<1,2,3,4;
return LIBRARY_NO_ERROR;}";
And load it as using
LibraryFunctionUnload[donothing];
libnew = CreateLibrary[libsource, "donothing", "Debug" -> True,
"CompileOptions" -> "-x c++"];
donothing = LibraryFunctionLoad[libnew, "donothing", {}, "Void"];
I turned on debug, and mathematica ouput shell compilation result as below:
C:\Users\qq\AppData\Roaming\Mathematica\SystemFiles\LibraryResources\W\
indows-x86-64\Working-lenovo-qq-5144-7404-36>C:\mingw-w64\mingw64\bin\
\x86_64-w64-mingw32-gcc-5.2.0.exe -shared -o \
"C:\Users\qq\AppData\Roaming\Mathematica\SystemFiles\LibraryResources\
\Windows-x86-64\Working-lenovo-qq-5144-7404-36\donothing.dll" -g -x c++ \
-I"C:\Program Files\Wolfram \
Research\Mathematica\10.3\SystemFiles\IncludeFiles\C" -I"C:\Program \
Files\Wolfram \
Research\Mathematica\10.3\SystemFiles\Links\MathLink\DeveloperKit\W\
indows-x86-64\CompilerAdditions\mldev64\include" "C:\Users\qq\AppData\
\Roaming\Mathematica\SystemFiles\LibraryResources\Windows-x86-64\W\
orking-lenovo-qq-5144-7404-36\donothing.c" -L"C:\Program \
Files\Wolfram \
Research\Mathematica\10.3\SystemFiles\Links\MathLink\DeveloperKit\W\
indows-x86-64\CompilerAdditions\mldev64\lib" -L"C:\Program \
Files\Wolfram \
Research\Mathematica\10.3\SystemFiles\Libraries\Windows-x86-64" \
2>&1
R:\temp\cc9bBS4s.o:donothing.c:(.data+0x0): undefined reference to \
`__gxx_personality_seh0'
R:\temp\cc9bBS4s.o:donothing.c:(.xdata+0x10): undefined reference to \
`__gxx_personality_seh0'
collect2.exe: error: ld returned 1 exit status
Yesterday, I run the same code, it works perfectly. While now, I don't know what is wrong.
At the same time, all librarylink without Eigen library works well. And Eigen library is not damaged, since I can compile .cpp file using Eigen without problem.
How to solve this?
update
I don't know why my question marked as duplicate without any comment! I read that link, and it didn't solve my problem! I already said "yesterday it works well". I already use option "-x c++", and I also tried "-x c++ -lstdc++" and the error is __gxx_personality_seh0
not ___gxx_personality_v0