(C++) 'Hello Boost' using Qt Creator under Lubuntu
February 24, 2017 · View on GitHub
(C++) 
'Hello Boost' using Qt Creator under Lubuntu
Hello Boost is an extension of Hello World. Like Hello World, Hello Boost is a simple console application. Hello Boost, however, also requires the Boost library and to link against the Boost.Regex library.
Next to the Qt Creator project, there is included:
- Makefile: the makefile created by qmake
- test.sh: a bash script that tests if Boost installed correctly
Technical facts
Operating system(s) or programming environment(s)
Lubuntu 13.04 (raring)
Qt Creator 2.7.0
- G++ 4.7.3
Libraries used:
Qt project file: CppHelloBoostQtCreatorLubuntu.pro
QT += core QT -= gui CONFIG += console CONFIG -= app_bundle TEMPLATE = app SOURCES += main.cpp LIBS += \ -lboost_date_time \ -lboost_filesystem \ -lboost_program_options \ -lboost_regex \ -lboost_signals \ -lboost_system
main.cpp
#include <iostream> #include <boost/regex.hpp> int main() { std::string s = "Hello World"; s = boost::regex_replace(s,boost::regex("World"),std::string("Boost")); std::cout << s << '\n'; }
test.sh
#!/bin/bash target="CppHelloBoostQtCreatorLubuntu" if [ -e Makefile ] then cp Makefile Makefile.prev echo "Makefile copied to Makefile.prev" rm Makefile echo "Removed Makefile" fi qmake $target.pro if [ -e Makefile ] then echo "Makefile created successfully" else echo "FAIL: qmake CppHelloBoostQtCreatorLubuntu.pro" exit fi make if [ -e $target ] then echo "SUCCES" else echo "FAIL" fi #Cleaning up rm *.o rm Makefile rm $target