Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
676 views
in Technique[技术] by (71.8m points)

makefile - Sublime Text Build System that just "make"

I'm trying to build my project by simple executing make in the top directory. However, when I do, I get the following error:

[Errno 2] No such file or directory
[cmd:  [u'make']]
[dir:  /Users/jonathanong/Workspace/template]
[path: /usr/local/bin]
[Finished]

This is after setting the build configuration to Make.

I'm on Sublime Text 2.0.1, OS X 10.8.2. My Makefile consists of executing globally installed node.js binaries. What do I have to do?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This is because make is not in your PATH. If you can build in the terminal, use which make to figure out the path to make, and then add that to the path for build. You can edit the makefile build system to add your path.

Your new makefile rule should look like:

{
   "cmd": ["make"],
   "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
   "working_dir": "${project_path:${folder:${file_path}}}",
   "selector": "source.makefile",
   "path": "/usr/local/bin:/Applications/Xcode.app/Contents/Developer/usr/bin",
   "variants":
    [
      {
        "name": "Clean",
        "cmd": ["make", "clean"]
      },
      {
        "name": "Test",
        "cmd": ["make", "test"]
      }
    ]
}

This is basically the default make target, but I added to the PATH, and (of course) a test target. You may have to extend the PATH to find gcc, ifort, or whatever you are using to compile. Use : to separate directories on Linux and Mac, and ; on Windows. You can also change other environment variables, I had to set DYLD_LIBRARY_PATH and CPATH so that my libraries and include directories would be available.

It should be saved as Make (OSX).sublime-build in the User directory of your Sublime preferences. The (OSX) will ensure that this file is only used on Mac, so when you copy your preferences to a non-mac computer, you won't gunk up the path.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...