我有一个构建系统配置为使用 boost 构建项目(v1.53,Mac OS X Mountain Lion)
{
"cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}", "-I/usr/local/include -L/usr/local/lib -lboost_system"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"variants":
[
{
"name": "Run",
"cmd": ["bash", "-c", "g++ '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
}
]
}
但是,当我尝试使用一个简单的程序对其进行测试时:
#include <iostream>
#include <boost/asio.hpp>
int main(){
std::cout << "Hello world! - boost" << std::endl;
return 0;
};
我收到以下错误(来自 sublime text 2 输出):
Undefined symbols for architecture x86_64:
"boost::system::system_category()", referenced from:
__static_initialization_and_destruction_0(int, int)in cct7f9yj.o
boost::asio::error::get_system_category() in cct7f9yj.o
"boost::system::generic_category()", referenced from:
__static_initialization_and_destruction_0(int, int)in cct7f9yj.o
ld: symbol(s) not found for architecture x86_64
collect2: [Finished in 1.1s with exit code 1]ld returned 1 exit status
控制台输出为:
Running g++ /Users/xxxx/Desktop/event_system/main.cpp -o /Users/xxxx/Desktop/event_system/main -I/usr/local/include -L/usr/local/lib -lboost_system
当我将相同的命令复制并粘贴到终端时,它可以正常工作。这只是 Sublime Text 2 无法正确使用 g++ 的问题吗?还是有其他问题。