error LNK2019: 无法解析的外部符号 __imp_SU***,该符号在函数 main 中被引用

Brook_ 2019-06-04 03:53:12
控制台输出:
====================[ Build | sketchup_imports | Debug ]========================
"F:\CLion 2019.1.4\bin\cmake\win\bin\cmake.exe" --build G:\project\CLion\sketchup_imports\cmake-build-debug --target sketchup_imports --
Scanning dependencies of target sketchup_imports
[ 50%] Building CXX object CMakeFiles/sketchup_imports.dir/main.cpp.obj
main.cpp
[100%] Linking CXX executable sketchup_imports.exe
LINK Pass 1: command "C:\PROGRA~2\MICROS~2.0\VC\bin\amd64\link.exe /nologo @CMakeFiles\sketchup_imports.dir\objects1.rsp /out:sketchup_imports.exe /implib:sketchup_imports.lib /pdb:G:\project\CLion\sketchup_imports\cmake-build-debug\sketchup_imports.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles\sketchup_imports.dir/intermediate.manifest CMakeFiles\sketchup_imports.dir/manifest.res" failed (exit code 1120) with the following output:
main.cpp.obj : error LNK2019: 无法解析的外部符号 __imp_SUInitialize,该符号在函数 main 中被引用
main.cpp.obj : error LNK2019: 无法解析的外部符号 __imp_SUTerminate,该符号在函数 main 中被引用
main.cpp.obj : error LNK2019: 无法解析的外部符号 __imp_SUStringCreate,该符号在函数 main 中被引用
main.cpp.obj : error LNK2019: 无法解析的外部符号 __imp_SUStringRelease,该符号在函数 main 中被引用
main.cpp.obj : error LNK2019: 无法解析的外部符号 __imp_SUStringGetUTF8Length,该符号在函数 main 中被引用
main.cpp.obj : error LNK2019: 无法解析的外部符号 __imp_SUStringGetUTF8,该符号在函数 main 中被引用
main.cpp.obj : error LNK2019: 无法解析的外部符号 __imp_SUModelCreateFromFile,该符号在函数 main 中被引用
main.cpp.obj : error LNK2019: 无法解析的外部符号 __imp_SUModelRelease,该符号在函数 main 中被引用
main.cpp.obj : error LNK2019: 无法解析的外部符号 __imp_SUModelGetEntities,该符号在函数 main 中被引用
main.cpp.obj : error LNK2019: 无法解析的外部符号 __imp_SUModelGetName,该符号在函数 main 中被引用
main.cpp.obj : error LNK2019: 无法解析的外部符号 __imp_SUEntitiesGetNumFaces,该符号在函数 main 中被引用
main.cpp.obj : error LNK2019: 无法解析的外部符号 __imp_SUEntitiesGetFaces,该符号在函数 main 中被引用
main.cpp.obj : error LNK2019: 无法解析的外部符号 __imp_SUFaceGetNumEdges,该符号在函数 main 中被引用
main.cpp.obj : error LNK2019: 无法解析的外部符号 __imp_SUFaceGetEdges,该符号在函数 main 中被引用
main.cpp.obj : error LNK2019: 无法解析的外部符号 __imp_SUEdgeGetStartVertex,该符号在函数 main 中被引用
main.cpp.obj : error LNK2019: 无法解析的外部符号 __imp_SUEdgeGetEndVertex,该符号在函数 main 中被引用
main.cpp.obj : error LNK2019: 无法解析的外部符号 __imp_SUVertexGetPosition,该符号在函数 main 中被引用
sketchup_imports.exe : fatal error LNK1120: 17 个无法解析的外部命令
NMAKE : fatal error U1077: “"F:\CLion 2019.1.4\bin\cmake\win\bin\cmake.exe"”: 返回代码“0xffffffff”
Stop.
NMAKE : fatal error U1077: “"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe"”: 返回代码“0x2”
Stop.
NMAKE : fatal error U1077: “"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe"”: 返回代码“0x2”
Stop.
NMAKE : fatal error U1077: “"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe"”: 返回代码“0x2”
Stop.



源码:
#include <iostream>
#include "SketchUpAPI/slapi.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>

int main() {
// Always initialize the API before using it
SUInitialize(); //这是其中一个报错
// Load the model from a file
SUModelRef model = SU_INVALID;
SUResult res = SUModelCreateFromFile(&model, "Sketchup_3D_Test.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;
}







请各位大神帮帮忙,我是小学生一枚
...全文
691 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Brook_ 2019-06-04
  • 打赏
  • 举报
回复
引用 1 楼 zarelaky 的回复:
CMakeLists.txt 中添加 TARGET_LINK_LIBRARIES(<add_executable里面的target> sketchupapi);
cmake_minimum_required(VERSION 3.14) project(sketchup_imports) set(CMAKE_CXX_STANDARD 14) add_executable(sketchup_imports main.cpp) target_link_libraries(sketchup_imports SketchUpAPI) //新添加的,问题解决了
zarelaky 2019-06-04
  • 打赏
  • 举报
回复
CMakeLists.txt 中添加
TARGET_LINK_LIBRARIES(<add_executable里面的target> sketchupapi);

64,633

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧