Sublime Forum

C++ Mac OSX issues

#1

So, I’ve already rummaged through the forums to see what I could do to fix the problem, but nothing seems to work. Basically, I’ve created a single “test” c++ source file ( with extension .cpp), and I’ve made the makefile for it in the same directory. It all seems to work right when I use the make commands solely through the OS terminal to compile. However, when I try to build the program through Sublime Text 2, I get the following message:

make: *** No targets specified and no makefile found. Stop.

I don’t know what to do. Can someone please help?

I’ve typed " which make" in the terminal to see where make is situated, and it appears to be in the appropriate directory, that is, /usr/bin/make . I’ve also tried messing with path environment variables to see if this issue could be resolved, but I don’t even think that was necessary to begin with.

I really want this to work out for me before I decide to buy the program. Any help would be dearly appreciated, thank you.

0 Likes

#2

The problem appears to be that make isn’t being launched in the right working directory. The logic used to determine the working directory is the first matching one of:

  1. The directory of the current project, if any
  2. The directory of the first open folder, if any
  3. The directory of the current file, if any

Probably the first step to checking on what’s going on would be to close the current project, remove any open folders, and then try again with just the file open (and assuming the Makefile is in the same dir as the .cpp file in question)

0 Likes

#3

I’m sorry, but I’m a little confused. First of all, I don’t have any project open. Secondly, I don’t know what you mean by removing open folders. Lastly, all I do with ST 2 is click file > open file and select my .cpp source file, then click tools > build. I have my source and makefile located as such:

~/Documents/Listing/main.cpp
~/Documents/Listing/tax.make

The code for tax.make is as such:

tax.make

tax: main.cpp
g++ -o tax main.cpp

end of make file

It works fine through the terminal.

Perhaps I’m just slow and didn’t quite understand what you were trying to say. Could you please rephrase if I misunderstood?

0 Likes

#4

Generally your makefile needs to be named ‘Makefile’ for make to pick it up.

When you run it from the terminal, are you just typing ‘make’?

0 Likes

#5

I renamed it to Makefile.make, and in the terminal, while in the source’s directory I would normally type

make -f Makefile.make

It still doesn’t work on ST 2 after renaming it.

I’m not going to lie, but this is my first time learning how to do makefiles. I’ve managed to do them correctly thus far because the terminal builds the programs I’ve tested so far.

0 Likes

#6

Just ‘Makefile’, with no extension - you’ll then be able to run make by typing ‘make’, with no need for -f. Once the file is called Makefile, then the make build system should be working from within Sublime Text 2.

0 Likes

#7

Bravo! That did the trick, thanks so much. Now I can buy this program with confidence :laughing:

Just bought the program, thank you!

0 Likes

#8

Is there a way to have the program run automatically once the source has been compiled? Is there a shortcut key for this?

0 Likes

#9

There’s not, but there is likely to be in the future.

A workaround for the moment is to just add running the program as another step in the Makefile.

0 Likes

#10

Ok thanks, I’ll have to look into the make documentation to see how to do that. Any pointers ? :smile:

0 Likes

#11

Something along the lines of:

tax: main.cpp
	g++ -o tax main.cpp
	./tax
0 Likes