dlib example, test builds fail - c++

Running ubuntu 12.04, I downloaded the source and compiled it as instructed (see https://github.com/davisking/dlib). Below is the error message displayed.
cmake --build . --config Release
[ 1%] Building CXX object dlib_build/CMakeFiles/dlib.dir/bsp/bsp.cpp.o
In file included from /home/andreif/downlib/dlib-19.2/dlib/bsp/../sockets/../threads/parallel_for_extension.h:9:0,
from /home/my_path/dlib-19.2/dlib/bsp/../sockets/../threads.h:24,
from /home/my_path/dlib-19.2/dlib/bsp/../sockets/sockets_kernel_2.h:33,
from /home/my_path/dlib-19.2/dlib/bsp/../sockets/posix.h:4,
from /home/my_path/dlib-19.2/dlib/bsp/../sockets.h:14,
from /home/my_path/dlib-19.2/dlib/bsp/bsp.h:7,
from /home/my_path/dlib-19.2/dlib/bsp/bsp.cpp:6:
/home/my_path/dlib-19.2/dlib/bsp/../sockets/../threads/async.h: In function ‘std::future<typename std::result_of<_Functor(_ArgTypes="" ...)="">::type> dlib::async(dlib::thread_pool&, Function&&, Args&& ...)’:
/home/my_path/dlib-19.2/dlib/bsp/../sockets/../threads/async.h:63:15: error: expected nested-name-specifier before ‘bind_t’
/home/my_path/dlib-19.2/dlib/bsp/../sockets/../threads/async.h:63:15: error: ‘bind_t’ has not been declared
/home/my_path/dlib-19.2/dlib/bsp/../sockets/../threads/async.h:63:22: error: expected ‘;’ before ‘=’ token
/home/my_path/dlib-19.2/dlib/bsp/../sockets/../threads/async.h:63:22: error: expected primary-expression before ‘=’ token
/home/my_path/dlib-19.2/dlib/bsp/../sockets/../threads/async.h:63:24: error: expected primary-expression before ‘decltype’
/home/my_path/dlib-19.2/dlib/bsp/../sockets/../threads/async.h:63:24: error: expected ‘;’ before ‘decltype’
/home/my_path/dlib-19.2/dlib/bsp/../sockets/../threads/async.h:64:37: error: ‘bind_t’ was not declared in this scope
make[2]: [dlib_build/CMakeFiles/dlib.dir/bsp/bsp.cpp.o] Error 1
make[1]: [dlib_build/CMakeFiles/dlib.dir/all] Error 2
make: *** [all] Error 2

The problem was my c++ compiler: the default gcc 4.6 in ubuntu 12.04 has c++11 support, but it has to be enabled at the command line when calling it. I tried editing /.bashrc to automatically do this, but it didn't work. The solution for me was to install gcc/g++ 4.8 (and use update-alternatives to keep the old installation usable), as described here
http://mortenvp.com/installing-a-newer-gccg-on-ubuntu-12-04-lts/

Related

When compile llvm 3.1, why get error: expected primary-expression before ‘>’ token

For some reason, I need to install llvm 3.1 or llvm 3.0, but I'm getting this error when during make.
[ 5%] Building CXX object utils/TableGen/CMakeFiles/llvm-tblgen.dir/AsmMatcherEmitter.cpp.o
In file included from /home/ubuntu/llvm/utils/TableGen/AsmMatcherEmitter.cpp:103:0:
/home/ubuntu/llvm/include/llvm/ADT/PointerUnion.h: In member function ‘int llvm::PointerUnion3<PT1, PT2, PT3>::is() const’:
/home/ubuntu/llvm/include/llvm/ADT/PointerUnion.h:266:26: error: expected primary-expression before ‘>’ token
return Ty(Val).is<T>();
^
/home/ubuntu/llvm/include/llvm/ADT/PointerUnion.h:266:28: error: expected primary-expression before ‘)’ token
return Ty(Val).is<T>();
^
/home/ubuntu/llvm/include/llvm/ADT/PointerUnion.h: In member function ‘T llvm::PointerUnion3<PT1, PT2, PT3>::get() const’:
/home/ubuntu/llvm/include/llvm/ADT/PointerUnion.h:279:27: error: expected primary-expression before ‘>’ token
return Ty(Val).get<T>();
^'
/home/ubuntu/llvm/include/llvm/ADT/PointerUnion.h:279:29: error: expected primary-expression before ‘)’ token
return Ty(Val).get<T>();
^
I guess there might be a compatibility issue between llvm 3.0 and gcc 7.0.0, so I installed gcc-4.6.3, and use this cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/home/ubuntu/install -DCMAKE_CXX_LINK_FLAGS="-Wl,-rpath,$HOME/gcc463/install -L$HOME/gcc463/install" -G "Unix Makefiles" ../llvm to configure. But the same error still occurs. Anybody knows why and how to fix it? Thanks!!
Try passing -std=c++98 or if that does not work then -std=c++11. I'm afraid this maybe because of incompatibilities in different C++ versions.
Additionally, you may have to remove -std=c++14 from the CXXFLAGS if it is there. This is the default for g++7.
So I installed gcc-4.6.3, and use this
Did you change the CMAKE_C_COMPILER and CMAKE_CXX_COMPILER flag so that cmake can use the gcc-4.6 instead?
hth,

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?

Error building openCV - dumpOpenCLDevice() method error

I have been trying to build opencv for over a week now using the instructions at
http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html and http://miloq.blogspot.com/2012/12/install-opencv-ubuntu-linux.html however every time I get to the 'make' step, I get an error:
In file included from /home/sello/opencv-2.4.9/modules/nonfree/perf/perf_main.cpp:28:0:
/home/sello/opencv-2.4.9/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp: In function ‘void dumpOpenCLDevice()’:
/home/sello/opencv-2.4.9/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp:88:9: error: ‘PlatformsInfo’ is not a member of ‘cv::ocl’
/home/sello/opencv-2.4.9/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp:88:32: error: expected ‘;’ before ‘platforms’
/home/sello/opencv-2.4.9/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp:89:9: error: ‘getOpenCLPlatforms’ is not a member of ‘cv::ocl’
/home/sello/opencv-2.4.9/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp:89:37: error: ‘platforms’ was not declared in this scope
/home/sello/opencv-2.4.9/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp:95:19: error: ‘DevicesInfo’ in namespace ‘cv::ocl’ does not name a type
/home/sello/opencv-2.4.9/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp:96:39: error: ‘devices’ was not declared in this scope
/home/sello/opencv-2.4.9/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp:98:23: error: ‘DeviceInfo’ in namespace ‘cv::ocl’ does not name a type
/home/sello/opencv-2.4.9/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp:99:33: error: ‘current_device’ was not declared in this scope
/home/sello/opencv-2.4.9/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp:99:62: error: ‘CVCL_DEVICE_TYPE_CPU’ was not declared in this scope
/home/sello/opencv-2.4.9/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp:100:71: error: ‘CVCL_DEVICE_TYPE_GPU’ was not declared in this scope
In file included from /home/sello/opencv-2.4.9/modules/nonfree/perf/perf_main.cpp:28:0:
/home/sello/opencv-2.4.9/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp:108:15: error: ‘DeviceInfo’ in namespace ‘cv::ocl’ does not name a type
/home/sello/opencv-2.4.9/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp:110:9: error: ‘deviceInfo’ was not declared in this scope
/home/sello/opencv-2.4.9/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp:111:9: error: ‘deviceInfo’ was not declared in this scope
/home/sello/opencv-2.4.9/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp:113:25: error: ‘deviceInfo’ was not declared in this scope
/home/sello/opencv-2.4.9/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp:113:50: error: ‘CVCL_DEVICE_TYPE_CPU’ was not declared in this scope
/home/sello/opencv-2.4.9/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp:114:61: error: ‘CVCL_DEVICE_TYPE_GPU’ was not declared in this scope
make[2]: *** [modules/nonfree/CMakeFiles/opencv_perf_nonfree.dir/perf/perf_main.cpp.o] Error 1
make[1]: *** [modules/nonfree/CMakeFiles/opencv_perf_nonfree.dir/all] Error 2
make: *** [all] Error 2
The process works well for a while and then stops at 79% with the above error. I thought the problem might be caused by the fact that I did not have the OpenCL library installed. I installed it as shown at www.amd-dev.wpengine.netdna-cdn.com/wordpress/media/2013/07/AMD_APP_SDK_Installation_Notes.pdf and still no luck. I am running ubuntu 12.04 and OpenCV 2.4.9. The installed version of AMD APP SDK is 2.8.1.0. Please help. I am at my wits end here.
I experienced the same problem and solved it for me by compiling OpenCV without modules needing GPU functionality using the following cmake command in the release folder:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_OPENCL=OFF -D WITH_CUDA=OFF -D BUILD_opencv_gpu=OFF -D BUILD_opencv_nonfree=OFF -D BUILD_opencv_stitching=OFF -D BUILD_opencv_superres=OFF ..
The following modules are then deactivated: gpu, nonfree, stitching, superres

MySQL Connect/C++ 64 bit build error

I am using Netbeans and MacoSX and installed 64bit connector. On building I am getting following errors:
/usr/bin/make -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-conf
/usr/bin/make -f nbproject/Makefile-Debug.mk dist/Debug/GNU-MacOSX/inventory
mkdir -p build/Debug/GNU-MacOSX
rm -f build/Debug/GNU-MacOSX/addproduct.o.d
g++ -c -g -Iinclude -Iinclude -MMD -MP -MF build/Debug/GNU-MacOSX/addproduct.o.d -o build/Debug/GNU-MacOSX/addproduct.o addproduct.cpp
from addproduct.cpp:10:
In file included from include/mysql_connection.h:30,
include/cppconn/connection.h:31:29: warning: boost/variant.hpp: No such file or directory
In file included from addproduct.cpp:10:
include/mysql_connection.h:31:32: warning: boost/shared_ptr.hpp: No such file or directory
from addproduct.cpp:10:
In file included from include/mysql_connection.h:30,
include/cppconn/connection.h:41: error: 'boost' has not been declared
include/cppconn/connection.h:41: error: expected initializer before '<' token
include/cppconn/connection.h:43: error: 'ConnectPropertyVal' was not declared in this scope
include/cppconn/connection.h:43: error: template argument 2 is invalid
include/cppconn/connection.h:43: error: template argument 4 is invalid
include/cppconn/connection.h:43: error: invalid type in declaration before ';' token
In file included from addproduct.cpp:10:
include/mysql_connection.h:75: error: 'ConnectPropertyVal' is not a member of 'sql'
include/mysql_connection.h:75: error: 'ConnectPropertyVal' is not a member of 'sql'
include/mysql_connection.h:75: error: template argument 2 is invalid
include/mysql_connection.h:75: error: template argument 4 is invalid
include/mysql_connection.h:157: error: 'ConnectPropertyVal' is not a member of 'sql'
include/mysql_connection.h:157: error: 'ConnectPropertyVal' is not a member of 'sql'
include/mysql_connection.h:157: error: template argument 2 is invalid
include/mysql_connection.h:157: error: template argument 4 is invalid
include/mysql_connection.h:160: error: 'boost' has not been declared
include/mysql_connection.h:160: error: ISO C++ forbids declaration of 'shared_ptr' with no type
include/mysql_connection.h:160: error: expected ';' before '<' token
make[2]: *** [build/Debug/GNU-MacOSX/addproduct.o] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 538ms)
In Netbeans I am linking libmysqlcppconn.dylib only.
What files am I missing?
Why is it asking for BOOST? and which Boost Libs do I need to install?
mysql_connection.h includes #include <boost/shared_ptr.hpp>, you could either use latest versions of boost or modify below lines mysql_connection.h to use std::shared_ptr instead:
update
#include <boost/shared_ptr.hpp>
boost::shared_ptr< NativeAPI::NativeConnectionWrapper > proxy;
to
#include <memory>
std::shared_ptr< NativeAPI::NativeConnectionWrapper > proxy;
Have you read the documentation entitled "21.4.2. Installing MySQL Connector/C++ from Source"? Read the entire page carefully, then look for links specific to MacOSX...

has ::std::has_nothrow_default_constructor been moved/changed?

In trying to build boost mirror with gcc 4.7.2, I ran into this error, but oddly enough, I see this documentation.
Has ::std::has_nothrow_default_constructor been moved/changed?
In file included from /home/kfeng/src/mirror-lib/include/mirror/type_traits.hpp:20:0,
from /home/kfeng/src/mirror-lib/include/mirror/mirror_base.hpp:38,
from /home/kfeng/src/mirror-lib/include/mirror/mirror.hpp:16,
from /home/kfeng/src/mirror-lib/src/mirror/example/all_member_variables.cpp:10:
/home/kfeng/src/mirror-lib/include/mirror/type_traits/is_default_constructible.hpp:31:2: error: ‘has_nothrow_default_constructor’ is not a member of ‘std’
/home/kfeng/src/mirror-lib/include/mirror/type_traits/is_default_constructible.hpp:28:9: error: parse error in template argument list
/home/kfeng/src/mirror-lib/include/mirror/type_traits/is_default_constructible.hpp:31:43: error: expected ‘{’ before ‘::’ token
/home/kfeng/src/mirror-lib/include/mirror/type_traits/is_default_constructible.hpp:31:51: error: expected initializer before ‘||’ token
In file included from /home/kfeng/src/mirror-lib/include/mirror/type_traits.hpp:21:0,
from /home/kfeng/src/mirror-lib/include/mirror/mirror_base.hpp:38,
from /home/kfeng/src/mirror-lib/include/mirror/mirror.hpp:16,
from /home/kfeng/src/mirror-lib/src/mirror/example/all_member_variables.cpp:10:
/home/kfeng/src/mirror-lib/include/mirror/type_traits/is_copy_constructible.hpp:31:2: error: ‘has_nothrow_copy_constructor’ is not a member of ‘std’
/home/kfeng/src/mirror-lib/include/mirror/type_traits/is_copy_constructible.hpp:28:9: error: parse error in template argument list
/home/kfeng/src/mirror-lib/include/mirror/type_traits/is_copy_constructible.hpp:31:40: error: expected ‘{’ before ‘::’ token
/home/kfeng/src/mirror-lib/include/mirror/type_traits/is_copy_constructible.hpp:31:48: error: expected initializer before ‘||’ token
make[2]: *** [src/mirror/example/CMakeFiles/mirror-all_member_variables.dir/all_member_variables.cpp.o] Error 1
make[1]: *** [src/mirror/example/CMakeFiles/mirror-all_member_variables.dir/all] Error 2
make: *** [all] Error 2
ANSWER using Pubby's Note Below
Something like this should work with gcc 4.7.2 - I will submit a patch and let the maintainer decide how best to deal with it.
template <typename T>
struct is_default_constructible
: std::integral_constant<
bool,
::std::has_trivial_default_constructor<T>::value ||
#if __cplusplus>=201103L
::std::is_nothrow_default_constructible<T>::value ||
#else
::std::has_nothrow_default_constructor<T>::value ||
#endif
mirror::_class::_<T>::has_default_ctr::value>
{ };
In C++11 it was changed to std::is_nothrow_default_constructible to be more consistent with naming.
You are looking at documentation for GCC 4.6.2, but using GCC 4.7.2, so it's not very surprising they don't match.
The traits were renamed by n3142
See a previous answer of mine https://stackoverflow.com/a/12716778/981959 for some code that attempts to detect which is supported by your compiler, although a comment says it doesn't work with libc++.