首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Eclipse for MacOS X 10.8.2中编译Cinder

如何在Eclipse for MacOS X 10.8.2中编译Cinder
EN

Stack Overflow用户
提问于 2013-01-17 20:16:10
回答 1查看 1.1K关注 0票数 1

我已经下载并安装了Cinder,甚至在XCode中运行了TinderBox教程来创建Cinder项目。

然而,我热衷于使用eclipse作为我的IDE,而不是Xcode。

我正在运行OSX 10.8.2

在遵循以下教程配置eclipse Configure EclipseVimeo Video之后,我遇到了许多编译和链接问题。

代码语言:javascript
复制
make *** Error 1 C/C++ Problem cinder
undefined symbols for architecture i386:

我认为我要么没有完全遵循教程的帖子,要么在我的设置中有一些不同。

注意:这是一个问答帖子。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-01-17 20:16:10

索引

遇到的eclipse

  • Configure eclipse

  • Issues和solutions

  • Appendix (源eclipse

**配置eclipse **

假设您有一个eclipse的C++版本,并创建了一个基本的C++ Cinder项目。您可以在下面的附录中找到.h和.cpp文件。下面概述了需要配置才能进行编译的设置。

步骤1.

在C/C++ Build > 'Build Variables‘选项中打开项目’window.

  • Navigate‘

添加以下变量。

代码语言:javascript
复制
CINDER_PATH /path/to/cinder_0.8.4_mac/

步骤2.

  • 导航到C/C++ Build > Settings window.

  • Under Tools选项卡,选择'MacOS X C++ Linker‘选项。

在这里,在‘g++’输入字段中,您需要在命令后添加命令行选项和OSX框架引用

代码语言:javascript
复制
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告诉链路使用32位而不是64位。

-arch i386确保我们链接到正确的架构。

-framework参考了运行Cinder所需的框架(据我目前所知)

代码语言:javascript
复制
NOTE: Depending on your mac version you might find -framework Carbon in stead of -framework Cocoa, I used Cocoa. 

步骤3.

  1. 导航到'MacOS X C++ Linker‘> 'Libraries’选项
  2. 添加以下库搜索路径。( -L命令行)

${CINDER_PATH}/lib

${CINDER_PATH}/lib/ios-sim

${CINDER_PATH}/lib/ios

${CINDER_PATH}/lib/macosx

添加以下要包含的库( -l命令行)

代码语言:javascript
复制
cinder
cinder_d
z
png14
pixman-1
cairo
boost_thread
boost_system
boost_filesystem
boost_date_time
cinder-iphone-sim_d

步骤4.

在“MacOS X C++链接器”菜单下,选择“其他”选项,并在XLinker字段中添加以下内容。

代码语言:javascript
复制
${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:"

步骤5.

  1. 选择"GCC命令编译器“菜单选项。
  2. 在”C++“字段中添加以下内容。

g++ -m32 -arch i386

选择'Includes‘菜单选项并添加以下文件夹路径

代码语言:javascript
复制
${CINDER_PATH}/boost
${CINDER_PATH}/include
/System/Library/Frameworks

**遇到的问题及解决方案**

问题A

代码语言:javascript
复制
make *** Error 1 C/C++ Problem cinder
undefined symbols for architecture i386:

解决方案A

我发现有两个因素有助于克服这个问题。第一个是将-m32和-arch i386命令行选项添加到链接器和编译器设置。

第二个是包含以下-XLinker选项

代码语言:javascript
复制
${CINDER_PATH}/lib/libcinder_d.a

注意:以上是调试模式,( _d)对于发布,您必须将其设置为

代码语言:javascript
复制
${CINDER_PATH}/lib/libcinder.a

**附录**

HelloWorld.h

代码语言:javascript
复制
#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

代码语言:javascript
复制
#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 )

参考

所有的功劳都归功于这些最初帮助我的帖子,当然还有Cinder的创建者。

  1. Original Tutorial followed to configure eclipse for Cinder
  2. Link that helped solve the problem of correctly linking
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14378905

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档