Home Download Buy Blog Forum Support

C++ Mac OSX issues

C++ Mac OSX issues

Postby runnerofnight on Fri Mar 11, 2011 10:06 am

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.
runnerofnight
 
Posts: 7
Joined: Fri Mar 11, 2011 9:50 am

Re: C++ Mac OSX issues

Postby jps on Fri Mar 11, 2011 10:15 am

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)
jps
Site Admin
 
Posts: 3062
Joined: Wed Mar 19, 2008 12:33 pm

Re: C++ Mac OSX issues

Postby runnerofnight on Fri Mar 11, 2011 10:47 am

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?
runnerofnight
 
Posts: 7
Joined: Fri Mar 11, 2011 9:50 am

Re: C++ Mac OSX issues

Postby jps on Fri Mar 11, 2011 10:55 am

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'?
jps
Site Admin
 
Posts: 3062
Joined: Wed Mar 19, 2008 12:33 pm

Re: C++ Mac OSX issues

Postby runnerofnight on Fri Mar 11, 2011 11:08 am

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.
runnerofnight
 
Posts: 7
Joined: Fri Mar 11, 2011 9:50 am

Re: C++ Mac OSX issues

Postby jps on Fri Mar 11, 2011 11:13 am

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.
jps
Site Admin
 
Posts: 3062
Joined: Wed Mar 19, 2008 12:33 pm

Re: C++ Mac OSX issues

Postby runnerofnight on Fri Mar 11, 2011 11:22 am

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

Just bought the program, thank you!
runnerofnight
 
Posts: 7
Joined: Fri Mar 11, 2011 9:50 am

Re: C++ Mac OSX issues

Postby runnerofnight on Sat Mar 12, 2011 12:56 am

Is there a way to have the program run automatically once the source has been compiled? Is there a shortcut key for this?
runnerofnight
 
Posts: 7
Joined: Fri Mar 11, 2011 9:50 am

Re: C++ Mac OSX issues

Postby jps on Sat Mar 12, 2011 1:15 am

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.
jps
Site Admin
 
Posts: 3062
Joined: Wed Mar 19, 2008 12:33 pm

Re: C++ Mac OSX issues

Postby runnerofnight on Sat Mar 12, 2011 1:31 am

Ok thanks, I'll have to look into the make documentation to see how to do that. Any pointers ? :)
runnerofnight
 
Posts: 7
Joined: Fri Mar 11, 2011 9:50 am

Next

Return to Technical Support

Who is online

Users browsing this forum: Google [Bot], lefoy and 34 guests