Code::Blocks

User forums => Using Code::Blocks => Topic started by: hubert on August 08, 2017, 09:19:53 am

Title: CodeBlocks can't find #include <Random.h>
Post by: hubert on August 08, 2017, 09:19:53 am
Hello,

in my Header I have #include <Random.h>
in my "Settings" > "Compiler" >
I have:

 "Custom variables"
BOOSTINCLUDE = C:/MinGW/boost/include/boost
BOOSTVARIANTE = -mgw-mt
BOOSTLIBDIR = C:\MinGW\boost\lib

"Linker Settings"
boost_system$(BOOSTVARIANTE)
boost_filesystem$(BOOSTVARIANTE)

"Search directories"
"Compiler"
%USERPROFILE%\Documents\cppbuch\include
$(BOOSTVARIANTE)

"Linker"
$(BOOSTLIBDIR)

But when compiling it says:
fatal error. Random.h: No such file or Directory
=== Build failed: 1 error(s), 0 warning(s)     ...and so on

Can anybody please help ?

Greatings
hubert

Title: Re: CodeBlocks can't find #include <Random.h>
Post by: oBFusCATed on August 08, 2017, 09:29:11 am
If random is a boost header you have two errors:
1. C:/MinGW/boost/include/boost should be C:/MinGW/boost/include
2. the include should be <boost/random.h>
Title: Re: CodeBlocks can't find #include <Random.h>
Post by: hubert on August 08, 2017, 12:02:52 pm
Hello oBFusCATed ,

thanks, but that did not work.
I've got the code from a book's Website, which's test programms all worked up to now (when not using boost or any random method).

Any idea ?

Greatings
hubert
Title: Re: CodeBlocks can't find #include <Random.h>
Post by: Miguel Gimenez on August 08, 2017, 01:01:46 pm
Do you have boost? Not all MingW distros have integrated boost.

If you have boost, locate random.h and use the path in Search directories -> Compiler (leave the custom variable step for a second stage). As Obfuscated said, you should remove the last "boost" from the path and use #incude "boost/random.h".

The name of the include file is random.h, not Random.h; in Windows this is not an issue, but if you want code portability you should use the correct name from start.
Title: Re: CodeBlocks can't find #include <Random.h>
Post by: hubert on August 08, 2017, 01:17:36 pm
Hello Miguel,

1.) I have boost
2.) I removed the last "boost" from "Custom variables" Setting so now it says
BOOSTINCLUDE = C:/MinGW/boost/include
BOOSTVARIANTE = -mgw-mt
BOOSTLIBDIR = C/MinGW/boost/lib
Although it made sense to me to have the final "boost" here, because when installing the MinGW
I got the boost-stuff in the directories:
C:/MinGW/boost/lib
and
C:/MinGW/boost/include/boost/boost
WHICH (three times boost !?) looks redundant or weired, doesn't it ?

Greatings
hubert

3.) #include <boost/random.h>   did not help

Title: Re: CodeBlocks can't find #include <Random.h>
Post by: Miguel Gimenez on August 08, 2017, 01:53:03 pm
Did you edit Search directories -> Compiler? The content you posted didn't have the BOOSTINCLUDE variable. Add C:/MinGW/boost/include/boost to search directories and test again; when you get it working do the conversion to a custom variable.
Title: Re: CodeBlocks can't find #include <Random.h>
Post by: hubert on August 08, 2017, 03:04:07 pm
Hello Miguel,

yes, I  edited the  Search directories -> Compiler and I have the BOOSTINCLUDE variable.
I tried your idea >>>
Add C:/MinGW/boost/include/boost to search directories and test again....

It does not work !
I've got to go now, but I will continue on that Problem tomorrow and then I can send you all the configurations of mine...
Thanks, perhaps Hearing of you tomorrow

hubert
Title: Re: CodeBlocks can't find #include <Random.h>
Post by: stahta01 on August 08, 2017, 03:22:25 pm
Post a build log!
http://wiki.codeblocks.org/index.php/FAQ-Compiling_(errors)#Q:_How_do_I_troubleshoot_a_compiler_problem.3F (http://wiki.codeblocks.org/index.php/FAQ-Compiling_(errors)#Q:_How_do_I_troubleshoot_a_compiler_problem.3F)
Title: Re: CodeBlocks can't find #include <Random.h>
Post by: Krice on August 10, 2017, 10:09:44 am
Boost document and their example seems to indicate that you don't include random.h but one or more of random engine .hpp headers in this list:

http://www.boost.org/doc/libs/1_64_0/doc/html/boost_random/reference.html#headers
Title: Re: CodeBlocks can't find #include <Random.h>
Post by: Miguel Gimenez on August 10, 2017, 02:07:01 pm
In fact random.h does not exist, the correct name is random.hpp