So I coding a simple tensor with Eigen as follows:
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <Eigen/Dense>
#include <unsupported/Eigen/CXX11/Tensor>
using namespace Eigen;
using namespace std;
int main () {
Tensor<double, 3> A(4,5,6); // 3 dimensions (4x5x6)
A.setZero();
A(0,1,2) = 1.7;
A(1,2,2) = -1.5;
cout<<A(1,2,2)<<endl;
return 0;
}
But then I get the following error and I looked around the internet for help, but sadly I am still clueless. I always get this error with my more advanced code, so I decided to do a small code just to test when I get this error. Note: I didn't get this error when I was did the same with an Eigen matrix. Only when I changed to a tensor, did I get this error. Then afterwards I changed it back to a matrix and I somehow get the same error now? However, even in my more advanced code I don't even have any tensors, but for some reason still get this error. Can someone please help me as this is driving me insane?
C:WINDOWSsystem32cmd.exe /C C:/MinGW/bin/mingw32-make.exe -j4 SHELL=cmd.exe -e -f Makefile
"----------Building project:[ Test - Debug ]----------"
mingw32-make.exe[1]: Entering directory 'C:/Users/RS3/Desktop/SCC HiWi/Code/C++/myGmm/UQ/Test'
mingw32-make.exe[1]: Leaving directory 'C:/Users/RS3/Desktop/SCC HiWi/Code/C++/myGmm/UQ/Test'
mingw32-make.exe[1]: Entering directory 'C:/Users/RS3/Desktop/SCC HiWi/Code/C++/myGmm/UQ/Test'
C:/MinGW/bin/g++.exe -c "C:/Users/RS3/Desktop/SCC HiWi/Code/C++/myGmm/UQ/Test/main.cpp" -std=c++14 -Wall -g -O0 -Wall -o ./Debug/main.cpp.o -I. -I"C:UsersRS3DesktopSCC HiWiCodeC++myGmmUQeigen-3.3.9" -I"C:UsersRS3DesktopSCC HiWiCodeC++myGmmUQHalton" -I"C:UsersRS3DesktopSCC HiWiCodeC++myGmmUQquasimvnrnd" -I"C:UsersRS3DesktopSCC HiWiCodeC++myGmmUQdirentdirent-masterinclude"
In file included from C:/Users/RS3/Desktop/SCC HiWi/Code/C++/myGmm/UQ/Test/main.cpp:5:
C:UsersRS3DesktopSCC HiWiCodeC++myGmmUQeigen-3.3.9/unsupported/Eigen/CXX11/Tensor:53:17: error: conflicting declaration 'typedef long int int32_t'
typedef __int32 int32_t;
^~~~~~~
In file included from c:mingwlibgccmingw328.2.0includestdint.h:9,
from c:mingwlibgccmingw328.2.0includec++cstdint:41,
from c:mingwlibgccmingw328.2.0includec++itschar_traits.h:501,
from c:mingwlibgccmingw328.2.0includec++ios:40,
from c:mingwlibgccmingw328.2.0includec++ostream:38,
from c:mingwlibgccmingw328.2.0includec++iostream:39,
from C:/Users/RS3/Desktop/SCC HiWi/Code/C++/myGmm/UQ/Test/main.cpp:2:
c:mingwincludestdint.h:62:15: note: previous declaration as 'typedef int int32_t'
typedef int int32_t;
^~~~~~~
In file included from C:/Users/RS3/Desktop/SCC HiWi/Code/C++/myGmm/UQ/Test/main.cpp:5:
C:UsersRS3DesktopSCC HiWiCodeC++myGmmUQeigen-3.3.9/unsupported/Eigen/CXX11/Tensor:54:26: error: conflicting declaration 'typedef long unsigned int uint32_t'
typedef unsigned __int32 uint32_t;
^~~~~~~~
In file included from c:mingwlibgccmingw328.2.0includestdint.h:9,
from c:mingwlibgccmingw328.2.0includec++cstdint:41,
from c:mingwlibgccmingw328.2.0includec++itschar_traits.h:501,
from c:mingwlibgccmingw328.2.0includec++ios:40,
from c:mingwlibgccmingw328.2.0includec++ostream:38,
from c:mingwlibgccmingw328.2.0includec++iostream:39,
from C:/Users/RS3/Desktop/SCC HiWi/Code/C++/myGmm/UQ/Test/main.cpp:2:
c:mingwincludestdint.h:63:19: note: previous declaration as 'typedef unsigned int uint32_t'
typedef unsigned uint32_t;
^~~~~~~~
mingw32-make.exe[1]: *** [Debug/main.cpp.o] Error 1
Test.mk:97: recipe for target 'Debug/main.cpp.o' failed
mingw32-make.exe[1]: Leaving directory 'C:/Users/RS3/Desktop/SCC HiWi/Code/C++/myGmm/UQ/Test'
mingw32-make.exe: *** [All] Error 2
Makefile:4: recipe for target 'All' failed
====1 errors, 4 warnings====
UPDATE: When I remove the last include and do the Eigen matrix again, there's no problem. So the problem is with the last include. But without it, I can't work with tensors. What should I do to work with tensors without the error?
question from:
https://stackoverflow.com/questions/65901014/how-to-solve-this-all-error-2-in-this-case 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…