Page 1 of 1

PX routine problem - Error compiling parallel transformer

Posted: Fri Dec 02, 2016 4:02 pm
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;
}

Posted: Fri Dec 02, 2016 5:35 pm
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

Posted: Mon Dec 05, 2016 10:13 am
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.

Posted: Mon Dec 05, 2016 1:06 pm
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.

Posted: Mon Dec 05, 2016 1:27 pm
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.

Posted: Tue Dec 06, 2016 9:59 am
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.