How to compile OF from the command line so you can break up with xcode and use atom or sublime


#1

Hey folks -

Anyone else here want to take a baseball bat to the xcode IDE on a regular basis and wish they could use Atom for code development in OF?

If so, here’s a handy guide. It’s super dead simple.

  1. Go install atom if you haven’t now. This should also work for sublime, or even VIM.

  2. Add OF to your system’s path. To do this you need to find a hidden file. Open up terminal and use this unix command to do it. Steps 3-5 will walk you through it.

  • Open terminal and simply cd and press enter
  • type open .bash_profile (or open this file in your editor of choice. If you have atom installed you can use atom .bash_profile)
  • add this line at the bottom of the file, then save and quit your text editor export OF_ROOT=~/Documents/of_v0.9.8_osx_release
    (If you find this past this release, just update this to be whatever version of of you have downloaded, such as 9.9)

Now generate your OF project using the project generator. Go to atom or sublime and edit away. When you’re done, you’ll pop over to the terminal and change directory into your project’s root folder.

If you’re a total new soul cd is the Unix command to change directory. For example, cd ~/Documents would take you to your Documents folder. The ~ represents your user root directory. This should have your Desktop, Photos and Documents in it.

After you’ve changed directory into your project folder, all you have to do is type make on the command line. Yes, that’s it. They’ve now included make files with OF. Nice work folks. It will do all the heavy lifting for the compilation. The unix command make is a command that uses this utility called make to compile your applications. It’s really robust and cool and you can learn more about it here:
http://www.tutorialspoint.com/unix_commands/make.htm

It ships with your mac. You shouldn’t need to install it.

Read how to launch your app from here - it’s dead simple and make will explain it when it’s done building for you. Just read what it prints out about it in terminal.

Cheers! :smiley:
Phoenix


Sublime + make: where does cout go / where is console.log
Run openframeworks with Atom. Did anyone manage to use Atom as openframeworks IDE?
#3

you can also use atom’s build-make plugin to directly build and run from inside atom without having to go back and forth from a console and the atom linter plugin is also a nice one to have installed so it marks errors inlined in the code while compiling.


#4

SO GOOD! Has anyone set up an OF autocomplete yet?


#5

there’s the auto complete clang plugin: https://atom.io/packages/autocomplete-clang, it requires some file per project which telss the plugin where to look for headers… it’s easy to make the makefiles emit such a file but last time i tried it it was too slow for OF, OF includes so many headers that also makes available to users right away that it makes most auto complete systems really slow.

it seems that the plugin now supports precompiled headers which might make things faster but not sure how easy it would be to generate them, in any case it surely needs some modification on the makefiles


#6

Couple other quick tips to add:

  • make Debug will generate a binary with debugger hints included so you can load it up in gdb or similar (using gdb with OF is probably a topic all on its own).
  • make run will run the binary after it’s been compiled [I would expect it to automatically compile if necessary, but at least on linux it doesn’t see to do that. I’m going to report it as a bug. In the meantime, `make && make run` should work as a general “compile and run” command]
  • make clean should clean everything up, deleting the binary and any intermediate files (.so's and such)

#7

oh and there’s also atom-gdb which allows to debug the binaries and gives the traditional tools for debugging on any IDE


#8

I’m toying with Visual Studio Code (similar to atom), I was able to setup ofApps and build from the editor. Intellisense and debugging are working too in osx.

I didn’t use make though, I’m calling xcodebuild which is probably overkill… Are makefiles generated for all apps by default? Or do you need to target linux in PG?

My idea was to just wrap xcodebuild, msbuild or make; depending on which platform you’re developing on. This way you can have the same editor in all OSs.

The make route wouldn’t work out of the box for Windows… I do have a fork of the PG for vsc support; but there’s nothing working yet

I’m not sure if this would be a welcome addition to mainstream OF-PG


#9

Ah! I’m so close but I can’t make it work yet! I have the build-make plugin and Atom is compiling a project, but not running it. The make plugin only sees the default target. How do I get it to actually run the project?


#10

I use AppCode for Xcode projects, instead of Xcode itself. Personally I find it a much better IDE and has excellent refactoring tools. It is a nice environment for developing oF apps on macOS.


#11

Oh! Yay for using Editors to code! :slight_smile: did anyone get Auto Complete to work under Sublime Text 3? It’s my editor of choice since almost 6 years and I’d just love to not have to switch to Atom… although I know it’s great :slight_smile: any help greatly appreciated!


#12

On Mac and Linux I’ve been using make since 0.9.4 as far as I can remember.

On Windows it’s also possible to use make as long as you have msys2 installed like described in this page
http://openframeworks.cc/setup/msys2/

No need to modify your bash profile


#13

Hi Arturo! Hey can I get a guide to doing this? I can see the make package is installed - do I need a terminal or something to call it or is it hiding in the menu somewhere?


#14

i think F9 builds. I haven’t used the make build package but with other languages you also get the possible targets in the lower left corner where you can select which target to build

also usually in the package settigns there’s instructions on how to use it or a link to the web for that package


#15

Thanks man - they are scarce in that package but it’s most likely I am missing a readme. I’ll dig about.


#16

Thanks for sharing this. I did a little follow up detailing how I can to trigger the Makefile from Vim, taking into account the parent directory: http://brendandawes.com/blog/vim-of