C++包含问题
C++ include issue
我正在使用C++为Autodesk Maya编写一个插件,但存在链接器错误。
我的主要课程是Maya_Search_Plugin.cpp
#include <Utilities.h>
DeclareSimpleCommand( search_face, PLUGIN_COMPANY, "4.5");
//doIt method is entry point for plugin
MStatus search_face::doIt( const MArgList& )
{
//calls to Maya types/functions and Utilities functions
}
然后我有一个Utilities类,其中包含一些静态方法,标题看起来像
#ifndef __Maya_CPP_Plugin__Utilities__
#define __Maya_CPP_Plugin__Utilities__
//#pragma once
//standard libs
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <iostream>
#include <math.h>
//maya libs
#include <maya/MDagPath.h>
#include <maya/MFn.h>
#include <maya/MFileIO.h>
#include <maya/MIOStream.h>
#include <maya/MFnMesh.h>
#include <maya/MFnTransform.h>
#include <maya/MGlobal.h>
#include <maya/MSelectionList.h>
#include <maya/MSimple.h>
#include <maya/MTypes.h>
#include <maya/MPointArray.h>
#include <maya/MObjectArray.h>
class Utilities{
public: static const int max_mov = 50;
public:
static double get_mesh_error(MPointArray, MPointArray, int);
static MStatus translateManipulator(double amount, MObject *path);
static void GetSelected(MObjectArray* objects, MFn::Type type);
};
#endif /* defined(__Maya_CPP_Plugin__Utilities__) */
像这样的实现
#include <Utilities.h>
double Utilities::get_mesh_error(MPointArray a, MPointArray b, int vertexCount){
...
}
MStatus Utilities::translateManipulator(double amount, MObject *path){
...
}
void Utilities::GetSelected(MObjectArray* objects, MFn::Type type) {
...
}
然而,我得到以下错误
duplicate symbol _MApiVersion in:
/Users/tmg06qyu/Library/Developer/Xcode/DerivedData/Maya_CPP_Plugin-hjrwvybwlvqyyscbmixdkcpdzjqr/Build/Intermediates/Maya_CPP_Plugin.build/Debug/Maya_CPP_Plugin.build/Objects-normal/x86_64/Maya_Search_Plugin.o
/Users/tmg06qyu/Library/Developer/Xcode/DerivedData/Maya_CPP_Plugin-hjrwvybwlvqyyscbmixdkcpdzjqr/Build/Intermediates/Maya_CPP_Plugin.build/Debug/Maya_CPP_Plugin.build/Objects-normal/x86_64/Utilities.o
ld: 1 duplicate symbol for architecture x86_64
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld failed with exit code 1
我认为这是一个链接错误,在某个地方有一些循环引用,但我不知道它在哪里
感谢您的帮助。
谢谢。
我知道这已经一年了。但几分钟前我又偶然发现了。。。
添加
#define MNoVersionString
#define MNoPluginEntry
#include <maya/MFnPlugin.h>
到您编写插件代码的头文件或cpp文件。包括
#include <maya/MFnPlugin.h>
直接在初始化插件的main.cpp中。
maya中的大多数示例都有以下字符串:
// This is added to prevent multiple definitions of the MApiVersion string.
#define _MApiVersion
在包括任何内容之前。例如这里。
如果您有多个包含MFnPlugin.h 的文件,则可能会发生此问题
相关文章:
- 编译包含字符串的代码时遇到问题
- 使用mongocxx驱动程序时包含头文件问题
- 当调用switch语句中的函数时(即使函数不包含循环),似乎是永不结束的循环的问题
- 包含矢量指针的结构的内存释放问题
- CMake 错误"源似乎不包含 CMakeLists.txt",路径/库连接问题
- 指向包含对齐 C 结构C++类的 C 指针的对齐问题
- 在包含窗口标头时难以解决循环依赖关系问题
- 在Visual Studio代码中包含自定义c++库的问题
- 双向链表问题 - 包含项目但不显示
- 包含问题:"多重定义"、"此处首次定义"
- C++ 将问题包含在其他文件中?(提升包括)
- 检查 std::any 变量是否包含 std::string 时出现问题
- 相同的代码,不同的结果?从其他项目包含有什么问题?
- 头文件的相互包含会导致问题
- "Debug assertion failed" 这种有什么问题?它应该按年份对包含电影对象的动态列表进行排序
- 可变参数类的文件包含问题
- 在构建基于 C++ 的软件时包含 QtGui 文件的问题
- 我的逻辑有什么问题?尝试计算文件中包含特定字符的单词数
- 休息:当我尝试制作包含JSON参数的requst时发出问题
- OOP 设计问题:包含对象或容器中的责任