Mac和boost库上的Qt Creator
Qt Creator on Mac and boost libraries
我正在Mac上运行QtCreator。。。我想开始研究boost库。。。因此,我使用安装了boost库
brew install boost
之后,我创建了一个小的boost hallo世界程序,并在.pro文件中进行了如下的更改
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
unix:INCLUDEPATH += "/usr/local/Cellar/boost/1.55.0_1/include/"
unix:LIBPATH += "-L/usr/local/Cellar/boost/1.55.0_1/lib/"
SOURCES += main.cpp
LIBS +=
-lboost_date_time
-lboost_filesystem
-lboost_program_options
-lboost_regex
-lboost_signals
-lboost_system
我仍然无法构建。。。原因可能是什么?请告诉我可能的错误是什么。。。
错误是
library not found for -lboost_data_time
linker command failed with exit code 1 (use -v to see invocation)
这有点偏离了Uflex的回答,因为他错过了一些东西。所以保持相同的代码:
//make sure that there is a boost folder in your boost include directory
#include <boost/chrono.hpp>
#include <cmath>
int main()
{
auto start = boost::chrono::system_clock::now();
for ( long i = 0; i < 10000000; ++i )
std::sqrt( 123.456L ); // burn some time
auto sec = boost::chrono::system_clock::now() - start;
std::cout << "took " << sec.count() << " seconds" << std::endl;
return 0;
}
但让我们改变一下他的职业生涯:
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.cpp
macx {
QMAKE_CXXFLAGS += -std=c++11
_BOOST_PATH = /usr/local/Cellar/boost/1.55.0_1
INCLUDEPATH += "$${_BOOST_PATH}/include/"
LIBS += -L$${_BOOST_PATH}/lib
## Use only one of these:
LIBS += -lboost_chrono-mt -lboost_system # using dynamic lib (not sure if you need that "-mt" at the end or not)
#LIBS += $${_BOOST_PATH}/lib/libboost_chrono-mt.a # using static lib
}
我唯一添加的是助推系统(-lbostrongystem)这应该解决了他的原始版本导致未定义符号的问题,并允许您添加其他库。
比如-lbost_date_time,对我来说,它与brew安装非常配合。
当然,我的路径实际上是:/usr/local/Cellar/boost/1.55.0_2
Boost库是模块化的,您只需要链接到您正在使用的库。有些库只是头,所以您不需要做任何事情,在您的路径中可以访问boost就足够了。
你可以尝试编译这个:
//make sure that there is a boost folder in your boost include directory
#include <boost/chrono.hpp>
#include <cmath>
int main()
{
auto start = boost::chrono::system_clock::now();
for ( long i = 0; i < 10000000; ++i )
std::sqrt( 123.456L ); // burn some time
auto sec = boost::chrono::system_clock::now() - start;
std::cout << "took " << sec.count() << " seconds" << std::endl;
return 0;
}
在.pro文件中:
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.cpp
macx {
QMAKE_CXXFLAGS += -std=c++11
_BOOST_PATH = /usr/local/Cellar/boost/1.55.0_1
INCLUDEPATH += "$${_BOOST_PATH}/include/"
LIBS += -L$${_BOOST_PATH}/lib
## Use only one of these:
LIBS += -lboost_chrono-mt # using dynamic lib (not sure if you need that "-mt" at the end or not)
#LIBS += $${_BOOST_PATH}/lib/libboost_chrono-mt.a # using static lib
}
相关文章:
- 无法使用Qt Creator在Windows中构建yaml-cpp
- 在Qt Creator中,如何在连接到正在运行的进程后查看控制台输出
- 如何在QT Creator上将QWidget声明为继承类的对象
- 在 QTextEdit 中使用指针或在 Qt-Creator 上使用 connect()
- Qt creator 4.11,在应用程序输出面板中创建一个链接
- 使用 Cmake 在 Qt Creator 中显示头文件
- 如何在 CMakeLists.txt Qt Creator 中包含头文件?
- 为什么Qt Creator的应用程序输出不能从spdlog记录器打印
- 使用Qt Creator在调试模式下编译一段代码
- Qt Creator 在执行步骤 "make" 时出现编译错误,-fno-stack-limit
- Qt creator语言 - fno-elide-constructors 不起作用
- 如何将Valgrind与Qt Creator一起使用来调试远程应用程序?
- QT Creator将SQLite复制为空数据库
- 如何在QT Creator中手动运行CMake和Run
- 在Qt Creator中应用代码更改的快捷方式是什么?
- Qt Creator在linux mint 64位中找不到CMAKE_CXX_COMPILER编译器
- 为什么 qt-creator 在我用小写字母命名小部件类后无法构建?
- Qt Creator项目打破:"找不到建筑x86_64符号"
- 您将如何在现有的QT Creator GUI项目中实现ROS发布者和订阅者?
- 将OpenBLAS与Qt Creator项目链接