0

我正在尝试使用提供的 SketchUp SLAPI 框架来操作 SketchUp .skp 文件。我刚刚将整个框架文件包含到 X-code 项目中,但它一直无法构建。这个问题来自路径吗?

整个源代码是 SketchUp API 提供的示例:

#include "main.h"

#include <slapi/slapi.h>
#include <slapi/geometry.h>
#include <slapi/initialize.h>
#include <slapi/unicodestring.h>
#include <slapi/model/model.h>
#include <slapi/model/entities.h>
#include <slapi/model/face.h>
#include <slapi/model/edge.h>
#include <slapi/model/vertex.h>
#include <vector>

int main() {
    // Always initialize the API before using it
    SUInitialize();

    // Load the model from a file
    SUModelRef model = SU_INVALID;
    SUResult res = SUModelCreateFromFile(&model, "model.skp");

    // It's best to always check the return code from each SU function call.
    // Only showing this check once to keep this example short.
    if (res != SU_ERROR_NONE)
        return 1;

    // Get the entity container of the model.
    SUEntitiesRef entities = SU_INVALID;
    SUModelGetEntities(model, &entities);

    // Get all the faces from the entities object
    size_t faceCount = 0;
    SUEntitiesGetNumFaces(entities, &faceCount);

    if (faceCount > 0) {
        std::vector<SUFaceRef> faces(faceCount);
        SUEntitiesGetFaces(entities, faceCount, &faces[0], &faceCount);

        // Get all the edges in this face
        for (size_t i = 0; i < faceCount; i++) {
            size_t edgeCount = 0;
            SUFaceGetNumEdges(faces[i], &edgeCount);
            if (edgeCount > 0) {
                std::vector<SUEdgeRef> edges(edgeCount);
                SUFaceGetEdges(faces[i], edgeCount, &edges[0], &edgeCount);

                // Get the vertex positions for each edge
                for (size_t j = 0; j < edgeCount; j++) {
                    SUVertexRef startVertex = SU_INVALID;
                    SUVertexRef endVertex = SU_INVALID;
                    SUEdgeGetStartVertex(edges[j], &startVertex);
                    SUEdgeGetEndVertex(edges[j], &endVertex);
                    SUPoint3D start;
                    SUPoint3D end;
                    SUVertexGetPosition(startVertex, &start);
                    SUVertexGetPosition(endVertex, &end);
                    // Now do something with the point data
                }
            }
        }
    }

    // Get model name
    SUStringRef name = SU_INVALID;
    SUStringCreate(&name);
    SUModelGetName(model, &name);
    size_t name_length = 0;
    SUStringGetUTF8Length(name, &name_length);
    char* name_utf8 = new char[name_length + 1];
    SUStringGetUTF8(name, name_length + 1, name_utf8, &name_length);

    // Now we have the name in a form we can use
    SUStringRelease(&name);
    delete []name_utf8;

    // Must release the model or there will be memory leaks
    SUModelRelease(&model);

    // Always terminate the API when done using it
    SUTerminate();
    return 0;
}

警告看起来像

    ld: warning: ignoring file /Users/qubick/Desktop/Test/slapi.framework/slapi, file was built for unsupported file format ( 0xce 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 0 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (x86_64): /Users/qubick/Desktop/Test/slapi.framework/slapi
Undefined symbols for architecture x86_64:
  "_SUEdgeGetEndVertex", referenced from:
      _main in main.o
  "_SUEdgeGetStartVertex", referenced from:
      _main in main.o
  "_SUEntitiesGetFaces", referenced from:
      _main in main.o
  "_SUEntitiesGetNumFaces", referenced from:
      _main in main.o
  "_SUFaceGetEdges", referenced from:
      _main in main.o
  "_SUFaceGetNumEdges", referenced from:
      _main in main.o
  "_SUInitialize", referenced from:
      _main in main.o
  "_SUModelCreateFromFile", referenced from:
      _main in main.o
  "_SUModelGetEntities", referenced from:
      _main in main.o
  "_SUModelGetName", referenced from:
      _main in main.o
  "_SUModelRelease", referenced from:
      _main in main.o
  "_SUStringCreate", referenced from:
      _main in main.o
  "_SUStringGetUTF8", referenced from:
      _main in main.o
  "_SUStringGetUTF8Length", referenced from:
      _main in main.o
  "_SUStringRelease", referenced from:
      _main in main.o
  "_SUTerminate", referenced from:
      _main in main.o
  "_SUVertexGetPosition", referenced from:
      _main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

截图:https ://docs.google.com/file/d/0B-JhSq_7buRkWlE2Z294ZlRXZjQ/edit

4

1 回答 1

1

新的 SketchUp C SDK 在 Mac OS 上还不支持 64 位。包含的框架是一个 x86 二进制文件,它解释了您看到的链接器错误。

于 2013-09-16T21:34:13.830 回答