C语言编写LoadRunner脚本时如何引入.h文件?已将.h文件移至脚本路径
Hey there! Since you’ve already moved your target .h file to the same directory as your LoadRunner (LR) script, including it is straightforward. Here’s a step-by-step breakdown:
1. Use Double Quotes for Local Header Inclusion
In your LR C script (the .c file in your script project), add the include statement using double quotes instead of angle brackets. This tells the compiler to first look in the current script directory before checking system/LoadRunner default paths.
Example:
#include "your_target_header.h"
Note: Replace
your_target_header.hwith the exact filename of your header file—pay attention to uppercase/lowercase if you’re working in a case-sensitive environment (though Windows-based LR setups are usually case-insensitive, it’s good practice to match the filename exactly).
2. Optional: Verify LoadRunner’s Include Path (If Needed)
In most cases, the double-quote method works immediately if the .h file is in the script’s root directory. But if you run into a "header file not found" error during compilation, you can explicitly add the script directory to LR’s include search path:
- Open VuGen and your script project.
- Go to
Tools > General Options > Directoriestab. - In the
Include directoriessection, click theAddbutton and browse to your script’s directory. - Save the settings and recompile your script.
3. Validate the Inclusion
After adding the include statement, press F7 to compile your script. If the compilation succeeds without "file not found" errors, your header file is correctly included.
Quick Troubleshooting Tips
- If the script compiles but throws "undefined reference" errors, make sure any function implementations (
.cfiles) corresponding to declarations in your.hfile are also present in the script directory or linked properly. - If your
.hfile is in a subfolder of the script directory, use a relative path in the include statement:#include "./subfoldername/your_target_header.h"
内容的提问来源于stack exchange,提问作者bosimao

