error: 'log1p' is not a member of 'std' - c++

I create a simple main function and above it, I include armadillo library.
#include <armadillo>
I compiled it using g++ (version of GCC is 5.3) and under cygwin 64bit on windowse 8. I turned on c++11 option and added -larmadillo for linking to armadillo library.
Once I compile the code, I receive such horrible error. The same code runs absolutely fine on windowse XP 32 bit.
usr/include/armadillo_bits/compiler_setup.hpp:73:88: note: #pragma message: WAR
NING: #define ARMA_DONT_USE_CXX11 before #include <armadillo>
#pragma message ("WARNING: #define ARMA_DONT_USE_CXX11 before #include <arm
adillo>")
^
In file included from /usr/include/armadillo:310:0,
from main.cpp:1:
/usr/include/armadillo_bits/arma_cmath.hpp: In function 'float arma::arma_log1p(
float)':
/usr/include/armadillo_bits/arma_cmath.hpp:270:12: error: 'log1p' is not a membe
r of 'std'
return std::log1p(x);
^
compilation terminated due to -Wfatal-errors.
Makefile:110: recipe for target 'main.o' failed
make: *** [main.o] Error 1

Related

How to solve this [All] Error 2 in this case?

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:\WINDOWS\system32\cmd.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:\Users\RS3\Desktop\SCC HiWi\Code\C++\myGmm\UQ\eigen-3.3.9" -I"C:\Users\RS3\Desktop\SCC HiWi\Code\C++\myGmm\UQ\Halton" -I"C:\Users\RS3\Desktop\SCC HiWi\Code\C++\myGmm\UQ\quasimvnrnd" -I"C:\Users\RS3\Desktop\SCC HiWi\Code\C++\myGmm\UQ\dirent\dirent-master\include"
In file included from C:/Users/RS3/Desktop/SCC HiWi/Code/C++/myGmm/UQ/Test/main.cpp:5:
C:\Users\RS3\Desktop\SCC HiWi\Code\C++\myGmm\UQ\eigen-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:\mingw\lib\gcc\mingw32\8.2.0\include\stdint.h:9,
from c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\cstdint:41,
from c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\bits\char_traits.h:501,
from c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\ios:40,
from c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\iostream:39,
from C:/Users/RS3/Desktop/SCC HiWi/Code/C++/myGmm/UQ/Test/main.cpp:2:
c:\mingw\include\stdint.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:\Users\RS3\Desktop\SCC HiWi\Code\C++\myGmm\UQ\eigen-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:\mingw\lib\gcc\mingw32\8.2.0\include\stdint.h:9,
from c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\cstdint:41,
from c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\bits\char_traits.h:501,
from c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\ios:40,
from c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\iostream:39,
from C:/Users/RS3/Desktop/SCC HiWi/Code/C++/myGmm/UQ/Test/main.cpp:2:
c:\mingw\include\stdint.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?
Can you let us know where your version of MinGW comes from?
The issue is that your version of MinGW is apparently defining __int32 as long but int32_t as int, leading to a type conflict. We had some code in the Tensor module to ensure int32_t is always defined on Windows, since Visual Studio prior to 2010 doesn't actually provide an stdint.h header. We've never seen this cause an issue before. I tried several versions of MinGW, both 32-bit and 64-bit, but in all the ones I've tried so far __int32 is always an int.
I have a potential fix pending on the master branch here: !373. Once it's merged we can backport the change to the stable 3.3 branch.
If you just want to get something up and running, you can try installing a different version of MinGW.

make opencv on windows,get a error

I using cmake and mingw-w64 to make opencv on windows 10,however,i get a error when make it on 97%.
there are error report:
[ 96%] Built target opencv_videostab
[ 97%] Building CXX object modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2.cpp.obj
In file included from C:/PROGRA~1/Python36/include/Python.h:8:0,
from D:\Program Files (x86)\OpenCv_3.2.0\opencv\sources\modules\python\src2\cv2.cpp:6:
C:/PROGRA~1/Python36/include/pyconfig.h:379:5: warning: "_MSC_VER" is not defined, evaluates to 0 [-Wundef]
#if _MSC_VER >= 1800
^~~~~~~~
In file included from D:/Program Files (x86)/MinGw_64/mingw64/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++/math.h: 36:0,
from C:/PROGRA~1/Python36/include/pyport.h:194,
from C:/PROGRA~1/Python36/include/Python.h:50,
from D:\Program Files (x86)\OpenCv_3.2.0\opencv\sources\modules\python\src2\cv2.cpp:6:
D:/Program Files (x86)/MinGw_64/mingw64/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++/cmath:42:10: fatal error: D:/ Program Files (x86)/MinGw_64/mingw64/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++/bits/cpp_type_traits.h>: Invalid argument
#include <bits/cpp_type_traits.h>s
^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
mingw32-make[2]: ***[modules\python3\CMakeFiles\opencv_python3.dir\build.make:180: modules/python3/CMakeFiles/ope ncv_python3.dir/__/src2/cv2.cpp.obj] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:6794: modules/python3/CMakeFiles/opencv_python3.dir/all] Error 2
mingw32-make: *** [Makefile:160: all] Error 2
What can i do to slove it?
update:
i had sloved it,it's a bug fot mingww64,the error erport
:cmath:42:10: fatal error: D:/ Program Files (x86)/MinGw_64/mingw64/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++/bits/cpp_type_traits.h>: Invalid argument #include <bits/cpp_type_traits.h>s
said having a error to head file,so i just delete the 's' after include statement,that is include <bits/cpp_type_traits.h>

<atomic> not implemented while building a ROOT class

I have been trying to make a ROOT Class called RooUnfold which miserably fails while building with these errors:
Use ROOT 6.06/08 for macosx64 from /usr/local/Cellar/root6/6.06.08
Making /Users/sudoankit/root/RooUnfold-master/libRooUnfold.rootmap
In file included from /Users/sudoankit/root/RooUnfold-master/tmp/macosx64/RooUnfoldMap_LinkDef.cxx:1:
In file included from /usr/local/Cellar/root6/6.06.08/include/root/TObject.h:31:
In file included from /usr/local/Cellar/root6/6.06.08/include/root/Rtypes.h:37:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/atomic:543:2: error:
<atomic> is not implemented
#error <atomic> is not implemented
^
1 error generated.
make: *** [/Users/sudoankit/root/RooUnfold-master/libRooUnfold.rootmap] Error 1
How do I build it with <atomic> library?

c++ compiles in Ubuntu but not in centOS

I have a bunch of code which compiles in Ubuntu using GCC 4.8.4.
When I transfer to centOS and compile it there the following errors occur:
[ 0%] Building CXX object src/chrono/CMakeFiles/ChronoEngine.dir/core/ChClassRegister.cpp.o
In file included from /home/com/medyn/chrono/chrono_ver1/Chrono_source_Old/src/chrono/core/ChClassRegister.cpp:21:
/home/com/medyn/chrono/chrono_ver1/Chrono_source_Old/src/chrono/core/ChClassRegister.h: In destructor 'chrono::ChClassFactory::~ChClassFactory()':
/home/com/medyn/chrono/chrono_ver1/Chrono_source_Old/src/chrono/core/ChClassRegister.h:225: error: expected initializer before ':' token
/home/com/medyn/chrono/chrono_ver1/Chrono_source_Old/src/chrono/core/ChClassRegister.h:228: error: could not convert '((chrono::ChLog*)chrono::GetLog())->chrono::ChLog::<anonymous>.chrono::ChStreamOutAscii::operator<<(((const char*)"Delete ChClassFactory \012"))' to 'bool'
/home/com/medyn/chrono/chrono_ver1/Chrono_source_Old/src/chrono/core/ChClassRegister.h:229: error: expected primary-expression before '}' token
/home/com/medyn/chrono/chrono_ver1/Chrono_source_Old/src/chrono/core/ChClassRegister.h:229: error: expected ')' before '}' token
/home/com/medyn/chrono/chrono_ver1/Chrono_source_Old/src/chrono/core/ChClassRegister.h:229: error: expected primary-expression before '}' token
/home/com/medyn/chrono/chrono_ver1/Chrono_source_Old/src/chrono/core/ChClassRegister.h:229: error: expected ';' before '}' token
make[2]: *** [src/chrono/CMakeFiles/ChronoEngine.dir/core/ChClassRegister.cpp.o] Error 1
make[1]: *** [src/chrono/CMakeFiles/ChronoEngine.dir/all] Error 2
make: *** [all] Error 2
These errors are for both GCC 4.4.7 and GCC 4.8.5.
The lines of code for which it gives the error are:
~ChClassFactory () {
for(const auto & it : class_map ) {
GetLog() << " registered: " << it.first << "\n";
}
GetLog() << "Delete ChClassFactory \n";
}
And the files included at the top of this script are:
#include <stdio.h>
#include <string>
#include <typeinfo>
#include "core/ChLog.h"
#include "core/ChRunTimeType.h"
#include <unordered_map>
I have checked that all of the include files exists and I have made another script to test if I can use them, and I can.
The reason why I don't stay with Ubuntu is because the Supercomputer I have to use is running centOS.
Does anyone have a solution for this problem?
Please let my know if you need additional information.
Regards,
Anders
Edit
With the GCC 4.8.5 version the program provided by NathanOliver compiles and run.
I compile it directly from terminal using:
g++ -std=c++11 main.cpp -o main
./main
1 2 3 4 5
And it runs with -std=c++0x.
Somehow I cant use -std=c++14.
It gives the following error:
g++: error: unrecognized command line option '-std=c++14'
Edit
So to get back to the main problem. My Makefile I have, have the following line:
//Flags used by the compiler during all build types.
CMAKE_CXX_FLAGS:STRING=-std=c++0x
So I can't see why the program should not run?

Qt 5.1 Beta Error using std::atomic c++11 feature

I have just started to work with QT and am still getting familiar with the compilation process. Currently, I am trying to port an existing QT project to Mac. This app compiles and runs on Linux and Windows.
When I compile the project on Mac OSX 10.8.2 , I am getting this c++11 related error ,
#include ../xxx/pch.h:71:10: fatal error: 'atomic' file not found
#include <atomic>
^
1 error generated.
make[1]: *** [debug/xxx/objective-c++.pch] Error 1
make: *** [debug] Error 2
11:32:01: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project xxx (kit: Qt5.1.0)
When executing step 'Make'
I have included the below flags in the.pro file to enable c++11 ,
QMAKE_CXXFLAGS += -std=c++11
CONFIG += c++11
I am building the project with the pre-built QT5.1Beta package (Clang) which I believe has c++11 enabled.
I see the atomic header in the below locations
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/atomic
and in /usr/lib/c++/v1/atomic
I tried testing by including the complete path ,
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr//lib/c++/v1/atomic
I am getting the below error,
In file included from ../xxx/pch.h:71:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/atomic:535:2:
error: atomic is not implemented
In file included from ../xxx/pch.h:124:
../../../yyy.h:308:12: error: no type named 'atomic' in namespace 'std'
std::atomic<bool> m_signaled;
What am I missing here?
Add also
macx:QMAKE_CXXFLAGS += -stdlib=libc++
macx:QMAKE_LFLAGS += -stdlib=libc++
Maybe it is a bit late, but I fixed it using the -std=gnu++0x flag