CLion Boost library - c++

I have installed Boost library following these commands:
I have extracted downloaded boost_1_67_0.7zfile
Then I have executed command bootstrap.bat gcc
Then I executed command b2 install --prefix=c:/Boost toolset=gcc
Then I restared my computer, just in case
Then I have opened CLion (newest version) and tried to include boost library in my program with find_package(Boost), but that doesn't work for me. Am I doing something wrong here or there is some other problem?
CMake file
Source code for my program
Folder hierarchy
Also I tried to say CMake whereis Boost installed with command
set(BOOST_ROOT C:/Boost/include/boost-1_67)
Then CMake can detect Boost, but it doesn't want to compile because it
can't find any file, for example boost/thread.hpp.

Related

Boost with Qt Creator

I was trying to use boost/filesystem in my C++ project made with QtCreator.
The problem was that when building, I got the following error:
"error: undefined reference to `boost::system::generic_category()'"
To use boost, I had performed the following actions:
download boost library boost_1_73_0.7z file
unzip it in my computer (under D:\Development\Boost)
in .pro file, I have added the following option
INCLUDEPATH += D:/Development/Boost
in my .cpp file, I have added the following include
#include "boost/filesystem.hpp"
At this point, when compiling, I had the following error in Qt creator IDE
"error: undefined reference to `boost::system::generic_category()'"
The root cause is the following : FileSystem needs to be built. Therefore, I have built this boost library by :
adding gcc and g++ to the path variable (it is succesful as I could call 'g++' and 'gcc' from the command prompt).
opening Qt command prompt (I used Qt 5.15.0 (MinGW 73.0 64-bit) ) and by navigating to the repository where boost is installed.
executing the following command in the command prompt in the directory (D:\Development\Boost): bootstrap gcc
executing the following command in the command prompt in the directory where I had unzipped Boost: b2 toolset=gcc link=shared threading=multi --build-type=complete stage. This action has created a the directory D:\develoment\Boost\Stage\lib with all the dll, including 'libboost_filesystem-mgw8-mt-d-x64-1_73.dll'.
Now it's time to link the library in Qt creator. I have thus added the following in my .pro file:
LIBS += -LD:/Development/Boost/stage/lib libboost_filesystem-mgw8-mt-d-x64-1_73
When compiling, the error is gone.
Thanks for your help.
Gatien
As #drescherjm commented, you need to build the boost libraries.
They are not in the D:/Development/Boost/libs directory.
You appear to be using Windows and have boost installed on your "D:" drive.
I assume your using the MinGw compiler that comes with Qt Creator, not Visual Studio.
To build boost with MinGw, first open the relevant Qt Command prompt, e.g. Qt 5.12.3 (MinGW 7.3.0 64-bit) and type the following:
D:
cd \Development\Boost
bootstrap.bat gcc
b2 toolset=gcc link=shared threading=multi --build-type=complete stage
This will build the MinGw boost libraries in your directory: D:\Development\Boost\stage\lib.
Then change the link command to:
LIBS += -LD:/Development/Boost/stage/lib -l boost_system-mgw73-mt-x64-d-1_66
Note: the precise name of the boost_system library depends upon how boost named it in your version.
See Boost Getting Started on Windows: library naming. the answer here: mingw-w64 cannot find -lboost_filesystem and the filenames you built in the D:\Development\Boost\stage\lib directory.

boost::asio installation via minGW64

I downloaded mingw64 compiler and boost 1.69.0.
I started bootstrap.bat from cmd with command "bootstrap gcc". then compilation I installed it with command "b2 toolset=gcc --prefix=C:/boost install".
After I looked for asio and saw, that there were only headers (in "include" dir). But there were no libs (.a) of asio.
Can someone tell me why those libs didn't compiled, and what I need to do to compile them?
For example library 'filesystem' successfuly compiled and works.

Boost.Python not the .lib

I think I have built it properly. I have other boost libraries working. I am getting the following error
Error: SNK1104 cannot open file 'boost_pythonPY_MAJOR_VERSIONPY_MINOR_VERSION-vc141-mt-x32-1_67.lib'.
I'm on windows using Visual Studios, with boost 1.67
boost-python is notoriously hard to install. Make sure you specify with-python when building from source. Something like this:
Download and configure boost
cd boost_1_55_0\tools\build\v2\engine
build.bat mingw
Add this to your path
C:\boost_1_55_0\tools\build\v2\engine\bin.ntx86
Build from source
bjam toolset=gcc --with-python link=shared
Add this to your path
C:\boost_1_55_0\stage\lib

Error building boost with MinGW

I tried to build boost library using the MinGW's GCC version that comes with CodeBLocks (gccc v5.1) and i have the bin folder in the PATH. When i run
boostrap.bat mingw
or
boostrap.bat gcc
i get
execnt.c: In function 'try_wait_callback':
execnt.c:833:5: warning: implicit declaration of function 'UnregisterWait' [-Wimplicit-function-declaration]
UnregisterWait( slot->wait_handle );
Reading a litte someone told me that my gcc version doesn't work to build boost so then i downloaded the last MinGW-w64 and copy its bin folder content into the MinGW's bin folder trying to "cheat"
if i do
gcc -v
i can see i have the version 7.3
Now it throws me this error:
gcc: error: CreateProcess: No such file or directory
You should use MinGW-w64, without the step "copy its bin folder content into the MinGW" !
You want to avoid using the pre-fork MinGW entirely. Download and install MinGW-w64 again and , if you want, add it to Code::Blocks.
Note that there are some sites providing MinGW-w64 and Boost bundles.
I had the same problem with MinGW provided with Code::Block. So I have to add to recomendations important details.
To build Boost.build tool:
After installation of minGW-w64 in NEW directory you need to delete entry of old MinGW\bin directory from PATH environment variable and add new entry with something like "C:\MinGW-w64\bin" entry.
By some reason starting commands in command line under user or administrator didn't work as supposed in Boost documentation, but if start terminal from shortcut provided by MinGW-w64 - commands of Boost can finish building. (Command "bootstrap.bat gcc")
Then Boost documentation recomends "b2 install --prefix=PREFIX" but I had to add parameter like "b2 install --prefix=PREFIX toolset=gcc" also in terminal started from MinGW-w64 shortcut.
Since I wanted to use MinGW32 of Code::Blocks in my projects (for other compatibility reasons), again I had to skip MinGW-w64 from availability (I had just renamed dir of MinGW-w64, you can delete entry from PATH) and to restore MinGW32 entry in PATH variable. Also I added Boost build tool "bin" dir into PATH.
So I had got Boost.Build tool ready to use (builded by MinGW-w64 compiler)
To build Boost libraries' binaries:
Then I started terminal under administrator, changed dir to boost root directory and then use the last command like "b2 --build-dir=build-directory toolset=gcc --build-type=complete stage" (where build-directory is of your choice)
And at last I'd got the result:
...failed updating 1334 targets...
...skipped 732 targets...
...updated 2873 targets...
Where I could find necessary for me files of Boost filesystem like
libboost_filesystem-mgw51-mt-x32-1_67.dll
libboost_filesystem-mgw51-mt-s-x32-1_67.a
libboost_filesystem-mgw51-mt-x32-1_67.a
etc.
I didn't test them yet, but this can help to others to build Boost.

Boost on windows with codeblocks - error: undefined reference to boost

Tons of these errors are popping up whenever I try to use boost in windows with codeblocks. On linux it works fine.
Even though I did add the boost .lib files and the include path to the GCC compiler in codeblocks.
I first compiled using bootstrap.bat + b2.exe but apperently that's wrong. A user in another forum said he fixed it but when I try his method I get:
So to clarify; what I did was:
. Add "C:\Program Files (x86)\CodeBlocks\MinGW\bin" to PATH
. Run bootstrap.bat which makes bjam.exe
. Run cmd.exe, cd to boost folder, enter bjam --build-dir=C:\boost --build-type=complete gcc stage
But then I get that error.
Why does compiling/using C++ libraries on windows always net these kind of errors that take hours to solve, while on linux it's nearly always flawless -.-
Who knows how to fix this one?
The technique that I use is as follows:
Set up the PATH environmental variable to include the bin directory of your GCC installation.
Extract boost somewhere.
Open a comand prompt and cd into the root of boost (the folder named boost_x_xx_x which has boost, doc, libs etc... subdirectories).
To compile boost, run:
bootstrap.bat
b2 toolset=gcc variant=release link=static threading=multi install
This will install boost to C:\Boost. If you want to install it elsewhere use the --build-dir= option when running b2.