I wanted to clean up my library of custom operators so I wanted as a test merge two SOP's and output them in one DLL. So I created small test:
Common.h
#pragma once
//#ifndef _COMMON_H_
//#define _COMMON_H_
#include <SOP/SOP_Node.h>
#include <UT/UT_DSOVersion.h>
#include <UT/UT_Interrupt.h>
#include <GU/GU_Detail.h>
#include <PRM/PRM_Include.h>
#include <PRM/PRM_ChoiceList.h>
#include <OP/OP_Operator.h>
#include <OP/OP_OperatorTable.h>
#include <iostream.h>
#include <string>
using std::cout;
using std::endl;
#define SOP_ONE_SMALL_NAME “sop_one”
#define SOP_ONE_BIG_NAME “HDK SOP One”
#define SOP_TWO_SMALL_NAME “sop_two”
#define SOP_TWO_BIG_NAME “HDK SOP Two”
//#endif
One.h
#pragma once
//#ifndef _SOP_ONE_H_
//#define _SOP_ONE_H_
#include “Common.h”
namespace Mantragora
{
namespace SOP
{
class SOP_One : public SOP_Node
{
public:
virtual
~SOP_One()
override;
static PRM_Template ParameterList;
static auto
CreateSOP(OP_Network* network, const char* name, OP_Operator* op)
-> OP_Node*;
protected:
virtual auto
cookMySop(OP_Context &context)
-> OP_ERROR override;
private:
SOP_One(OP_Network* network, const char* name, OP_Operator* op);
};
}
}
//#endif
One.cpp
#include “SOP_One.h”
using namespace Mantragora:OP;
PRM_Template SOP_One:arameterList = { PRM_Template() };
auto
SOP_One::CreateSOP(OP_Network* network, const char* name, OP_Operator* op)
-> OP_Node*
{ return new SOP_One(network, name, op); }
SOP_One:OP_One(OP_Network* network, const char* name, OP_Operator* op)
: SOP_Node(network, name, op) {}
SOP_One::~SOP_One() {}
auto
SOP_One::cookMySop(OP_Context& context)
-> OP_ERROR
{
UT_AutoInterrupt progress(“Performing Operation”);
// to access input we need to lock it
if (lockInputs(context) >= UT_ERROR_ABORT)
return error();
// to modify geometry we need to make copy of it
duplicateSource(0, context);
unlockInputs();
return error();
}
Two.h
It's the same like One.h, just named properly
Two.cpp
It's the same like One.cpp, just named properly
Registration.cpp
#include “SOP/SOP_One.h”
#include “SOP/SOP_Two.h”
using namespace Mantragora:OP;
auto
newSopOperator(OP_OperatorTable* table)
-> void
{
auto sopOne = new OP_Operator(SOP_ONE_SMALL_NAME, SOP_ONE_BIG_NAME,
SOP_One::CreateSOP,
SOP_One:arameterList,
1, 1,
0);
auto sopTwo = new OP_Operator(SOP_TWO_SMALL_NAME, SOP_TWO_BIG_NAME,
SOP_Two::CreateSOP,
SOP_Two:arameterList,
1, 1,
0);
auto success = table->addOperator(sopOne);
success = table->addOperator(sopTwo);
}
When I compile it, I get those errors:
Error 471 error LNK2005: HoudiniCompilerVersion already defined in Registration.obj C:\Users\mantragora\Desktop\Houdini_Template\Houdini_Template\SOP_One.obj MANTRAGORA_Operators
Error 472 error LNK2005: HoudiniDSOVersion already defined in Registration.obj C:\Users\mantragora\Desktop\Houdini_Template\Houdini_Template\SOP_One.obj MANTRAGORA_Operators
Error 473 error LNK2005: HoudiniCompilerVersion already defined in Registration.obj C:\Users\mantragora\Desktop\Houdini_Template\Houdini_Template\SOP_Two.obj MANTRAGORA_Operators
Error 474 error LNK2005: HoudiniDSOVersion already defined in Registration.obj C:\Users\mantragora\Desktop\Houdini_Template\Houdini_Template\SOP_Two.obj MANTRAGORA_Operators
Error 475 error LNK1169: one or more multiply defined symbols found D:\Dropbox\Programs\Houdini\home\dso\H13.0\MANTRAGORA_Operators_Release_13.0.377.dll MANTRAGORA_Operators
So how to merge two operators in one?
BTW: I'm on Windows.