I managed to build the basic Hello World
ruby extension from Github with XCode 7.2.1
Now I would like to add some of the functions from SketchupAPI
and to do this I have initially included the headers
#include "RubyUtils/RubyUtils.h"
#include <iostream>
#include <assert.h>
#include <SketchUpAPI/common.h>
#include <SketchUpAPI/model/material.h>
#include <SketchUpAPI/color.h>
#include <SketchUpAPI/geometry.h>
#include <SketchUpAPI/initialize.h>
#include <SketchUpAPI/unicodestring.h>
#include <SketchUpAPI/model/model.h>
#include <SketchUpAPI/model/entities.h>
#include <SketchUpAPI/model/face.h>
#include <SketchUpAPI/model/edge.h>
#include <SketchUpAPI/model/vertex.h>
#include <vector>
VALUE hello_world() {
return GetRubyInterface("Hello World!");
}
// Load this module from Ruby using:
// require 'SUEX_HelloWorld'
extern "C"
void Init_SUEX()
{
VALUE mSUEX = rb_define_module("SUEX");
rb_define_const(mSUEX, "CEXT_VERSION", GetRubyInterface("1.0.0"));
rb_define_module_function(mSUEX, "hello_world",
VALUEFUNC(hello_world), 0);
}
The project builds successfully, I copy the three files in my plugin folder …/Plugins/RG/SUEX
Frameworks/Ruby.framework
Frameworks/SketchUpAPI.framework
SUEX.bundle
but when I require it with require "RG/SUEX/SUEX.bundle"
I get the error
Error: #<LoadError: dlopen(/Users/ruggiero/Library/Application Support/SketchUp 2015/SketchUp/Plugins/RG/SUEX/SUEX.bundle, 9): Library not loaded: @rpath/SketchUpAPI.framework/Versions/Current/SketchUpAPI
Referenced from: /Users/ruggiero/Library/Application Support/SketchUp 2015/SketchUp/Plugins/RG/SUEX/SUEX.bundle
Reason: image not found - /Users/ruggiero/Library/Application Support/SketchUp 2015/SketchUp/Plugins/RG/SUEX/SUEX.bundle>
/Applications/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/2.0/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
/Applications/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/2.0/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
<main>:in `<main>'
SketchUp:1:in `eval'
I think the problem is related to the search path but I cannot figure out how to fix it. Any idea?