Boost :: filesystem在OSX中返回工作目录

时间:2013-11-02 18:06:13

标签: c++ macos boost qt-creator boost-filesystem

我在代码中发现了一个错误,导致我无法将结果输出到终端。我让程序在linux中运行(输出目录);但是,当我在OSX上编译它时,终端在执行pProgram.parent_path().string();后退出报告。

我在OSX中缺少什么阻止Boost 1.54正常运行?我能做些什么让它正常执行?谢谢。

输入

#include <iostream>
#include <cstring>
#include <boost/filesystem.hpp>

int main()
{
  boost::filesystem::path pProgram( boost::filesystem::current_path() );

  std::cout << "\nhello, world - point A!\n";
  std::string workingDirectory = pProgram.parent_path().string()
  std::cout << "\nhello, world - point B!\n";

  std::cout << workingDirectory;

  return 0;
}

输出

hello, world - point A!
Press <RETURN> to close this window..

Pro qmake文件

cache()

TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt

SOURCES += main.cpp

macx {
INCLUDEPATH += /opt/local/lib
INCLUDEPATH += /opt/local/include

INCLUDEPATH += opt/local/include
DEPENDPATH  += opt/local/include

unix: LIBS += -L$$PWD/../../../../../opt/local/lib/ -lboost_filesystem-mt
unix: PRE_TARGETDEPS += $$PWD/../../../../../opt/local/lib/libboost_filesystem-mt.a
unix: LIBS += -L$$PWD/../../../../../opt/local/lib/ -lboost_system-mt
unix: PRE_TARGETDEPS += $$PWD/../../../../../opt/local/lib/libboost_system-mt.a
}

0 个答案:

没有答案