error when including <chrono> - c++

I've tried to include the class to measure the time it takes for a segment of code to run. These are my includes:
#include <iostream>
#include <fstream>
#include <math.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
my error message is:
FILENAME.cpp:4: chrono: No such file or directory
What's the matter with my code?

From my comment:
Are you using a C++11 compiler? With g++, try giving it "-std=c++11".
g++ -std=c++11 myfile.cpp
With clang it's probably the same.

Related

Syntax highlighting for llvm c++ api in clion

Right now I'm quite extensively using the C++-Api for LLVM IR. I'm using CLion as my IDE and im building and linking the project via a Makefile.
The includes look like the following
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Type.h"
The problem now is that I don't have any syntax highlighting for the things coming from the llvm headers. How do I enable that.

inlining failed in call to always_inline '__m256d _mm256_broadcast_sd(const double*)'

I'm trying to run a Visual Studio cpp project created by a friend of mine. I'm trying to run the file without VS. But I'm getting a list of errors, all in the same format:
inlining failed in call to always_inline '__m256d _mm256_broadcast_sd(const double*)': target specific option mismatch|
It runs correctly in VS with release mode and breaks when run in debug mode.
The includes are as follows:
#include "stdafx.h"
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <vector>
# include <omp.h>
#include <chrono>
#include <fstream>
#include <algorithm>
#include <immintrin.h>
using namespace std::chrono;
using namespace std;
and the error is called from here:
double zero = 0;
__m256d acc = _mm256_broadcast_sd(&zero);
Update:
I'm using the this command to run it: g++ -std=c++0x multip.cpp -o multip, is there an additional parameter to add -mavx to the compiler invocation?
"Target specific option mismatch" means that you're missing a feature flag from your GCC invocation. You probably need to add -mavx to your compiler invocation.
If you're intending to run this on your computer only, -march=native will turn on all the feature flags that your own machine supports.

C++ program compiling without functional header

As per CPP Doc, std::greater is defined in <functional> header but my C++ program using std::greater is compiling with TDM-GCC-64 5.1.0 and running with only the following includes :
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
It could be because <algorithm> automatically includes <functional> but since this is not mentioned in the doc, I was wondering is there a way to know this before hand ?
Just to close the topic, the conclusion is that this is implementation dependent and all the necessary headers should be included for portability.

"No such file" Include issue with Boost dynamic_bitset

I'm trying to use Boost's Dynamic_bitset class for a project, and I (believe I) have taken whichever subset of files I needed from the complete library. Now I'm doing an
#include "boost/dynamic_bitset.hpp" inside my manager.cpp file, and when compiling I get this:
In file included from manager.cpp:4:0:
boost/dynamic_bitset.hpp:15:51: fatal error: boost/dynamic_bitset/dynamic_bitset.hpp: No such file or directory
The file ierarchy inside the project folder goes like this:
proj/extras.h
proj/Makefile~
proj/manager.cpp
proj/boost
proj/boost/limits.hpp
proj/boost/dynamic_bitset.hpp
proj/boost/mpl
proj/boost/mpl/if.hpp
proj/boost/mpl/has_xxx.hpp
proj/boost/iterator.hpp
proj/boost/static_assert.hpp
proj/boost/dynamic_bitset
proj/boost/dynamic_bitset/dynamic_bitset.hpp
proj/boost/dynamic_bitset/config.hpp
proj/boost/config
proj/boost/config/select_platform_config.hpp
proj/boost/config/select_compiler_config.hpp
proj/boost/config/user.hpp
proj/boost/config/suffix.hpp
proj/boost/config/select_stdlib_config.hpp
proj/boost/dynamic_bitset_fwd.hpp
proj/boost/config.hpp
proj/boost/type_traits
proj/boost/type_traits/is_same.hpp
proj/boost/type_traits/is_pointer.hpp
proj/boost/type_traits/remove_pointer.hpp
proj/boost/type_traits/remove_const.hpp
proj/boost/type_traits/is_base_and_derived.hpp
proj/boost/type_traits/detail
proj/boost/type_traits/detail/bool_trait_def.hpp
proj/boost/type_traits/detail/yes_no_type.hpp
proj/boost/pending
proj/boost/pending/integer_log2.hpp
proj/boost/detail
proj/boost/detail/limits.hpp
proj/boost/detail/dynamic_bitset.hpp
proj/boost/detail/workaround.hpp
proj/boost/lowest_bit.hpp
proj/Makefile
proj/generator.cpp~
proj/generator.cpp
This same project compiles fine on my university's linux systems(g++ 4.2.4 there but I doubt it matters), but fails to do so (with the above error) on my Ubuntu laptop. Why isn't it finding the file since it evidently exists?
All my includes are as such:
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include "boost/dynamic_bitset.hpp"
#include <cmath>
#include <list>
#include <unistd.h>
#include <sys/sem.h>
#include <sys/shm.h>
#include <errno.h>
#include <wait.h>
#include <time.h>
#include "extras.h"
compilation is done simply with
g++ -o manager manager.c
or
g++ -Iboost -o manager manager.c
if I want to explicitely include the (local..) folder
-I .
At least if you are compiling in the same directory that contains boost.
You wrote -Iboost and #include "boost/…". So it looks in ./boost if there is a boost subdirectory.

Symbol boost could not be resolved

I am using boost and eclipse as my IDE.
Boost is located in /home/ubuntu/cpp/boost_1_52_0/boost
In eclipse IDE I get a red squiggly line in red that says:
symbol boost could not be resolved-> using namespace boost;
In the ide and eclipse settings I have the includes have the path home/ubuntu/cpp/boost_1_52_0/
specified. Soo..how to I make boost work? What am I missing?
#include <iostream>
#include <stdlib.h>
#include <vector>
#include <string>
#include <time.h>
#include <boost/tokenizer.hpp>
using namespace boost;
using namespace std;