PX 转换例程编译问题
PX Transform Routine compile issues
>我有一个用 C++ 编写的转换器例程,该例程设置为清除所有空格并在输入字符串为 null 或空时映射到一个值。c ++代码已编译并已正确测试,但是我在使例程在Datastage中工作时遇到问题。
根据说明,我已经复制了我在DS环境中的确切编译器选项,如下所示。
g++ -c -O -fPIC -Wno-deprecated -m64 -mtune=generic -mcmodel=small BlankToValue.cpp
g++ -shared -m64 BlankToValue.so BlankToValue.o
但是,在作业中测试例程时,我收到以下错误。
Sequential_File_36,0: 内部错误: (shbuf(: IOMGR/IOMGRC: 2649
我应该使用一组不同的选项进行编译吗?
作为参考,请参阅 c++ 代码。
#include <stdlib.h>
#include <stdio.h>
#include <algorithm>
#include <locale.h>
#include <locale>
char * BlankToValue(char *InStr, char *RepStr)
{
if (InStr[0] == ' ') // Check for null pointer at first character of input string.
{
return RepStr; // Return replacement string if true. This is to prevent unnecessary processing.
} else
{
const char* checkstr = InStr; // Establish copy of inputstring stored in checkstring.
do { // Start outer loop.
while (isspace(*checkstr)) { // Inner loop while current checkstring byte is whitespace.
++checkstr; // Increment to next checkstring byte.
}
} while ((*InStr++ = *checkstr++)); // Set inputstring byte to current checkstring and iterate both. Breaks when either string evaluates to null.
*InStr = ' '; // Set null terminator for input string at current byte location.
if (InStr[0] == ' ') // Checks first character of cleaned input string for null pointer.
{
return RepStr; // Return replacement string if true.
} else
{
return InStr; // Return new input string if false.
}
}
}
威廉,
在指向此自定义函数的 DataStage 例程定义中,您是选择例程类型作为对象(在作业运行时编译到转换器阶段的 .o 文件(还是库(在作业运行时加载但对库命名约定有要求的 lib.so 文件,并且该库位于库路径中(。 上面的代码建议您正在创建一个 *.so 文件,但没有以 lib 为前缀。 下面是一个示例: https://www.ibm.com/support/pages/node/403041
此外,如果作业日志中的第一个错误不是库加载错误,而是内部错误 (shbuf( 错误,我发现过去使用自定义例程会发生过几种情况:
自定义例程涉及空处理,您的例程也是如此,并且在升级到 Information Server 8.5 后,当我们的产品中的空处理规则发生更改时,自定义例程开始失败。 这些更改解释如下: https://www.ibm.com/support/pages/node/433863 您可以通过使用新的作业级别环境变量运行作业来测试这是否是问题所在:APT_TRANSFORM_COMPILE_OLD_NULL_HANDLING=1
在另一种情况下,自定义例程中的 shbuf 错误是转换器级接收到大记录(大于自定义例程中定义的数据类型可以处理的记录(的结果。 在所有字符串类型字段中仅使用具有较小值的单个示例输入记录时,作业是否仍然失败。
谢谢。
另外,我注意到错误来自顺序文件阶段,而不是使用自定义例程的转换器阶段。 因此,可能还需要考虑自定义例程的输出数据类型是什么,并确保它以有效值退出,该值对于数据类型来说不会太大,也不会大于阶段之间使用的默认传输缓冲区大小(默认为 128k(。
经过一两天多次尝试不同的编译和代码方法,我找到了解决问题的方法。下面的代码在传递空列时抛出分段错误。回想起来,这是有道理的。
if (InStr[0] == ' ')
它已被更正到下面,现在一切正常。
if ((InStr == NULL) || (InStr[0] == ' '))
- 编译包含字符串的代码时遇到问题
- 在编译C++代码(具有dlib和opencv)到WASM时面临问题
- 编译要在英特尔Hyperscan中使用的.cc文件时出现问题
- 如何在 Mac 上正确编译C++,当它在 Linux 上编译没有问题时?
- Rextester 语言编译C++问题
- 这是使用回溯的 nqueen 问题,但我使用了动态 2d 数组,我的程序编译良好,但不返回任何输出
- 编译 llvm 插件时出现问题:llvm/Config/llvm-config.h:没有这样的文件或目录
- C++ 多级虚拟继承编译问题
- 编译问题:在函数"_start"中:未定义对"主"的引用 collect2:错误:ld 返回 1 个退出状态
- 在Linux上使用Clang / OLLVM交叉编译helloworld Windows可执行文件时的问题
- 使用 CImg 库的 std::min 和 std::max 的编译问题
- Qt Visual Studio 2015 加载项编译问题
- 构造函数和 G++ 编译配方的问题
- 解析问题 - 预期的非限定 ID - #include <array> 编译错误
- libssh 问题编译问题未定义的错误
- Eclipse 问题 - 编译期间不考虑 .c 和 .cpp 文件中定义的预处理
- Visual Studio 2017问题编译了C 代码,而该代码则在Linux中编译
- 这个C++代码有什么问题?编译错误:调用“测试::测试(测试)”没有匹配函数
- 试图编译基本Boost PropertyTree示例时出现问题-编译错误.该怎么做
- 如何解决***缺少分隔符的问题.编译QT(或支持库)时