Pro/TOOLKIT
| (12 intermediate revisions by one user not shown) | |||
| Line 1: | Line 1: | ||
| − | I'm using Pro/ENIGNEER Wildfire 3. | + | I'm using Pro/ENIGNEER Wildfire 3 and Visual Studio .Net 2003. |
==Installation== | ==Installation== | ||
| Line 23: | Line 23: | ||
where msg_user.txt has the following: | where msg_user.txt has the following: | ||
| − | + | <PRE> | |
USER %0s | USER %0s | ||
%0s | %0s | ||
| Line 52: | Line 52: | ||
# | # | ||
# | # | ||
| − | + | </PRE> | |
The path will obviously have to be changed to wherever you keep the file. These message files keep the text that is displayed in Pro/ENGINEER. A typical use will be something like the following: | The path will obviously have to be changed to wherever you keep the file. These message files keep the text that is displayed in Pro/ENGINEER. A typical use will be something like the following: | ||
| Line 62: | Line 62: | ||
the text file instead had the entry | the text file instead had the entry | ||
| + | <PRE> | ||
USER -HelloWorld | USER -HelloWorld | ||
Export | Export | ||
| + | </PRE> | ||
the button would be named "Export." A quirky feature of these message files is that changes in them will only be recognized once Pro/ENGINEER is closed down and restarted. Merely restarting the auxiliary application or re-registering it is insufficient. | the button would be named "Export." A quirky feature of these message files is that changes in them will only be recognized once Pro/ENGINEER is closed down and restarted. Merely restarting the auxiliary application or re-registering it is insufficient. | ||
| + | |||
| + | ==Hello Button== | ||
| + | |||
| + | The added functionality of some of the above code hints at what is to come here: a short talk on adding menus to Pro/E. This section is based on code from the user guide, which has had its buggy portions removed. | ||
| + | |||
| + | <PRE> | ||
| + | #include <time.h> | ||
| + | #ifdef USE_ANSI_IOSTREAMS | ||
| + | # include <iostream> | ||
| + | using namespace std; | ||
| + | #else | ||
| + | //# include <iostream.h> | ||
| + | #endif | ||
| + | #include "TestError.h" | ||
| + | |||
| + | /*--------------------------------------------------------------------*\ | ||
| + | Pro/Toolkit includes | ||
| + | \*--------------------------------------------------------------------*/ | ||
| + | #define PRO_USE_VAR_ARGS | ||
| + | |||
| + | |||
| + | #include <ProDrawing.h> | ||
| + | #include <ProMenuBar.h> | ||
| + | #include <ProMessage.h> | ||
| + | |||
| + | /*--------------------------------------------------------------------*\ | ||
| + | Application global/external data | ||
| + | \*--------------------------------------------------------------------*/ | ||
| + | static wchar_t MSGFIL[] = {'m','s','g','_','u','s','e','r','.','t','x','t','\0'}; | ||
| + | static char revcode[PRO_LINE_SIZE]; | ||
| + | |||
| + | /* Declare function */ | ||
| + | ProError ProTestInstallationCheck(); | ||
| + | ProError ProTestInstallationURLCheck(); | ||
| + | ProError ProTestDialogCreate ( ProBoolean is_successful ); | ||
| + | |||
| + | extern "C" static uiCmdAccessState TestAccessDefault(uiCmdAccessMode access_mode) | ||
| + | { | ||
| + | return (ACCESS_AVAILABLE); | ||
| + | } | ||
| + | |||
| + | /*================================================================*\ | ||
| + | FUNCTION: MiscAction() | ||
| + | PURPOSE: Generic action function | ||
| + | \*================================================================*/ | ||
| + | extern "C" int MiscAction() | ||
| + | { | ||
| + | wchar_t UserMsg[80]; | ||
| + | ProStringToWstring (UserMsg, "C:\\cygwin\\home\\Admin\\tkTest\\TKTEMPLATE\\msg_user.txt"); | ||
| + | ProMessageDisplay (UserMsg, "USER %0s", "Action function called."); | ||
| + | return (0); | ||
| + | } | ||
| + | |||
| + | |||
| + | /*===========================================================================*\ | ||
| + | Function : main | ||
| + | Purpose : Test the ProToolkitMain() function. main is optional function. | ||
| + | \*===========================================================================*/ | ||
| + | int main(int argc, char **argv) | ||
| + | { | ||
| + | // cerr << endl << "\tWelcome to Pro/TOOLKIT - The \"pt_install_test\" program" << endl; | ||
| + | |||
| + | ProToolkitMain(argc, argv); | ||
| + | |||
| + | return(0); | ||
| + | } | ||
| + | |||
| + | |||
| + | /*====================================================================*\ | ||
| + | FUNCTION : user_initialize() | ||
| + | PURPOSE : Pro/DEVELOP standard initialize - define menu button | ||
| + | \*====================================================================*/ | ||
| + | extern "C" int user_initialize( | ||
| + | int argc, | ||
| + | char *argv[], | ||
| + | char *version, | ||
| + | char *build, | ||
| + | wchar_t errbuf[80]) | ||
| + | { | ||
| + | char cbuff1[PRO_PATH_SIZE], cbuff2[PRO_PATH_SIZE]; | ||
| + | char astr1[PRO_LINE_SIZE]; | ||
| + | int i, menu_id; | ||
| + | ProPath wbuff1, wbuff2; | ||
| + | ProError status; | ||
| + | uiCmdCmdId cmd_id; | ||
| + | wchar_t UserMsg[80]; | ||
| + | |||
| + | /*================================================================*\ | ||
| + | Say hello and add menu buttons. | ||
| + | \*================================================================*/ | ||
| + | |||
| + | /*----------------------------------------------------------------*\ | ||
| + | Message file. | ||
| + | \*----------------------------------------------------------------*/ | ||
| + | ProStringToWstring (UserMsg, "C:\\cygwin\\home\\Admin\\tkTest\\TKTEMPLATE\\msg_user.txt"); | ||
| + | ProMessageDisplay (UserMsg, "USER %0s", "Apples2Apples export tool started."); | ||
| + | |||
| + | /*----------------------------------------------------------------*\ | ||
| + | Add a new menu to the menu bar (to the right of Utilities). | ||
| + | \*----------------------------------------------------------------*/ | ||
| + | status = ProMenubarMenuAdd ("Exporter", "USER -Exporter", | ||
| + | "Utilities", PRO_B_TRUE, UserMsg); | ||
| + | /*----------------------------------------------------------------*\ | ||
| + | Add to the new menu. | ||
| + | \*----------------------------------------------------------------*/ | ||
| + | status = ProCmdActionAdd ("UserDispMsg", (uiCmdCmdActFn)MiscAction, | ||
| + | uiCmdPrioDefault, TestAccessDefault, PRO_B_TRUE, PRO_B_TRUE, | ||
| + | &cmd_id); | ||
| + | |||
| + | status = ProMenubarmenuMenuAdd ("Exporter", "Sub1", "USER -Sub1", | ||
| + | NULL, PRO_B_TRUE, UserMsg); | ||
| + | /*----------------------------------------------------------------*\ | ||
| + | Fill in the buttons of Sub1. | ||
| + | \*----------------------------------------------------------------*/ | ||
| + | status = ProMenubarmenuPushbuttonAdd ("Sub1", "Sub1Btn1", | ||
| + | "USER -Sub1Btn1", "USER New Button help.", NULL, PRO_B_TRUE, | ||
| + | cmd_id, UserMsg); | ||
| + | |||
| + | |||
| + | return(0); | ||
| + | } | ||
| + | |||
| + | /*====================================================================*\ | ||
| + | FUNCTION : user_terminate() | ||
| + | PURPOSE : To handle any termination actions | ||
| + | \*====================================================================*/ | ||
| + | extern "C" void user_terminate() | ||
| + | { | ||
| + | /*---------------------------------------------------------------------*\ | ||
| + | Loging file close. | ||
| + | \*---------------------------------------------------------------------*/ | ||
| + | ProTestErrlogClose(); | ||
| + | |||
| + | // cout << "user_terminate" << endl; | ||
| + | } | ||
| + | |||
| + | |||
| + | </PRE> | ||
| + | |||
| + | *ProMenubarMenuAdd - this creates a button on the highest level menu next to "Utilities," which is actually the Tools button... | ||
| + | *ProMenubarmenuMenuAdd - this adds a menu to the menu that was added with ProMenubarMenuAdd. | ||
| + | *ProMenubarmenuPushbuttonAdd - This adds a button off of the menu just added an associates with it the action created with ProCmdActionAdd. | ||
| + | |||
| + | ==Integration with other DLLs== | ||
| + | |||
| + | The documentation for Pro/TOOLKIT in the windows environment is, as near as I can tell, virtually non-existent. The best documentation that I've been able to find is the website cited earlier. This site brings up a difficulty in integrating Pro/TOOLKIT with other libraries: modern dlls are often built with the a multi-threaded runtime library. In order to build a Pro/TOOLKIT dll with a multi-threaded runtime library, the following changes must be made to the set up sequence described in the cited site: | ||
| + | |||
| + | # Do not link to protk_dll.lib. Instead link to protk_dllmd.lib. | ||
| + | # Change the runtime library to Multi-threaded Debug DLL or the non-Debug version. | ||
| + | # If needed, explicitly include MSVCRTD.lib (debug) or MSVCRT.lib. | ||
| + | |||
| + | The project should now be able to be built and run from Pro/ENGINEER as well as integrated with existing dlls. [1] claimed that this library cannot be used to create a standalone executable. | ||
| + | |||
| + | ==Integrating with STD libraries== | ||
| + | |||
| + | For some reason, I kept getting the following errors when I tried including iostream and string. | ||
| + | |||
| + | <PRE> | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(19): error C2039: 'fgetwc' : is not a member of 'operator``global namespace''' | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(19): error C2039: 'fgetws' : is not a member of 'operator``global namespace''' | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(19): error C2039: 'fputwc' : is not a member of 'operator``global namespace''' | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(20): error C2039: 'fputws' : is not a member of 'operator``global namespace''' | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(20): error C2039: 'fwprintf' : is not a member of 'operator``global namespace''' | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(21): error C2039: 'fwscanf' : is not a member of 'operator``global namespace''' | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(21): error C2039: 'getwc' : is not a member of 'operator``global namespace''' | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(21): error C2039: 'getwchar' : is not a member of 'operator``global namespace''' | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(23): error C2039: 'putwc' : is not a member of 'operator``global namespace''' | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(23): error C2039: 'putwchar' : is not a member of 'operator``global namespace''' | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(24): error C2039: 'swprintf' : is not a member of 'operator``global namespace''' | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(24): error C2039: 'swscanf' : is not a member of 'operator``global namespace''' | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(24): error C2039: 'ungetwc' : is not a member of 'operator``global namespace''' | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(25): error C2039: 'vfwprintf' : is not a member of 'operator``global namespace''' | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(25): error C2039: 'vswprintf' : is not a member of 'operator``global namespace''' | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(25): error C2039: 'vwprintf' : is not a member of 'operator``global namespace''' | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(26): error C2039: 'wprintf' : is not a member of 'operator``global namespace''' | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(26): error C2039: 'wscanf' : is not a member of 'operator``global namespace''' | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(19): error C2873: 'fgetwc' : symbol cannot be used in a using-declaration | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(19): error C2873: 'fgetws' : symbol cannot be used in a using-declaration | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(19): error C2873: 'fputwc' : symbol cannot be used in a using-declaration | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(20): error C2873: 'fputws' : symbol cannot be used in a using-declaration | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(20): error C2873: 'fwprintf' : symbol cannot be used in a using-declaration | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(21): error C2873: 'fwscanf' : symbol cannot be used in a using-declaration | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(21): error C2873: 'getwc' : symbol cannot be used in a using-declaration | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(21): error C2873: 'getwchar' : symbol cannot be used in a using-declaration | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(23): error C2873: 'putwc' : symbol cannot be used in a using-declaration | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(23): error C2873: 'putwchar' : symbol cannot be used in a using-declaration | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(24): error C2873: 'swprintf' : symbol cannot be used in a using-declaration | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(24): error C2873: 'swscanf' : symbol cannot be used in a using-declaration | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(24): error C2873: 'ungetwc' : symbol cannot be used in a using-declaration | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(25): error C2873: 'vfwprintf' : symbol cannot be used in a using-declaration | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(25): error C2873: 'vswprintf' : symbol cannot be used in a using-declaration | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(25): error C2873: 'vwprintf' : symbol cannot be used in a using-declaration | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(26): error C2873: 'wprintf' : symbol cannot be used in a using-declaration | ||
| + | c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(26): error C2873: 'wscanf' : symbol cannot be used in a using-declaration | ||
| + | </PRE> | ||
| + | |||
| + | My workaround was to write my own version of cwchar without the missing functions: | ||
| + | <PRE> | ||
| + | #include <wchar.h> | ||
| + | #define _CWCHAR_ | ||
| + | namespace std { | ||
| + | using ::mbstate_t; using ::size_t; using ::wint_t; | ||
| + | using ::fwide; using ::mbrlen; using ::mbrtowc; | ||
| + | using ::mbsinit; using ::wcrtomb; using ::wcsrtombs; | ||
| + | using ::wcstol; using ::wcscat; using ::mbsrtowcs; | ||
| + | using ::wcschr; using ::wcscmp; using ::wcscoll; | ||
| + | using ::wcscpy; using ::wcscspn; using ::wcslen; | ||
| + | using ::wcsncat; using ::wcsncmp; using ::wcsncpy; | ||
| + | using ::wcspbrk; using ::wcsrchr; using ::wcsspn; | ||
| + | using ::wcsstr; using ::wcstok; using ::wcsxfrm; | ||
| + | using ::wmemchr; using ::wmemcmp; using ::wmemcpy; | ||
| + | using ::wmemmove; using ::wmemset; using ::wcsftime; | ||
| + | }; | ||
| + | </PRE> | ||
| + | |||
| + | This has allowed me to include iostream and string, and I've yet to run into a problem. | ||
| + | |||
| + | ==Links== | ||
| + | |||
| + | 1: http://www.caddigest.com/subjects/pro_engineer/select/tutorials/jovanovic_toolkit_environment.htm | ||
Latest revision as of 18:35, 14 March 2007
I'm using Pro/ENIGNEER Wildfire 3 and Visual Studio .Net 2003.
Contents |
Installation
Pro/TOOLKIT is sold as a component of Pro/ENGINEER. If your license allows, you can install Pro/TOOLKIT along with Pro/ENGINEER. There should be an option during the Define Installation Components section of the install with something like:
API Toolkits—Select this component to optionally install the files necessary to run the Application Program Interface toolkits like Pro/J.Link, Pro/Web.Link, and Pro/TOOLKIT.
Setting Up A Project
I found a tutorial on setting up a visual studio project at [1]. I used Visual Studio .Net 2003 and had no problems.
Hello World
The simplest method for a "HelloWorld" program is likely the following:
ProStringToWstring (UserMsg, "C:\\cygwin\\home\\Admin\\tkTest\\TKTEMPLATE\\msg_user.txt");
ProMessageDisplay (UserMsg, "USER %0s",
"Hello World.");
where msg_user.txt has the following:
USER %0s %0s # # USER -HelloWorld HelloWorld # # USER -MainBtn1 -MainBtn1 # # USER New Button help. New Button help. # # USER -Sub1 -Sub1 # # USER -Sub1Btn1 -Sub1Btn1 # # USER -Sub1Btn2 -Sub1Btn2 # #
The path will obviously have to be changed to wherever you keep the file. These message files keep the text that is displayed in Pro/ENGINEER. A typical use will be something like the following:
status = ProMenubarMenuAdd ("HelloWorld", "USER -HelloWorld",
"Utilities", PRO_B_TRUE, UserMsg);
Here, a button will recieve the text defined in the file under "USER -HelloWorld." In the above, this is HelloWorld. However, if the the text file instead had the entry
USER -HelloWorld Export
the button would be named "Export." A quirky feature of these message files is that changes in them will only be recognized once Pro/ENGINEER is closed down and restarted. Merely restarting the auxiliary application or re-registering it is insufficient.
Hello Button
The added functionality of some of the above code hints at what is to come here: a short talk on adding menus to Pro/E. This section is based on code from the user guide, which has had its buggy portions removed.
#include <time.h>
#ifdef USE_ANSI_IOSTREAMS
# include <iostream>
using namespace std;
#else
//# include <iostream.h>
#endif
#include "TestError.h"
/*--------------------------------------------------------------------*\
Pro/Toolkit includes
\*--------------------------------------------------------------------*/
#define PRO_USE_VAR_ARGS
#include <ProDrawing.h>
#include <ProMenuBar.h>
#include <ProMessage.h>
/*--------------------------------------------------------------------*\
Application global/external data
\*--------------------------------------------------------------------*/
static wchar_t MSGFIL[] = {'m','s','g','_','u','s','e','r','.','t','x','t','\0'};
static char revcode[PRO_LINE_SIZE];
/* Declare function */
ProError ProTestInstallationCheck();
ProError ProTestInstallationURLCheck();
ProError ProTestDialogCreate ( ProBoolean is_successful );
extern "C" static uiCmdAccessState TestAccessDefault(uiCmdAccessMode access_mode)
{
return (ACCESS_AVAILABLE);
}
/*================================================================*\
FUNCTION: MiscAction()
PURPOSE: Generic action function
\*================================================================*/
extern "C" int MiscAction()
{
wchar_t UserMsg[80];
ProStringToWstring (UserMsg, "C:\\cygwin\\home\\Admin\\tkTest\\TKTEMPLATE\\msg_user.txt");
ProMessageDisplay (UserMsg, "USER %0s", "Action function called.");
return (0);
}
/*===========================================================================*\
Function : main
Purpose : Test the ProToolkitMain() function. main is optional function.
\*===========================================================================*/
int main(int argc, char **argv)
{
// cerr << endl << "\tWelcome to Pro/TOOLKIT - The \"pt_install_test\" program" << endl;
ProToolkitMain(argc, argv);
return(0);
}
/*====================================================================*\
FUNCTION : user_initialize()
PURPOSE : Pro/DEVELOP standard initialize - define menu button
\*====================================================================*/
extern "C" int user_initialize(
int argc,
char *argv[],
char *version,
char *build,
wchar_t errbuf[80])
{
char cbuff1[PRO_PATH_SIZE], cbuff2[PRO_PATH_SIZE];
char astr1[PRO_LINE_SIZE];
int i, menu_id;
ProPath wbuff1, wbuff2;
ProError status;
uiCmdCmdId cmd_id;
wchar_t UserMsg[80];
/*================================================================*\
Say hello and add menu buttons.
\*================================================================*/
/*----------------------------------------------------------------*\
Message file.
\*----------------------------------------------------------------*/
ProStringToWstring (UserMsg, "C:\\cygwin\\home\\Admin\\tkTest\\TKTEMPLATE\\msg_user.txt");
ProMessageDisplay (UserMsg, "USER %0s", "Apples2Apples export tool started.");
/*----------------------------------------------------------------*\
Add a new menu to the menu bar (to the right of Utilities).
\*----------------------------------------------------------------*/
status = ProMenubarMenuAdd ("Exporter", "USER -Exporter",
"Utilities", PRO_B_TRUE, UserMsg);
/*----------------------------------------------------------------*\
Add to the new menu.
\*----------------------------------------------------------------*/
status = ProCmdActionAdd ("UserDispMsg", (uiCmdCmdActFn)MiscAction,
uiCmdPrioDefault, TestAccessDefault, PRO_B_TRUE, PRO_B_TRUE,
&cmd_id);
status = ProMenubarmenuMenuAdd ("Exporter", "Sub1", "USER -Sub1",
NULL, PRO_B_TRUE, UserMsg);
/*----------------------------------------------------------------*\
Fill in the buttons of Sub1.
\*----------------------------------------------------------------*/
status = ProMenubarmenuPushbuttonAdd ("Sub1", "Sub1Btn1",
"USER -Sub1Btn1", "USER New Button help.", NULL, PRO_B_TRUE,
cmd_id, UserMsg);
return(0);
}
/*====================================================================*\
FUNCTION : user_terminate()
PURPOSE : To handle any termination actions
\*====================================================================*/
extern "C" void user_terminate()
{
/*---------------------------------------------------------------------*\
Loging file close.
\*---------------------------------------------------------------------*/
ProTestErrlogClose();
// cout << "user_terminate" << endl;
}
- ProMenubarMenuAdd - this creates a button on the highest level menu next to "Utilities," which is actually the Tools button...
- ProMenubarmenuMenuAdd - this adds a menu to the menu that was added with ProMenubarMenuAdd.
- ProMenubarmenuPushbuttonAdd - This adds a button off of the menu just added an associates with it the action created with ProCmdActionAdd.
Integration with other DLLs
The documentation for Pro/TOOLKIT in the windows environment is, as near as I can tell, virtually non-existent. The best documentation that I've been able to find is the website cited earlier. This site brings up a difficulty in integrating Pro/TOOLKIT with other libraries: modern dlls are often built with the a multi-threaded runtime library. In order to build a Pro/TOOLKIT dll with a multi-threaded runtime library, the following changes must be made to the set up sequence described in the cited site:
- Do not link to protk_dll.lib. Instead link to protk_dllmd.lib.
- Change the runtime library to Multi-threaded Debug DLL or the non-Debug version.
- If needed, explicitly include MSVCRTD.lib (debug) or MSVCRT.lib.
The project should now be able to be built and run from Pro/ENGINEER as well as integrated with existing dlls. [1] claimed that this library cannot be used to create a standalone executable.
Integrating with STD libraries
For some reason, I kept getting the following errors when I tried including iostream and string.
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(19): error C2039: 'fgetwc' : is not a member of 'operator``global namespace''' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(19): error C2039: 'fgetws' : is not a member of 'operator``global namespace''' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(19): error C2039: 'fputwc' : is not a member of 'operator``global namespace''' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(20): error C2039: 'fputws' : is not a member of 'operator``global namespace''' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(20): error C2039: 'fwprintf' : is not a member of 'operator``global namespace''' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(21): error C2039: 'fwscanf' : is not a member of 'operator``global namespace''' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(21): error C2039: 'getwc' : is not a member of 'operator``global namespace''' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(21): error C2039: 'getwchar' : is not a member of 'operator``global namespace''' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(23): error C2039: 'putwc' : is not a member of 'operator``global namespace''' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(23): error C2039: 'putwchar' : is not a member of 'operator``global namespace''' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(24): error C2039: 'swprintf' : is not a member of 'operator``global namespace''' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(24): error C2039: 'swscanf' : is not a member of 'operator``global namespace''' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(24): error C2039: 'ungetwc' : is not a member of 'operator``global namespace''' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(25): error C2039: 'vfwprintf' : is not a member of 'operator``global namespace''' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(25): error C2039: 'vswprintf' : is not a member of 'operator``global namespace''' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(25): error C2039: 'vwprintf' : is not a member of 'operator``global namespace''' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(26): error C2039: 'wprintf' : is not a member of 'operator``global namespace''' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(26): error C2039: 'wscanf' : is not a member of 'operator``global namespace''' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(19): error C2873: 'fgetwc' : symbol cannot be used in a using-declaration c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(19): error C2873: 'fgetws' : symbol cannot be used in a using-declaration c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(19): error C2873: 'fputwc' : symbol cannot be used in a using-declaration c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(20): error C2873: 'fputws' : symbol cannot be used in a using-declaration c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(20): error C2873: 'fwprintf' : symbol cannot be used in a using-declaration c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(21): error C2873: 'fwscanf' : symbol cannot be used in a using-declaration c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(21): error C2873: 'getwc' : symbol cannot be used in a using-declaration c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(21): error C2873: 'getwchar' : symbol cannot be used in a using-declaration c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(23): error C2873: 'putwc' : symbol cannot be used in a using-declaration c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(23): error C2873: 'putwchar' : symbol cannot be used in a using-declaration c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(24): error C2873: 'swprintf' : symbol cannot be used in a using-declaration c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(24): error C2873: 'swscanf' : symbol cannot be used in a using-declaration c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(24): error C2873: 'ungetwc' : symbol cannot be used in a using-declaration c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(25): error C2873: 'vfwprintf' : symbol cannot be used in a using-declaration c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(25): error C2873: 'vswprintf' : symbol cannot be used in a using-declaration c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(25): error C2873: 'vwprintf' : symbol cannot be used in a using-declaration c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(26): error C2873: 'wprintf' : symbol cannot be used in a using-declaration c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cwchar(26): error C2873: 'wscanf' : symbol cannot be used in a using-declaration
My workaround was to write my own version of cwchar without the missing functions:
#include <wchar.h>
#define _CWCHAR_
namespace std {
using ::mbstate_t; using ::size_t; using ::wint_t;
using ::fwide; using ::mbrlen; using ::mbrtowc;
using ::mbsinit; using ::wcrtomb; using ::wcsrtombs;
using ::wcstol; using ::wcscat; using ::mbsrtowcs;
using ::wcschr; using ::wcscmp; using ::wcscoll;
using ::wcscpy; using ::wcscspn; using ::wcslen;
using ::wcsncat; using ::wcsncmp; using ::wcsncpy;
using ::wcspbrk; using ::wcsrchr; using ::wcsspn;
using ::wcsstr; using ::wcstok; using ::wcsxfrm;
using ::wmemchr; using ::wmemcmp; using ::wmemcpy;
using ::wmemmove; using ::wmemset; using ::wcsftime;
};
This has allowed me to include iostream and string, and I've yet to run into a problem.
Links
1: http://www.caddigest.com/subjects/pro_engineer/select/tutorials/jovanovic_toolkit_environment.htm