Error running a simple C routine.

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
Minhajuddin
Participant
Posts: 467
Joined: Tue Mar 20, 2007 6:36 am
Location: Chennai
Contact:

Error running a simple C routine.

Post by Minhajuddin »

Hi all,

I have a simple c routine.

Code: Select all

#include <string.h>
#include <stdio.h>
#include <stdlib.h>

int simpleRoutine(int i)
{
i = 101010;
return i;
}
I have compiled it into an obj file "simpleRoutine.obj". And I created a routine in Datastage, with the settings:

Routine Name: simpleRoutineds
Type: External Function
Object Type : Object
External subroutine name: simpleRoutine
Return type: int
Library Path: C:\osh\
Arguments:
argument Name: i
I/O type: I
Native type: int


I have set the library path to C:\osh\ where I have the object file for this routine.


But, when I try to compile a job using this routine it is throwing up an error. Please help me debug it. Here is the error:

Code: Select all

Output from transformer compilation follows:

##I TFCN 000001 10:01:38(000) <main_program> 
Ascential DataStage(tm) Enterprise Edition 7.5
Copyright (c) 2004, 1997-2004 Ascential Software Corporation.
All Rights Reserved


##I TOSH 000002 10:01:38(001) <main_program> orchgeneral: loaded
##I TOSH 000002 10:01:38(002) <main_program> orchsort: loaded
##I TOSH 000002 10:01:38(003) <main_program> orchstats: loaded
##W TFPA 000012 10:01:38(006) <main_program> Warning: the PWD environment variable is not defined. Remote process startup may be unsuccessful as a result.If your ORCHESTRATE job does not start up correctly, please set your PWD variable to a value that will work on all nodes of your system.
##E TBLD 000000 10:01:52(000) <main_program> Error when checking composite operator: Subprocess command failed with exit status 40192
##E TFSR 000019 10:01:52(001) <main_program> Could not check all operators because of previous error(s)
##W TFCP 000000 10:01:52(002) <transform> Error when checking composite operator:  The number of reject datasets "0"is less than the number of input datasets "1".
##I TBLD 000000 10:01:52(003) <main_program> Error when checking composite operator: Output from subprocess: C:\Ascential\DataStage\Projects\Test\RT_BP11.O\V0S3_cRoutine_Transformer_3.C(239) : warning C4244: '=' : conversion from 'APT_Int64' to 'int', possible loss of data

##W TFCP 000025 10:01:52(004) <transform> Error when checking composite operator: Possible range limitation
##W TFCP 000000 10:01:52(005) <transform> Error when checking composite operator:  Implicit conversion from source type "Int32" to result type "Decimal".
##I TFCP 000008 10:01:52(006) <transform> Error when checking composite operator: cxx    -LC:/Ascential/DataStage/Projects/Test/RT_BP11.O/ -LC:/Ascential/DataStage/PXEngine/lib -LC:/Ascential/DataStage/PXEngine/user_lib -W/TP -W/dll -W/base:0x50000000 -lliborchnt -lliborchcorent -lliborchbuildopnt C:\osh\.o C:/Ascential/DataStage/Projects/Test/RT_BP11.O/V0S3_cRoutine_Transformer_3.tmp.o -o C:/Ascential/DataStage/Projects/Test/RT_BP11.O/V0S3_cRoutine_Transformer_3.dll
##I TBLD 000000 10:01:52(007) <main_program> Error when checking composite operator: Output from subprocess: LINK : warning LNK4224: /DEBUGTYPE:BOTH is no longer supported;  ignored

##I TBLD 000000 10:01:52(008) <main_program> Error when checking composite operator: Output from subprocess: LINK : fatal error LNK1181: cannot open input file 'C:osh.o'

##E TCOS 000029 10:01:52(009) <main_program> Creation of step finished with status = FAILED (cRoutine.Transformer_3)

*** Internal Generated Transformer Code follows:
0001: //
0002: // Generated file to implement the V0S3_repos_Transformer_3 transform operator.
0003: //
0004: 
0005: // define external functions used
0006: extern int32 simpleRoutine(int32 i);
0007: 
0008: // define our input/output link names
0009: inputname 0 DSLink2;
0010: outputname 0 DSLink6;
0011: 
0012: initialize {
0013: 	// define our row rejected variable
0014: 	int8 RowRejected0;
0015: 
0016: 	// define our null set variable
0017: 	int8 NullSetVar0;
0018: 
0019: }
0020: 
0021: mainloop {
0022: 	// initialise our row rejected variable
0023: 	RowRejected0 = 1;
0024: 
0025: 	// evaluate columns (no constraints) for link: DSLink6
0026: 	DSLink6.state = simpleRoutine(2);
0027: 	DSLink6.agg_popn = DSLink2.population;
0028: 	writerecord 0;
0029: 	RowRejected0 = 0;
0030: }
0031: 
0032: finish {
0033: }
0034: 
*** End of Internal Generated Transformer Code
Minhajuddin

<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Modifying the input argument in a function is never a good plan - you can get unwanted side effects. What did you actually want this function to accomplish?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Minhajuddin
Participant
Posts: 467
Joined: Tue Mar 20, 2007 6:36 am
Location: Chennai
Contact:

Post by Minhajuddin »

Hi Ray,

I wanted to get started with c routines. It's just a simple routine which just returns a number '101010'. I thought if this ran fine.. I could dive into more complex routines.....
Minhajuddin

<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

If you look at the settings within DataStage it will tell you the compiler name and options used. You need to match these to create your own routines. Do a search there are several posts explaining how to do this.
Mamu Kim
Minhajuddin
Participant
Posts: 467
Joined: Tue Mar 20, 2007 6:36 am
Location: Chennai
Contact:

Post by Minhajuddin »

Hi Kim,

I searched the forum but didn't get the exact method of linking a c routine... maybe I am missing something....

And even the datastage documentation doesn't have an example of a c routine..... :(
Minhajuddin

<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Compiling and linking C routines is usually achieved using what's called a "make file". Research this term in your C language manuals. Under the covers the compiler gets involved, so too might other commands such as ld - it really depends on what your routine requires. It's impossible, really, to give a generic "one size fits all" answer.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
shivadas
Participant
Posts: 48
Joined: Tue Jun 12, 2007 12:10 am

Re: Error running a simple C routine.

Post by shivadas »

Hi Muju,

Did you got any soluction how to build and use c routine in DS
Post Reply