boost似乎没有正确导入

时间:2019-06-01 19:12:43

标签: c++ boost

boost未导入或函数未加载。这是我不断得到的错误:

Undefined symbols for architecture x86_64:
  "boost::filesystem::detail::current_path(boost::system::error_code*)", referenced from:
      boost::filesystem::current_path() in testfile-7ee4bc.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

这是我的制作文件:

#!/bin/bash

brew install gcc
brew install zeromq
brew install pkgconfig
brew install sdl2
brew install sdl2_image
brew install sdl2_ttf
brew install boost
DIR="$(cd "$(dirname "$0")" && pwd)"
Run1="$DIR/test.dylib"
Run2=$Run1
Run3="$DIR/testfile.cpp"
Run4=$Run3
g++ $(pkg-config --cflags sdl2 sdl2_image sdl2_ttf) -I /Library/Frameworks -I /usr/local/Cellar/boost/ "$Run4" -o "$Run2" $(pkg-config --libs sdl2 sdl2_image sdl2_ttf)
"$Run2"
exit 0

这是我的代码:

#include <iostream>
#include <stdio.h>
#include <thread>
#include <unistd.h>
#include <fstream>
#include <sys/stat.h>
#include <sys/types.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/progress.hpp>


int main(int argc, const char * argv[]) {
    SDL_Surface* image = IMG_Load((boost::filesystem::current_path().string() + "/background").c_str());

    rest of my code...

    return 0;
}

有人可以告诉我为什么吗?预先感谢。

1 个答案:

答案 0 :(得分:0)

(硝烯酸已在评论中答复。)

您尚未链接到Boost库。这意味着,在提供包含路径时,功能签名是可见的,但功能定义不可见。