This is TERAI, a guest researcher.
My work at the restaurant event uses C++ based development environment called openFrameworks. OpenFrameworks is suited to installation development, and it is often seen to be used at the events in commercial facilities and live stage events.

This is the first time to use OpenFrameworks with a serious stance but I did not think it was difficult to approach so much because I was originally a Flash developer. However, at the beginning of using OpenFrameworks, I did not have any idea of the contents of error shown at build errors and I often encountered build errors regardless of not adding a few changes when I downloaded samples from the Internet. The development environment is very snazzy and fun, but people might fail at the beginning and give it up.

In this entry, I will list the errors and how to handle the errors seen in OpenFrameworks, and I hope these points will help people at a loss with the same errors.

This will be done with a MacOS10.9, Xcode5 environment.

Table of Contents (* mark tells that it is very important.)

  • 1. Be careful of the places to put samples
  • 2*. Do Product > Clean
  • 3*. Change Base SDK to MacOS10.8
  • 4. Ignore yellow warnings?
  • 5. Specify Release Build
  • 6. Cases where several projects are open
  • 7. Make sure that needed add-ons are ready
  • 8*. Are the related add-ons ready?
  • 9*. Cases where there is a Libs directory in the file of add-ons
  • 10. Cases where samples are included in the add-ons read in on Xcode
  • 11. Switch to Libstdc++
  • 12. Re-examine Header Search Paths

1. Be careful of the places to put samples

In OpenFrameworks, it is ruled to put project files in the following places.

  • (OpenFrameworks directory)/apps/myApps/(project)
  • (OpenFrameworks directory)/examples/(3d,event,gl,gui…)/(sample project)

As you can see the reason by opening the project files in project and sample projects (in the case of xcode, extension .Xcodeproj) and checking the build setting settings, the library path specification from the project specifies 3 trees up from the project files.

../../../libs/openFrameworks/**

When you follow this rule, you can build a project in the proper way. For example, you can make files at

  • (OpenFrameworks directory)/apps/myOneNewProject/ (project).

terai_kinect_0310image1
'ofMain.h' file not found

As the illustration above shows, when you are warned not to find (not found) even an OfMain.h file which is surely existing in OpenFrameworks, it is possible not to be able to keep this hierarchical structure, so check the place to put project files.

2*. Do Product > Clean

When errors occurred although the build was successful until a while ago but you did not have idea of the errors, start cleaning up projects.

terai_kinect_0310image2

Cleaning itself is easy but unfortunately also easy to forget to do. There are some cases where projects got recovered only by making cleanups although codes were re-examined over and over again, but they did not get recovered.

3*. Change Base SDK to MacOS10.8

This is a kind of troublesome for those who start using OpenFrameworks recently.

You can see some errors which are hard to understand defined “'tr1/memory' file not found

terai_kinect_0310image3

When you see these errors at the environment of MacOS10.9, Xcode5 and later, by clicking the first line’s project of the file list at the left of Xcode window, by clicking the Build Setting tab in the center window, and then by lowering Base SDK which is shown in the settings from “Latest OS X (OS X 10.9)” to “Mac OS 10.8”, the errors can be cleared.

terai_kinect_0310image4

When Tr1/memory errors comes out with the sample downloaded from the Internet and when the sample is released before MacOS10.9, Xcode5 was released, you should have doubt of being this cause.

4. Ignore yellow warnings?

terai_kinect_0310image5

When you see an array of yellow warning icons shown in the file list, which is bad for the heart, do not mind because you can still build projects with yellow warning icons unlike red warning icons. Most of the contents of warnings tell that the API used in implementation inside of the used add-ons are Deprecations, that is to say, old, and it’s better to replace it for a new API.

It’s good to rewrite the inside of the add-ons made by an engineer with good skills, however, you can use it as it is during the beginning if it works for now.

5. Specify Release Build

Doubt if this is specified when the build was successful (Build Succeeded) but applications are not shown.

terai_kinect_0310image6

Debug build is, as its name suggests, for debugging, and it can use break points. A Release build cannot do such delicate debugging work, but this is for the production environment, release build can run applications in a state of higher performance (= original operating behavior). There is a chance that it does not work with Build but it does work with Release, so check first if it works with a Release build.

6. Cases where several projects are open

terai_kinect_0310image7

When you see the red warnings as below on the upper file list,

Workspace Integrity
Couldn't load openFrameworksLib.xcodeproj because it is already opened from another project or workspace

it is possible to open another .Xcodeproj file. If you close the file, the warnings will also be cleared. These are the red warning icons, but you can still build the project. So, ignore these warnings if you want to keep several projects open.

That’s all for an entry level, so I think this is not so difficult. For me, I had been unable to make a quick decision since I started using extension and library features in OpenFrameworks called add-ons. It was often the case with this when a sample was downloaded from the Internet but there was the following build errors.

xxx.h file not found

7. Make sure that needed add-ons are ready

terai_kinect_0310image8

Basically add-ons should be in the following directory.

  • (OpenFrameworks directory)/addons

In this directory, there are originally some add-ons from the beginning.

The file name of the add-ons (Added add-ons) downloaded from the Internet are most likely written as “The Name of Add-ons -master”. In this case, put the add-ons to Addons directory with erasing the text “-master”. In most cases, a full set of sample projects are bundled as an examples directory in the added add-ons, and you can test it by placing this sample projects to the designated location which is described as the two trees below of the apps and examples directory.

If you find the contents of Addons on the file list in the left side of the screen when opening a project red, it means the file does not exist.

terai_kinect_0310image9

  • This is because there is no add-ons in the Addons directory on Finder.
  • ・Because the name of the directory in the Addons on Finder is different, so it cannot be found; is it still “xxx-master”?

Check those again. The top priority is to make the add-on related files exist (the color of the text becomes black on the list).

Moreover, if needed add-ons are not loaded on the file list in the project,

terai_kinect_0310image10

by right clicking on the Addons in the file list, load the designated add-ons with “add files to ”(the name of the project)”.

terai_kinect_0310image11

8*. Are the related add-ons ready?

For example, when you want to use particle fluid add-ons called ofxMSAFluid, there needs other related add-ons. The add-on page writes that MSACore is needed as Dependencies, so download the add-on and make it work on the project.

To make MSAFruid work for real, other OfxSimpleGuiToo, OfxTuio, OfxMSAInteractiveObject were needed but if something is missing, you will see warnings in the build, so search add-ons every time on the Internet and download and install it.

Tips: If you install a plugin for Xcode5 called OFPlugin, it automatically collects the missing add-ons and sets the settings. After you yield insight about add-ons structure to an extent, you can acquire the convenience by watching the movie from the URL below.

9*. Cases where there is a libs directory in the file of add-ons

When there is a libs directory in addition to Src in the add-ons which you want to use, it sometimes becomes build errors that a class in the libs cannot be found.

terai_kinect_0310image12

It might be good to re-load the add-ons when you see the red warnings in the file list, which means it does not exist. Delete all the targeted add-ons once (by right clicking on the Xcode file list > Delete, and Delete Reference only. Do not delete the file itself.), right click again on the Addons as described before, and by “add files to ”, check if the name of the file becomes black.

There is another case that reference errors such as “.h file not found” can be seen even though the text color is black (=exist) in the libs on the file list. This is because there are many cases when it fails to load the header file below the libs directory although Src can be loaded right under Addons. By specifying the directory below the libs to the Header Search Paths in the Build Setting, you can, in the literature, search paths to the header of the directory.

terai_kinect_0310image13

As a note of caution, you also need to specify the directory as a header path when there is another directory structure in the libs directory. OfxOpenCV and OfxOsc add-ons fall under the category of this.

terai_kinect_0310image14

Tips: Search the point of differences compared with moving project settings

By using ProjectGenerator in ProjectGenerator_osx, you can create a new project that needed add-ons are embedded.

terai_kinect_0310image15

By clicking Addon on the generator screen, you will see the screen like the above. There are add-ons which included as standard on the left side, and on the right side, there are add-ons which I added. By checking the needed add-ons to the project which you are going to create, and by “GENERATE PROJECT”, you can create a new project which completes all the reference configuration to the add-ons described here so far.

You might want to make developments on the base of the project which the generator created from the beginning, but for me, I often correct sample files which are used a certain add-on (feature) , create my own project, and add needed add-ons every time. So, when I was not sure about the header path settings of the mid-flow add-ons,I try to compare my project with the Build Setting of the project which the generator created.

10. Cases where samples are included in the add-ons read in on Xcode

I encountered an error such as

ld: 6 duplicate symbols for architecture i386

terai_kinect_0310image16

As the image shows above, when add-ons are loaded, sample files and etc. can be also loaded together. By deleting the unnecessary files (deleting only the references), a build can be successful.
So, please keep it in mind. As in this article, the same errors can occur when the same add-ons are loaded redundantly.

I also encountered the following errors although this case is rare.

11. Switch to Libstdc++

When I added add-ons by hand after creating a project,‘tr1/memory’ file not found errors came out. So, when I changed the BaseSDK to MacOS10.8 but the errors were still not cleared, I could avoid the errors by switching the part of C++ Standard Library to libstdc++ as in this article.

terai_kinect_0310image17

12. Re-examine Header Search Paths

I was upset when a build was successful but the build errors came out at a later date. I do not know if the cause came from a bug in Mac or Xcode but the header path specified character string in Build Settings was automatically changed, which caused build errors.

terai_kinect_0310image18

At the beginning, by specifying “../../../addons/~ “ I could build a project, but every time I opened the project at a later date, a backslash was added automatically as you see in the illustration above and $(SRCROOT) path, which was not needed, but was added. So, I delated all at once and specified them again.

Finally

By taking care of these points, the samples on the internet could work almost perfectly. As I have only known OpenFrameworks for a short time, if there is a mistake in this article or other reminders, please kindly notify me to my twitter account (@trick7).