none
DLL erstellen für Plant Simulation RRS feed

  • Frage

  • Hallo,

    dies ist mein erster Forenbeitrag, deswegen möchte ich zunächst erstmal alle hier begrüßen. Ich bin C++ Neuling und versuche momentan eine DLL Datei in Visual Studio 2013 zu erstellen, die später in Tecnomatix Plant Simulation aufgerufen werden soll. Als ersten Test habe ich mir den Sinus von PI/6 durch eine DLL in Plant Simulation ausgeben lassen, hat auch super funktioniert. Jetzt versuche ich zusätzlich eine Tabelle zu füllen, eine Header Datei für die PlantSim-eigenen Befehle wurde von PlantSim bereitgestellt. Dabei bekomme ich folgende Errors:

    Error 1 error LNK2001: unresolved external symbol _listAtPut            File CSchnittstelle.dll

    Error 2 error LNK1120: 1 unresolved externals                           File cinterf.obj

    Anscheinend gibt es ein Problem mit der Headerdatei. Sie ist allerdings im Solution Explorer unter "Header Files" zu finden und auch im Ordner drin. Ich bin für jede Antwort dankbar.

    PS.: Mir ist natürlich bewusst, dass ich die Tabelle auch mit SimTalk füllen könnte. Das hier ist lediglich ein Test der C-Schnittstelle von PlantSim.

    Die von Plant Simulation bereitgestellte Headerdatei cwinfunc.h:

    #ifndef __C_USERFUNC_H
    #define __C_USERFUNC_H
    
    typedef void *SimpleObjID;
    
    typedef enum { UF_NONE=0, UF_VOID, UF_INTEGER, UF_REAL, UF_BOOLEAN, UF_STRING,
                   UF_LENGTH, UF_WEIGHT, UF_SPEED, UF_ACCELERATION, UF_TIME, UF_DATE,
                   UF_DATETIME, UF_OBJECT, UF_ERROR, UF_ERROR_STR } UF_DataType;
    
    typedef union {
    	int          integer;
    	double       real;
    	int          boolean;
    	char*        string;
    	double       length;
    	double       weight;
    	double       speed;
    	double       acceleration;
    	double       time;
    	double       date;
    	double       datetime;
    	SimpleObjID  object;
    	int          error;
    } UF_ValueUnion;
    
    typedef struct {
    	UF_DataType    type;
    	UF_ValueUnion  value;
    } UF_Value;
    
    
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    #if defined(__STDC__) || defined(__cplusplus)
    
    extern UF_Value	listAt(SimpleObjID list,int x,int y);
    extern UF_Value	listAtIndex(SimpleObjID list,UF_Value *x,UF_Value *y);
    extern UF_Value	listAtPut(SimpleObjID list,int x,int y,UF_Value *value);
    extern UF_Value	listAtIndexPut(SimpleObjID list,UF_Value *x,UF_Value *y,UF_Value *value);
    extern UF_Value	evalPath(SimpleObjID startObject,char *path,int argcount,UF_Value *args);
    extern UF_Value	assignValue(SimpleObjID object,char *attribute,char *subattribute,UF_Value *value);
    extern UF_Value	executeMethod(SimpleObjID method,SimpleObjID caller,SimpleObjID aktiveElement,int argcount,UF_Value *args);
    extern UF_Value	executeFunction(char *fktname,int argcount,UF_Value *args);
    
    #else
    
    extern UF_Value	listAt();
    extern UF_Value	listAtIndex();
    extern UF_Value	listAtPut();
    extern UF_Value	listAtIndexPut();
    extern UF_Value	evalPath();
    extern UF_Value	assignValue();
    extern UF_Value	executeMethod();
    extern UF_Value	executeFunction();
    
    #endif
    
    #ifdef __cplusplus
    }	/* extern "C" */
    #endif
    
    #endif	/* __C_USERFUNC_H */

    Der Code für sin(PI/6) und die Tabelle; cinterf.cpp:

    #define _CRT_SECURE_NO_WARNINGS #include <math.h> #include <iostream> #define WIN32_LEAN_AND_MEAN #include <windows.h> #include <stdio.h> #include "cwinfunc.h" extern "C" __declspec(dllexport) void calcSin(UF_Value *ret, UF_Value *arg) { ret->type = UF_REAL; ret->value.real = sin(arg[0].value.real); } void listAccess(UF_Value *ret, UF_Value *arg) { char data[100]; UF_Value val; val.type = UF_STRING; val.value.string = data; for (int x = 1; x <= 10; x++) { for (int y = 1; y <= 10; y++) { sprintf(data, "x: %d, y: %d", x, y); listAtPut(arg[0].value.object, x, y, &val); } } ret->type = UF_NONE;

    }


     

    Freitag, 9. März 2018 09:46

Antworten