3

I am trying to run some simulations, but when I try to compile my code I get an error that says

random: No such file or directory

The beginning of my code looks like

#include<iostream>
#include<iomanip>
#include<cmath>
#include<stdlib.h>
#include<random>
#include<set>
#include<algorithm>
#include<fstream>
#include<vector>

using namespace std;

I'm using Dev-C++ 5.0 beta 9.2. I should note that this code compiles just fine on my home computer.

Edit:

There is no option to change "Language standard" under my compiler options: enter image description here enter image description here

kccu
  • 283
  • 2
  • 10
  • 3
    Are you compiling with the `-std=c++11` flag set? – πάντα ῥεῖ Oct 13 '16 at 15:47
  • I don't know what that means. – kccu Oct 13 '16 at 15:48
  • What toolchain do you use in Dev-C++? – πάντα ῥεῖ Oct 13 '16 at 15:49
  • 1
    @kccu See [here](http://www.cplusplus.com/doc/tutorial/introduction/devcpp/) please. – πάντα ῥεῖ Oct 13 '16 at 15:52
  • My compiler options window does not look like that.http://i65.tinypic.com/2mx0eft.png – kccu Oct 13 '16 at 15:57
  • Check the C++ Compiler tab. – πάντα ῥεῖ Oct 13 '16 at 16:00
  • Not there either. http://i66.tinypic.com/23h3yuq.png – kccu Oct 13 '16 at 16:02
  • This question http://stackoverflow.com/questions/16951376/how-to-change-mode-from-c98-mode-in-dev-c-to-a-mode-that-supports-c0x-ran suggested adding "-std=C++0x" or "-std=c++11" but neither work. – kccu Oct 13 '16 at 16:03
  • Could you please edit your question to add screenshots and such, I'll reopen your question afterwards. Also please provide your toolchain and its version. – πάντα ῥεῖ Oct 13 '16 at 16:05
  • I don't know what a "toolchain" is or how to determine its version. – kccu Oct 13 '16 at 16:08
  • The toolchain is the c++ compiler used by your Dev-C++ IDE. – πάντα ῥεῖ Oct 13 '16 at 16:08
  • That still doesn't help me determine its version. As I said in my question I'm running Dev-C++ 5.0 beta 9.2. Their website says "It uses Mingw port of GCC (GNU Compiler Collection) as it's compiler." – kccu Oct 13 '16 at 16:10
  • You can update your installation of MinGW to the latest version independently of what was shipped with Dev-C++ originally. May be that helps. – πάντα ῥεῖ Oct 13 '16 at 16:13
  • I just installed Dev-C++ today, so everything should be the latest version... – kccu Oct 13 '16 at 16:30
  • From [here](http://orwelldevcpp.blogspot.de/) it seems the latest Dev C++ version is 5.11. Also that doesn't mean it is shipped with the lates MinGW GCC. You can check the compiler version opening a shell window and type in `g++ --version`. – πάντα ῥεῖ Oct 13 '16 at 16:34
  • I don't know what you mean by opening a shell window in Dev C++. – kccu Oct 13 '16 at 17:20
  • On windows it's the `cmd` Window (Input Prompt), I didn't mean from Dev-C++. – πάντα ῥεῖ Oct 13 '16 at 17:22
  • When I try that I get a message that says "'g++' is not recognized as an internal or external command, operable program or batch file." – kccu Oct 13 '16 at 17:50
  • Use the full path where it's installed to invoke then. – πάντα ῥεῖ Oct 13 '16 at 17:52
  • The version says "3.4.2 (mingw-special)." The real issue is that I cannot change the language standard in Dev C++ because the compiler options window does not seem to have that option. I remember changing it on my home computer without a problem. – kccu Oct 13 '16 at 18:05
  • Do you see the bit in the second screenshot where it says `-std=C++0x`? Change that to `-std=c++11` (note the case of the `C`) and see if that works. Alternatively, try just making the `C` lowercase. – Nic Oct 13 '16 at 18:09
  • When I tried that I got a message that said "unrecognized command line option "-std=c++11"" – kccu Oct 13 '16 at 18:11
  • 2
    @kccu Try the flag you have with a lowercase `c` instead of an uppercase one? – Nic Oct 13 '16 at 18:11
  • The C needs to be lower case in the `-std=C++0x` – NathanOliver Oct 13 '16 at 18:12
  • Same problem: "unrecognized command line option "-std=c++0x"" – kccu Oct 13 '16 at 18:12
  • What compiler is installed? Which version? (Dev-C++ is not a compiler but an IDE for a compiler) – NathanOliver Oct 13 '16 at 18:14
  • I have already answered that question in the comments above: Dev C++ says it uses "Mingw port of GCC (GNU Compiler Collection)." The version of g++ installed is "3.4.2 (mingw-special)." – kccu Oct 13 '16 at 18:16
  • @kccu (1) Please add that to the question, then. (2) GCC 3.4 [doesn't seem to support any C++11 features](https://gcc.gnu.org/projects/cxx-status.html#cxx11). – Nic Oct 13 '16 at 18:20
  • You need a higher version of GCC then. – NathanOliver Oct 13 '16 at 18:20
  • @kccu As mentioned earlier, the compiler version shipped with Dev-C++ isn't necessarily the latest one, and you can update it separately. – πάντα ῥεῖ Oct 13 '16 at 18:23
  • If you want to use Dev C++ as an IDE, it's probably better if you install the more recent Orwell forked version, the one linked in πάντα ῥεῖ comment above and mentioned in the Q&A you linked earlier. – Bob__ Oct 13 '16 at 18:35
  • I've downloaded the more recent version of C++ and was able to change the language standard. Thank you everyone for your help. – kccu Oct 13 '16 at 19:42

1 Answers1

2

You have to set the -std=c++11 flag to use this C++11 Feature! Random requires C++11 for its use.

  • 3
    The problem apparently is that OP doesn't know how to do that in the Dev-C++ IDE. – πάντα ῥεῖ Oct 13 '16 at 15:50
  • I tried to follow the steps here (http://stackoverflow.com/questions/13613295/how-can-i-compile-c11-code-with-orwell-dev-c) to set this, but once I get to "Code Generation" there's no "Language standard" option – kccu Oct 13 '16 at 15:52
  • Before trying to set c++11, OP is using Dev-C++ 5.0 beta 9.2! – EFenix Oct 13 '16 at 16:01