请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
1 i& m5 t# A8 u: ~! H: n+ ^% Q# B
- i, t2 M6 f6 t+ e% Y
I% c$ Z, F# K& k% i' B
DebUGging and Running
3 r, e; U- z; G3 K$ D5 Q# D, u
' a9 Q3 ?* H: R If the project is an internal Open C application (DLL), the following steps must be performed to associate the NX executable with the project. If these steps are not performed, the application cannot be executed or debugged from the Visual C++ environment. These steps do not apply to external Open C applications (EXEs). , P. X2 s. {# d4 u/ s) |
$ T: l" P* t* ]1 ]* u Step 1 Determine the location of the NX executable ugraf.exe. ! b. A# z/ L* b4 G3 d. M" k
& s4 P4 _( D! N9 G, [! n
Go to the Windows "Start" menu and select "Settings->Control Panel". Double-click the "System" icon. Click the "Environment" tab on the resulting "System Properties" dialog. In the "System Variables" list scroll down until you find a variable named "UGII_ROOT_DIR". The value associated with this variable is the directory path to the "ugraf.exe" executable. Select the "UGII_ROOT_DIR" variable. Highlight the complete path in the "Value" field at the bottom of the dialog and copy it to the clipboard.
; y* F' k; ?8 x3 P# v- l2 z% E
1 E3 N% f9 C; |, l Step 2 Associate the NX executable with your project.
( Q- a; x0 c9 x+ z
0 |: o7 \% P0 }0 E+ k l* z From within Visual C++, select the "Project->Settings" menu item and select the "Debug" tab on the resulting "Project Settings" dialog. Notice that the "Executable for debug session:" field is empty. Place the cursor in this field and then type or paste the path determined in the first step, followed by "\ugraf.exe". For example, if the value of "UGII_ROOT_DIR" were "C:\ugnx50\ugii" then you would enter: C:\ugnx50\ugii\ugraf.exe. You may also browse for the executable file by clicking the arrow button to the right of the "Executable for debug session:" field. 0 ~/ D0 j6 R' l5 z/ ]* e1 _
9 w5 x4 }' V, N/ e Step 3 Set the working directory. $ M8 s6 o+ f3 D, U/ j7 N
& l- t U8 z* O/ ^% @; i The "Working directory:" field on the "Project Settings" dialog specifies the directory from which Visual C++ runs NX. A common convention is to use "C:\TEMP" for the working directory.
) ?' t1 [3 N& a2 w' D( c 9 ?. x Y3 z5 s K
Step 4 Set the NX program arguments (optional) 8 L8 F. b* l4 J8 n' a& f: \9 D
8 Q5 X' P/ N+ e+ G& ^) Y" x
You may set any NX program arguments you require by entering them in the "Program arguments:" field on the "Project Settings" dialog. The syntax is exactly the same as the command-line syntax for starting NX. 6 l( _! L" ?4 m) Q( U. K( y
/ k5 @2 P r! F! g7 P+ G( X
Step 6 Run the Application
- u. V! H; o% O- n) A: \* o% i & P/ V/ _; q$ k* ^- G! A
Click "OK" in the "Project Settings" dialog and then run or debug the application as you would normally from Visual C++. NX is started each time the project is executed. You are free to place breakpoints in your Open C application just as you would in any other application. It may take a few moments for NX to appear because Visual C++ is searching for debug symbols in the NX DLLs, so be patient.
. C, v" L) G: { Print statementsSince NX is a native Windows application, there is no console started up automatically. Therefore using a printf to print to stdout will not work. If you want to use printf statements to debug your internal Open C application, you must add the following code to your internal Open C API function:
# v8 }# T! j0 u7 b0 l( G
; q( T- C5 @ L; U: C #include <windows.h>: b) b5 }' [" F5 I6 K
#include <fstream.h>. ]8 s" D' T' {
#include <stdio.h>
+ D+ @/ y9 @& x- s6 }6 t+ Z/ O7 _ ...% {# G6 w! |* J, i# ?
FILE *fp;
$ v. D% }/ u2 a ... R1 \! D& M" k5 I* z7 U; N4 i+ y
0 W0 ?* z: I3 x% F8 u. |+ `6 N
/* allocate console window conout$ */0 Z0 b+ d0 u. ^2 s: q6 B
AllocConsole();/ w8 I/ h0 ~: c
/* reopen stdout on conout$ for fprintf and printf */
. z5 S: I* i* kfp = freopen("conout$", "w", stdout); , t H+ Y$ V4 N1 E
( }+ ]8 r! j/ Q. M7 P
This will create a console window and attach it to stdout so that printf and fprintf will work. 2 l% _% \" o4 U( R1 n; Q% d4 R
) c$ V# ~8 x3 H+ l( t3 K/ R |