Hi,
I already asked a similar question and the problem was a missing library in the *.mke file.
At the moment I have my "main" .cpp file and I want to call an Initialization function from another .cpp file.
I did it in a similar way to the "exampleSolids" program inside the Microstation SDK when it calls through a key-in an initialization function that is located in another file (e.g. exampleParametricFeatureTree).
Here you can see my main .cpp file:
//ParametricFeature.cpp
#include "ParametricFeatures.h"
Public RscFileHandle rfHandle; /* Resource file handle */
.
.
.
// Map key-in to function
static MdlCommandNumber commandNumbers[] =
{
{ (CmdHandler)ParametricFeatures_cmdExit, CMD_PARAMETRICFEATURES_EXIT },
{ (CmdHandler)GetSmartFeatureTree, CMD_TREE },
{ (CmdHandler)startShapeProcessor, CMD_SHAPE },
0
};
.
.
.
/*---------------------------------------------------------------------------------**//**
* @description MdlMain
* @param argc The number of command line parameters sent to the application.
* @param argv[] The array of strings sent to the application on the command line.
* @bsimethod Bentley Systems
+---------------+---------------+---------------+---------------+---------------+------*/
extern "C" DLLEXPORT void MdlMain(int argc, WCharCP argv[])
{
// Resources are defined in .r files
mdlResource_openFile(&rfHandle, NULL, RSC_READONLY);
// Register command numbers to enable you key in a command name to start a command
mdlSystem_registerCommandNumbers(commandNumbers);
// Load the command table defined in ParametricFeatures.r
mdlParse_loadCommandTable(NULL);
}
The header:
//ParametricFeature.h
#include <DgnView\DgnTool.h>
.
.
.
#define CMD_TREE 0x0100000000000000UI64
#define CMD_SHAPE 0x0200000000000000UI64
#define CMD_PARAMETRICFEATURES_EXIT 0x0300000000000000UI64
USING_NAMESPACE_BENTLEY;
USING_NAMESPACE_BENTLEY_DGNPLATFORM;
USING_NAMESPACE_BENTLEY_MSTNPLATFORM;
USING_NAMESPACE_BENTLEY_MSTNPLATFORM_ELEMENT;
USING_NAMESPACE_SMARTFEATURE;
void ParametricFeatures_cmdExit(WCharCP unparsedP);
void startShapeProcessor(WCharCP unparsedP);
StatusInt GetSmartFeatureTree(WCharCP unparsedP);
The line that generates problem is the one regarding the "startShapeProcessor" function.
Here you can see the .cpp file where is defined:
#include "ParametricFeatures.h"
struct ShapeProcessor : ElementGraphicsTool
{
protected:
ShapeProcessor(int cmdName)
{
SetCmdName(cmdName, 0);
}
virtual BentleyStatus _OnProcessSolidPrimitive(ISolidPrimitivePtr& geomPtr, DisplayPathCR path) override { return ERROR; } // Promote capped surface to solid body and un-capped surface to sheet body...
virtual BentleyStatus _OnProcessBsplineSurface(MSBsplineSurfacePtr& geomPtr, DisplayPathCR path) override { return ERROR; } // Promote surface to sheet body...
virtual BentleyStatus _OnProcessCurveVector(CurveVectorPtr& geomPtr, DisplayPathCR path) override { return ERROR; } // Promote region to sheet body...
virtual BentleyStatus _OnProcessPolyface(PolyfaceHeaderPtr& geomPtr, DisplayPathCR path) override { return SUCCESS; } // Don't convert a closed mesh to a BRep (and don't collect), can be expensive for large meshes...
/*---------------------------------------------------------------------------------**//**
*@bsimethod Bentley Systems
+---------------+---------------+---------------+---------------+---------------+------*/
virtual bool _CollectCurves() override { return false; } // Tool supports and collects profile.
virtual bool _CollectSurfaces() override { return false; } // Tool does not support solid face.
virtual bool _CollectSolids() override { return false; } // Tool does not support solid body.
/*---------------------------------------------------------------------------------**//**
* Overriding some base class methods to control work flow of the tool
* @bsimethod Bentley Systems
+---------------+---------------+---------------+---------------+---------------+------*/
private: StatusInt _OnElementModify(EditElementHandleR eeh) override { return SUCCESS; } // pure virtual method, sub-class must override!
private: bool _OnResetButton(DgnButtonEventCR ev) override { _OnRestartTool(); return true; }
/*---------------------------------------------------------------------------------**//**
* Return true if this element has the required geometry and should be accepted.
* @bsimethod Bentley Systems
+---------------+---------------+---------------+---------------+---------------+------*/
virtual bool _IsElementValidForOperation(ElementHandleCR eh, HitPathCP path, WStringR cantAcceptReason) override
{
return true;
}
/*---------------------------------------------------------------------------------**//**
* Install a new instance of the tool. Will be called in response to external events
* such as undo or by the base class from _OnReinitialize when the tool needs to be
* reset to it's initial state.
* @bsimethod Bentley Systems
+---------------+---------------+---------------+---------------+---------------+------*/
virtual void _OnRestartTool() override
{
InstallNewInstance(GetToolId());
}
public:
/*---------------------------------------------------------------------------------**//**
* Method to create and install a new instance of the tool. If InstallTool returns ERROR,
* the new tool instance will be freed/invalid. Never call delete on RefCounted classes.
* @bsimethod Bentley Systems
+---------------+---------------+---------------+---------------+---------------+------*/
static void InstallNewInstance(int toolId)
{
ShapeProcessor* tool = new ShapeProcessor(toolId);
tool->InstallTool();
}
/*=================================================================================**//**
* Functions associated with command number for starting tool.
* @param[in] unparsed Additional input supplied after command string.
+===============+===============+===============+===============+===============+======*/
Public void startShapeProcessor(WCharCP unparsedP)
{
// NOTE: Call the method to create/install the tool, RefCounted classes don't have public constructors...
ShapeProcessor::InstallNewInstance(2);
}
};
In the .mke file the source files for the are specified too:
PolicyFile = MicroStationPolicy.mki
appName = ParametricFeatures
sAppName = ParametricFeatures
MDLMKI = $(MSMDE)mki/
mdlLibs = $(MSMDE)library/
#dirToSearch = $(MDLMKI)
#genSrc = $(o)
%include $(MDLMKI)mdl.mki
.
.
.
#--------------------------------------------------------------------------------------
# Create object files
#--------------------------------------------------------------------------------------
$(rscObjects)$(sAppName).rsc : $(baseDir)$(sAppName).r
$(o)$(sAppName).h : $(baseDir)$(sAppName).r
#--------------------------------------------------------------------------------------
# Set up to use dlmcomp.mki and dlmlink.mki
#--------------------------------------------------------------------------------------
appObjects = \
$(o)$(appName)$(oext) \
$(o)ShapeProcessor$(oext) \
DLM_OBJECT_DEST = $(o)
DLM_NAME = $(appName)
DLM_OBJECT_FILES = $(appObjects)
DLM_LIBDEF_SRC = $(_MakeFilePath)
DLM_SPECIAL_LINKOPT = -fixed:no # Notify linker this library does not require a fixed base address to load
DLM_NO_DLS = 1 # USE DLLEXPORT IN .CPP
DLM_NO_DEF = 1
DLM_NOENTRY = 1
DLM_NO_MANIFEST = 1 # If not set linker embeds your current (developer) patched MSVCRT version manifest in output dll. This is not desirable and produces side-by-side CLIENT ERROR: 14001)
DLM_NO_SIGN = 1 # If not set and no certificate found, ERROR: 'singleton' is not recognized as an internal or external command
DLM_NO_INITIALIZE_FUNCTION = 1
DLM_DEST = $(mdlapps)
LINKER_LIBRARIES + $(mdlLibs)Bentley.lib
LINKER_LIBRARIES + $(mdlLibs)BentleyGeom.lib
LINKER_LIBRARIES + $(mdlLibs)BentleyAllocator.lib
LINKER_LIBRARIES + $(mdlLibs)DgnPlatform.lib
LINKER_LIBRARIES + $(mdlLibs)DgnView.lib
LINKER_LIBRARIES + $(mdlLibs)mdlbltin.lib
LINKER_LIBRARIES + $(mdlLibs)PSolidCore.lib
LINKER_LIBRARIES + $(mdlLibs)RmgrTools.lib
LINKER_LIBRARIES + $(mdlLibs)SmartFeature.lib
#--------------------------------------------------------------------------------------
# Compile the source files for the DLM
#--------------------------------------------------------------------------------------
$(o)$(appName)$(oext) : $(baseDir)$(appName).cpp $(baseDir)$(appName).h
$(o)ShapeProcessor$(oext) : $(baseDir)ShapeProcessor.cpp $(baseDir)$(appName).h
%include $(MDLMKI)dlmlink.mki
.
.
.
The error that i have is the following:
![]()
I don't understand what's missing, does anyone of you has any suggestion?