PX routine problem - Error compiling parallel transformer

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
Childrensmn
Premium Member
Premium Member
Posts: 32
Joined: Mon Apr 12, 2010 3:42 pm
Location: Minneapolis
Contact:

PX routine problem - Error compiling parallel transformer

Post by Childrensmn »

Very simple code. I'm just trying to get a integer returned to a test job. Below is the code. It compiles ok, but when I run it I get: "Error Compiling parallel transformer cpp_test_routine". While making the routine I have 2 int as input and the return value is int also...

Code: Select all

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

 using namespace std;

int addNumbers(int a,int b)
{
     return a+b;
}
asorrell
Posts: 1707
Joined: Fri Apr 04, 2003 2:00 pm
Location: Colleyville, Texas

Post by asorrell »

Make sure you have the same compiler that is specified in the environment variables in the admin client. Also make sure that your path variables are set so that the compiler and all libraries are accessible.

Also - have you reviewed all the steps outlined below (make sure and set it for the correct version).

http://www.ibm.com/support/knowledgecen ... utine.html
Andy Sorrell
Certified DataStage Consultant
IBM Analytics Champion 2009 - 2020
UCDI
Premium Member
Premium Member
Posts: 383
Joined: Mon Mar 21, 2016 2:00 pm

Post by UCDI »

mixing namespace and C is bad. (namespace is C++, these are C headers).
use <cstdio>, <cstdlib>
<cstring> is something else, use <string.h> if you are going to use C's string routines (recommended, c++ overthunk it).

This "error" can cause some compilers to bomb with weird messages depending on the settings and more. Other compilers eat it just fine.

alternatively, you can remove the using namespace std and use the old C headers instead.


You don't need ANY of these libraries to add 2 integers. You are bloating your code ... only include what you use, even if your compiler can remove the unused stuff, it is still best to just not pull it in (faster compiles, easier to understand the code, and more reasons). Granted, you will probably need most of the ones listed once you get past your test function.

FWIW I compile with this in a shell script to use with datastage:
g++ -O -fPIC -Wno-deprecated -m64 -mtune=generic -mcmodel=small -shared -m64 -c $1

This may not be the only, or best way, but it works for me under linux on 11.X.
Childrensmn
Premium Member
Premium Member
Posts: 32
Joined: Mon Apr 12, 2010 3:42 pm
Location: Minneapolis
Contact:

Post by Childrensmn »

Thanks Andy..... You would not believe how long it took me to see that -o and -O on the compile line is not the same.
UCDI
Premium Member
Premium Member
Posts: 383
Joined: Mon Mar 21, 2016 2:00 pm

Post by UCDI »

Or that.

I still recommend the corrections I gave in case you ever change to a more picky compiler. Visual studio used to explode when C headers were put in C++, not sure if it still does.
Childrensmn
Premium Member
Premium Member
Posts: 32
Joined: Mon Apr 12, 2010 3:42 pm
Location: Minneapolis
Contact:

Post by Childrensmn »

Yep Ill make the changes. Im still trying to figure out what Im doing, and how to do it.

Thanks for the help.
Post Reply