我在GNU Scientific Libraries的支持下用C ++编写代码。我已正确安装它们,为了从终端编译它们,我只需编写以下内容:
g++ $(gsl-config --cflags) filename.cpp $(gsl-config --libs)
现在,我是TextMate用户,我想修改C包中的标准Run命令,以便使用正确的gsl选项编译我的cpp文件。问题是TextMate.Executor函数,我完全忽略了,我没有找到任何详尽的参考。
以下是我的尝试:
#!/usr/bin/env ruby
require ENV["TM_SUPPORT_PATH"] + "/lib/tm/executor"
require ENV["TM_SUPPORT_PATH"] + "/lib/tm/save_current_document"
mode = ENV["TM_SCOPE"].slice(/.*?\bsource\.((?:obj)?c(\+\+)?)/, 1)
case mode
when "c"
g = "GCC"
env = "C"
ext = "c"
lang = "c"
when "c++"
g = "GXX"
env = "CXX"
ext = "cc"
lang = "c++"
when "objc"
g = "GCC"
env = "OBJC"
ext = "m"
lang = "objective-c"
when "objc++"
g = "GXX"
env = "OBJCXX"
ext = "mm"
lang = "objective-c++"
end
TextMate.save_current_document(ext)
TextMate::Executor.make_project_master_current_document
flags = ENV["TM_#{env}_FLAGS"] || "-Wall -include stdio.h $(gsl-config --cflags) "
args = [ENV["TM_#{g}"] || g.downcase.gsub("x", "+"), flags + " -x #{lang}", ENV["TM_FILEPATH"]+" $(gsl-config --libs)"]
TextMate::Executor.run(args, :version_args => ["--version"])
答案 0 :(得分:1)
这并不能完全回答你的问题,但可能更适合做一件事(而且,可以说更值得推荐的事情呢?)
为您的代码创建一个Makefile。这是我的精简版:
CC = g++
CFLAGS = -g -Wall -L/opt/local/lib -I/opt/local/include -I$(SRC_DIR)
GSLFLAGS = -lgsl -lgslcblas -lm -I/opt/local/include/gsl
EXEC = mRVM
SRC_DIR = ./src
OUTPUT_DIR = ./bin
all: $(EXEC)
clean:
-rm $(OUTPUT_DIR)/test
-rm $(OUTPUT_DIR)/*.exe
$(EXEC):
$(CC) $(CFLAGS) $(GSLFLAGS) -o $(OUTPUT_DIR)/$(EXEC) $(SRC_DIR)/main.cc
现在在您的“项目”中,导航到Makefile并按⌘ + M