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