[英]Sublime Text 2 Issue with Boost
我有一个构建系统配置为使用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 ++的问题吗? 还是有其他问题。
在Sublime Text 2构建系统中,该命令的每个参数应该是数组cmd
的单个项。 如果在一个项目中指定三个参数,则它们将仅作为一个参数传递。 以下面的设置为例,python脚本只接收一个参数,其值为"arg1 arg2 arg3"
。
{
"cmd" : ["python", "${file_path}/${file_base_name}.py", "arg1 arg2 arg3"],
"selector" : "source.py",
"working_dir": "${file_path}"
}
所以,在你的构建系统中, "-I/usr/local/include -L/usr/local/lib -lboost_system"
将被视为一个参数,也就是说, g++
不知道你已经指定了两个链接选项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.