Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X
I am trying to create an app using Object Toolkit C++ and run it using spawn mode (exe). I have tried with DLL and it works, but when I compile to exe and change the creotk.dat file to startup spawn it does not work anymore. After having registered the app in auxiliary applications, pressing start causes Creo to freeze and then crash.
My additional dependencies in the Visual studio solution is :
My creotk.dat is as follows:
name ObjectTest
startup spawn
#toolkit object
#creo_type direct
exec_file C:\Users\SENY5612\source\repos\ObjectToolkitTest\x64\Debug\FindNumberAnnotate.exe
text_dir .\text
allow_stop true
delay_start false
end
My source code is as following (for now it is more or less empty as you can see):
#include <wfcSession.h>
#include <pfcGlobal.h>
#include <pfcCommand.h>
#include <pfcUI.h>
#include <pfcExceptions.h>
#include <wfcClient.h>
#include <string>
#include <iostream>
#include <cstdio>
#include <stdexcept>
class OTKTestCallBack : public virtual pfcUICommandActionListener
{
public:
void OnCommand();
};
extern "C" int main(int argc, char* argv[])
{
return 0;
}
/* Entry */
extern "C" int user_initialize(
int argc,
char* argv[],
char* version,
char* build,
wchar_t errbuf[80])
{
pfcUICommand_ptr command;
try
{
return (wfcTK_NO_ERROR);
}
xcatchbegin
xcatchcip(Ex)
return (wfcTK_NO_ERROR);
xcatchend
return 0;
}
/* Exit*/
extern "C" void user_terminate()
{
}
void OTKTestCallBack::OnCommand()
{
try
{
}
xcatchbegin
xcatchcip(Ex)
xcatchend
catch (...)
{
}
}
Hi,
you should ask PTC Support.
Try full path of the text option.
See "Creo Object TOOLKIT C++ User’s Guide" (OTKUG) (<Creo>\Common Files\otk_cpp_doc\otkug.pdf) chapter "Registry File Fields" for protk.dat/creotk.dat syntax.
toolkit
Specifies the name of the Toolkit which was used to create the
customization. The valid values for this field are object and
protoolkit.
An application created in Creo Object TOOLKIT C++ must always
have the value of this field set as object.
(But I don't really believe this is the culprit.)
What libraries to include?
See "Standard Libraries" in the OTKUG. Mind the /MD topic!
otk_222.lib If you have the advanced license option 222, include this library in your application.
otk_no222.lib If you do not have the advanced license option 222, include this library in your application.
Are you sure you can use otk_222_md.lib? (This is a different licence than just the TK/OTK development licence.)
See "Creo TOOLKIT User’s Guide" (TKUSE) (<Creo>\Common Files\protoolkit\tkuse.pdf) chapter "Core of a Creo Toolkit Application"
user_initialize() must contain at least one Creo TOOLKIT API call.
Failure to do so causes the Creo TOOLKIT application to fail and return PRO_TK_GENERAL_ERROR.
If somehow the compiler settings regarding subsystem console/Windows is set to Windows, try
#ifdef _WINDLL
// No main entry point needed.
#pragma message ( __LOC_INF__ "_WINDLL is SET (assuming compiling synchronous DLL)" )
#else
#pragma message ( __LOC_INF__ "_WINDLL is NOT SET (assuming compiling synchronous EXE/SPAWN mode)" )
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
return main(__argc, __argv);
}
#endif
If none of the above helped, try to write a TOOLKIT (C, not C++ Object TOOLKIT!) DLL and get this started in spawn mode and add/modify to OTK later.