Qt Creator的Mac和Boost库 [英] Qt Creator on Mac and boost libraries

查看:208
本文介绍了Qt Creator的Mac和Boost库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Mac上运行QtCreator ...我要开始Boost库工作......所以,我安装使用Boost库

 酿造安装提振

之后,我创建了一个小型升压喂World程序,并按如下取得了.pro文件的修改

 模板=应用
CONFIG + =控制台
CONFIG - = app_bundle
CONFIG - = QTUNIX:INCLUDEPATH + =/usr/local/Cellar/boost/1.55​​.0_1/include/
UNIX:LIBPATH + =-L在/ usr /本地/库/升压/ 1.55.0_1 / lib中/SOURCES + = main.cpp中LIBS + = \\
-lboost_date_time \\
-lboost_filesystem \\
-lboost_program_options \\
-lboost_regex ​​\\
-lboost_signals \\
-lboost_system

我仍然无法建立......这可能是什么原因?请建议我可能是什么可能的错误...

的误差

没有找到-lboost_data_time

 
连接器命令,退出code 1(使用-v看看调用)失败


解决方案

这走的是一条从一点UFLEX的回答,因为他错过了一些东西。
因此,保持在同一code:

  //确保有一个在您升压升压文件夹包含目录
#包括LT&;升压/ chrono.hpp>
#包括LT&;&CMATH GT;诠释的main()
{
自动启动=提振::时辰:: SYSTEM_CLOCK ::现在();    为(长I = 0; I<千万++ I)
        的std ::开方(123.456L); //燃烧一段时间    汽车秒=提振::时辰:: SYSTEM_CLOCK ::现在() - 启动;
    性病::法院LT&;< 花<< sec.count()&所述;&下; 秒<<的std :: ENDL;    返回0;
}

但是让我们改变了他的.pro了一下:

 模板=应用
CONFIG + =控制台
CONFIG - = app_bundle
CONFIG - = QTSOURCES + = main.cpp中MACX {
    QMAKE_CXXFLAGS + = -std = C ++ 11    _BOOST_PATH = /usr/local/Cellar/boost/1.55​​.0_1
    INCLUDEPATH + =$$ {_ BOOST_PATH} /包括/
    LIBS + = -L $$ {_ BOOST_PATH} / lib目录
    ##只能使用其中的一个:
    使用动态LIB(不知道你是否需要一个-mt末或没有)LIBS + = -lboost_chrono-MT -lboost_system#
    #LIBS + = $$ {_ BOOST_PATH}使用静态库/lib/libboost_chrono-mt.a#
}

我已经加入到这一唯一的办法就是增压系统(-lboost_system)
这应该解决这一问题与他的原始版本导致未定义的符号,并允许您添加其他库。

如-lboost_date_time,这对我的酿造工作完全安装。

当然,我的道路居然是:/usr/local/Cellar/boost/1.55​​.0_2

I am running QtCreator on Mac... I want to start working on boost libraries ... So, I installed boost libraries using

brew install boost

After that I created a small boost hallo world program and made the changes in .pro file as follows

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

I am still unable to build... What could be the reason? Please suggest me what could be the possible mistake...

The errors are

library not found for -lboost_data_time
linker command failed with exit code 1 (use -v to see invocation)

解决方案

This is taking a bit from Uflex's answer, as he missed something. So keep the same code:

//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;
}

But lets change his .pro a bit:

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
}

The only thing I have added to this was the boost system( -lboost_system ) That should solve the issue with his original version causing the undefined symbols, and allow you to add your other libraries.

Such as -lboost_date_time, which for me worked perfectly with the brew install.

Granted, my path is actually: /usr/local/Cellar/boost/1.55.0_2

这篇关于Qt Creator的Mac和Boost库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆