index
- Configure eclipse
- Issues encountered and solutions
- Appendix (source code)
- References
** Configure eclipse **
Assumes that you have a C++ version of eclipse and have created a basic C++ Cinder project. You can find the .h and .cpp files in the appendix below. The following outlines the settings you need to configure to compile.
Step 1.
- Open the project 'properties' window.
- Navigate to the C/C++ Build > 'Build Variables' option.
Add the following Variable.
CINDER_PATH /path/to/cinder_0.8.4_mac/
Step 2.
- Navigate to the C/C++ Build > Settings window.
- Under the Tools Tab select the 'MacOS X C++ Linker' option.
Here, in the 'command' input field you need to add after the g++ your command line options and OSX framework references
g++ -m32 -arch i386 -framework Cocoa -framework IOKit -framework Accelerate -framework AudioToolbox -framework AudioUnit -framework CoreAudio -framework CoreVideo -framework CoreServices -framework QTKit -framework OpenGL -framework QuickTime -framework AppKit -framework Cocoa -framework CoreData -framework Foundation
-m32 Tells the link to use 32 bit rather than 64 bit.
-arch i386 Ensures we link for the correct architecture.
-framework Reference the frameworks required to run Cinder (As i understand it currently)
NOTE: Depending on your mac version you might find -framework Carbon in stead of -framework Cocoa, I used Cocoa.
Step 3.
- Navigate to the 'MacOS X C++ Linker' > 'Libraries' option
Add the following library search paths. ( -L command line)
${CINDER_PATH}/lib
${CINDER_PATH}/lib/ios-sim
${CINDER_PATH}/lib/ios
${CINDER_PATH}/lib/macosx
Add the following libraries to include ( -l command line)
cinder
cinder_d
z
png14
pixman-1
cairo
boost_thread
boost_system
boost_filesystem
boost_date_time
cinder-iphone-sim_d
Step 4.
Under the 'MacOS X C++ Linker' menu select the 'Miscellaneous' option and add the following in the XLinker field.
${CINDER_PATH}/lib/libcinder_d.a
NOTE: It was adding this option along with the -arch i386 option that resolved this error "undefined symbols for architecture i386:"
Step 5.
- Select the "GCC C++ Compiler" menu option.
Add the following in the 'command" field.
g++ -m32 -arch i386
Select the 'Includes' menu option and add the following folder paths
${CINDER_PATH}/boost
${CINDER_PATH}/include
/System/Library/Frameworks
** Issues encountered and solutions **
Problem A
make *** Error 1 C/C++ Problem cinder
undefined symbols for architecture i386:
Solution A
I found that there were two contributing factors to overcoming this issue. The first was adding the -m32 and -arch i386 command line options to the linker and compiler settings.
The second was that inclusion of the following -XLinker option
${CINDER_PATH}/lib/libcinder_d.a
Note: The above is for debug mode, (The _d) for release you have to set it to
${CINDER_PATH}/lib/libcinder.a
** Appendix **
HelloWorld.h
#include "cinder/app/AppBasic.h"
#include "cinder/gl/gl.h"
using namespace ci;
using namespace ci::app;
using namespace std;
class HelloWorld : public AppBasic {
public:
void setup();
void mouseDown( MouseEvent event );
void update();
void draw();
void prepareSettings(Settings * settings);
};
HellowWorld.cpp
#include "HelloWorld.h"
// You dont' need this when you have the CINDER_APP_BASIC line below.
//int main(int argc, char **argv) {
// return -1;
//}
void HelloWorld::setup()
{
}
void HelloWorld::mouseDown( MouseEvent event )
{
}
void HelloWorld::update()
{
}
void HelloWorld::draw()
{
// clear out the window with black
gl::clear( Color( 0, 0, 0 ) );
}
void HelloWorld::prepareSettings(Settings * settings)
{
settings->setWindowSize( 800, 600 );
settings->setFrameRate( 60.0f );
}
CINDER_APP_BASIC( HelloWorld, RendererGl )
References
All credit goes to these posts that helped me in the first place and of course the creators of Cinder.