boost::asio installation via minGW64 - c++

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.

Related

Compiling assimp from source does not generate libassimp file

So I compiled the assimp library with cmake using the x64_x86 developer command prompt that was said to be required. (When I tried using the regular console cmake did an error that it could not find 'the cl compiler').
After some time it finally compiled without errors with the following commands:
cmake CMakeLists.txt -DASSIMP_BUILD_ASSIMP_TOOLS=OFF
cmake --build .
It built 3 files:
C static library zlibstaticd.lib
CXX shared library ..\bin\assimp-vc142-mtd.dll
CXX executable ..\bin\unit.exe
But there was no libassimp.a or libassimp.so that I can link against in MinGW. I tried just linking with te dll in my own project with:
-L\"{assimp root directory}/bin\"
-lassimp-vc142-mtd
and it failed with "undefined reference to `Assimp::Importer::Importer()"
How can i get the lib file to link against?
I installed MSYS2, replaced my existing MinGW installation with MSYS, libraries installed flawlessly and everything works now.
My mistake was that:
I was compiling the library with VS C++ toolkit while I'm compiling my project with MInGW make and g++
even after I compiled assimp the correct way, version 5.2.4 couldn't find some header, 5.2.3 and some older versions compiled successfully, but failed some unit tests (God knows why). Seemed to always hit some unresolved issue on GitHub. Never again compiling libraries from source.

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.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

CLion Boost library

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.

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.