Ask Your Question
0

How to solve CMAKE compiler error in CentOS machine ?

asked 2018-06-08 08:38:36 -0600

azdoud.y gravatar image

updated 2018-06-08 09:05:23 -0600

Hello,

I've developed a code in Qt IDE in windows and when I run it, it works well, however, when I passed to run the code in CentOS machine with CMAKE I got these error :

[azdoud@video-processor CentOSsimple]$ make Scanning dependencies of target main [100%] Building CXX object CMakeFiles/main.dir/main.cpp.o In file included from /usr/include/c++/4.8.2/thread:35:0, from /opt/working/CentOSsimple/main.cpp:5:

  /usr/include/c++/4.8.2/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
   #error This file requires compiler and library support for the \
    ^
  /opt/working/CentOSsimple/main.cpp: In function ‘void loadVideo1(cv::VideoCapture, int, int)’:
  /opt/working/CentOSsimple/main.cpp:24:65: error: ‘to_string’ was not declared in this scope
           cv::putText(frame, "Frame "+to_string(frameNum+seek_step),
                                                                   ^
  /opt/working/CentOSsimple/main.cpp: In function ‘int main()’:
  /opt/working/CentOSsimple/main.cpp:92:10: error: ‘future1’ does not name a type
       auto future1 = std::async(loadVideo, cap1,0,1);
            ^
  /opt/working/CentOSsimple/main.cpp:93:10: error: ‘future2’ does not name a type
       auto future2 = std::async(loadVideo, cap2,750,2);
            ^
  /opt/working/CentOSsimple/main.cpp:94:10: error: ‘future3’ does not name a type
       auto future3 = std::async(loadVideo, cap3,1000,3);
            ^
  /opt/working/CentOSsimple/main.cpp:96:13: error: ‘future1’ was not declared in this scope
       cout << future1.get() << endl;
               ^
  /opt/working/CentOSsimple/main.cpp:97:13: error: ‘future2’ was not declared in this scope
       cout << future2.get() << endl;
               ^
  /opt/working/CentOSsimple/main.cpp:98:13: error: ‘future3’ was not declared in this scope
       cout << future3.get() << endl;
               ^
  make[2]: *** [CMakeFiles/main.dir/main.cpp.o] Error 1
  make[1]: *** [CMakeFiles/main.dir/all] Error 2
  make: *** [all] Error 2

I've followed this documentation to set opencv and cmake in my machine, I've tested it, its works well too as you can see

    [azdoud@video-processor CentOSsimple]$ make
    Scanning dependencies of target main
    [100%] Building CXX object CMakeFiles/main.dir/main.cpp.o
    Linking CXX executable main
    [100%] Built target main
    [azdoud@video-processor CentOSsimple]$ ll
    total 60
    -rw-rw-r--. 1 azdoud azdoud 13171 Jun  8 11:40 CMakeCache.txt
    drwxrwxr-x. 5 azdoud azdoud  4096 Jun  8 11:41 CMakeFiles
    -rw-rw-r--. 1 azdoud azdoud  1585 Jun  8 11:40 cmake_install.cmake
    -rw-rw-r--. 1 azdoud azdoud   166 Jun  8 11:39 CMakeLists.txt
    -rwxrwxr-x. 1 azdoud azdoud 18912 Jun  8 11:41 main
    -rw-rw-r--. 1 azdoud azdoud   435 Jun  8 11:02 main.cpp
    -rw-rw-r--. 1 azdoud azdoud  4646 Jun  8 11:40 Makefile
    [azdoud@video-processor CentOSsimple]$ ./main
    Width : 37
    Height: 69

This is the simple code that I'm trying to run in linux machine

    #include <iostream> // for standard I/O
    #include <opencv2/core/core.hpp>        // Basic OpenCV structures (cv::Mat, Scalar)
    #include <opencv2 ...
(more)
edit retag flag offensive close merge delete

Comments

tnaksalot for the edit, no we can quote it easily ;)

berak gravatar imageberak ( 2018-06-08 09:07:39 -0600 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2018-06-08 09:10:57 -0600

berak gravatar image

updated 2018-06-08 09:11:26 -0600

your centos compiler (4.8.2) is quite old, and does not know c++11 by default.

since you're already using cmake, try adding

-DCMAKE_CXX_FLAGS="-std=c++11"

to the cmake cmdline

edit flag offensive delete link more

Comments

My compiler version is 7 not 4.8.2 I did not understand why it shows 4.8.2

[azdoud@video]$ gcc --version
gcc (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5)
Copyright (C) 2017 Free Software Foundation, Inc.
azdoud.y gravatar imageazdoud.y ( 2018-06-08 09:33:21 -0600 )edit

thank you @berak it works

azdoud.y gravatar imageazdoud.y ( 2018-06-08 09:50:37 -0600 )edit

^^ yea, that looks like latest.

berak gravatar imageberak ( 2018-06-08 09:51:11 -0600 )edit

did you solve the version riddle ?

berak gravatar imageberak ( 2018-06-08 09:53:41 -0600 )edit

I have just type in the command line cmake -DCMAKE_CXX_FLAGS="-std=c++11"

azdoud.y gravatar imageazdoud.y ( 2018-06-08 10:06:14 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-06-08 08:38:36 -0600

Seen: 452 times

Last updated: Jun 08 '18