Algorithm header llrint, llround compiler error - c++

I'm learning C++ and I'm at the point of using the <algorithm> header and I get this compiler error even with an empty project:
/Users/italrolando/hpc-gcc47/bin/../lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/cmath:1108:11: error: '::llrint' has not been declared
/Users/italrolando/hpc-gcc47/bin/../lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/cmath:1109:11: error: '::llrintf' has not been declared
/Users/italrolando/hpc-gcc47/bin/../lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/cmath:1110:11: error: '::llrintl' has not been declared
/Users/italrolando/hpc-gcc47/bin/../lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/cmath:1112:11: error: '::llround' has not been declared
/Users/italrolando/hpc-gcc47/bin/../lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/cmath:1113:11: error: '::llroundf' has not been declared
/Users/italrolando/hpc-gcc47/bin/../lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/cmath:1114:11: error: '::llroundl' has not been declared
make: *** [algorithm.o] Error 1
Here is the code:
#include <iostream>
#include <algorithm>
using namespace std;
int main( int argc, char ** argv ){
return 0;
}
I'm using Eclipse with GCC 4.7.1 compiler and it's quite strange since the course I'm following is using Eclipse with Gcc 4.7 and it works.
Thanks

Related

Possible namespace errors in OpenCV header files

I'm just now getting into OpenCV (4.1.0) in C++ (relatively new to both) and I'm getting an odd error from simply including some header files. (GCC 6.3.0)
Error:
from c:\Users\Logan\Projects\Code\C++\webcamTest.cpp:1:
C:\Users\Logan\Projects\Code\C++\Includes\opencv\build\include/opencv2/core/utility.hpp:697:14: error: 'recursive_mutex' in namespace 'std' does not name a type
typedef std::recursive_mutex Mutex;
^~~~~~~~~~~~~~~
C:\Users\Logan\Projects\Code\C++\Includes\opencv\build\include/opencv2/core/utility.hpp:698:25: error: 'Mutex' is not a member of 'cv'
typedef std::lock_guard<cv::Mutex> AutoLock;
^~
C:\Users\Logan\Projects\Code\C++\Includes\opencv\build\include/opencv2/core/utility.hpp:698:25: error: 'Mutex' is not a member of 'cv'
C:\Users\Logan\Projects\Code\C++\Includes\opencv\build\include/opencv2/core/utility.hpp:698:34: error: template argument 1 is invalid
typedef std::lock_guard<cv::Mutex> AutoLock;
Code:
#include <opencv2/core.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/highgui.hpp>
int main()
{
return 0;
}
To me this looks like an error with the way the headers are set up, but perhaps I didn't set something up correctly?
Currently the command I'm using is as follows:
g++ -std=c++11 -g -I C:\\Users\\Logan\\Projects\\Code\\C++\\Includes\\opencv\\build\\include -o C:\\Users\\Logan\\Projects\\Code\\C++\\Bins\\<File name I'm using in the editor>.exe <File I'm using in the editor>

error: 'to_string' was not declared in this scope in Windows using cmd

I'm trying compile this code in cmd:
#include <iostream>
#include <string>
using namespace std;
int main(){
int n = 24;
string s = to_string(n);
cout<<s;
}
I found in another qestions, that I should use this command:
g++ -std=c++11 main.cpp
but I get error:
main.cpp: In function 'int main()':
main.cpp:7:24: error: 'to_string' was not declared in this scope
string s = to_string(n);
^
I have latest g++ compiler for Windows v. 5.3.0. I used this installer for MinGW.
I tried solve in to_string is not a member of std, says g++, but this patch doesn't work.
How can I compile this code in command line in Windows?

compilation errors when trying to include boost/any.hpp from boost

I am not sure what happened to my system, but now when I try to include boost/any.hpp in a program test.cc
#include <iostream>
#include <boost/any.hpp>
int main(int argc, char *argv[])
{
std::cout << "hello" << std::endl;
return 0;
}
using g++ -o test test.cc, I get the following error:
In file included from test.cc:2:0:
/usr/include/boost/any.hpp: In function 'ValueType boost::any_cast(boost::any&)':
/usr/include/boost/any.hpp:278:52: error: 'if_' in namespace 'boost::mpl' does not name a template type
typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_<
^ /usr/include/boost/any.hpp:278:55: error: expected unqualified-id before '<' token
typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_<
^ /usr/include/boost/any.hpp:284:28: error: 'ref_type' does not name a type
return static_cast<ref_type>(*result);
Everything is fine when I remove the include to any.hpp. I am using boost-1.56.0 and gcc-4.9.3.
Things were compiling fine a week ago, but I am not sure what I might have updated to cause this error. Any help would be appreciated.

FI_Init_FreeType variable declaration error

I am trying to write a simple program that uses freetype.
code :
#include <ft2build.h>
#include FT_FREETYPE_H
int main()
{
FT_Library library;
int error = FI_Init_FreeType(&library);
}
i am compiling as g++ try1_c++demo.cpp -I/usr/include/freetype2
it gives following error:
try1_c++demo.cpp: In function ‘int main()’:
try1_c++demo.cpp:9: error: ‘FI_Init_FreeType’ was not declared in this scope
how do i solve this error?

Can't build sigqueue example with gcc but g++ is ok?

I have a strange build problem.
I have a simple test program that sends a sigqueue to another process.
This little code example builds and runs when I build it as a c++ program (compiled with g++)
but when I compile it as a c program (with gcc) I get a error that he can't find the sigval struct.
The short example:
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#include <sys/types.h>
int main(int argc, char *argv[])
{
sigval value;
value.sival_int = 123;
sigqueue(0,SIGUSR1, value);
}
Please note that I replaced the pid with 0 to simplify this question.
And if I compile with gcc I get this:
$> gcc sigusr1_mini.c
sigusr1_mini.c: In function ‘main’:
sigusr1_mini.c:9: error: ‘sigval’ undeclared (first use in this function)
sigusr1_mini.c:9: error: (Each undeclared identifier is reported only once
sigusr1_mini.c:9: error: for each function it appears in.)
sigusr1_mini.c:9: error: expected ‘;’ before ‘value’
sigusr1_mini.c:10: error: ‘value’ undeclared (first use in this function)
What am I missing here, why can't he find the sigval struct?
And why can g++ find it?
Thanks
Johan
In C, struct and union tags do not introduce names that can be used on their own like they do in C++. You must spell it out:
union sigval value;
How is sigval defined in h-file? C compiler may require full definition, for example:
union sigval value;