All Forums Connectivity
OrangeCrush 2 posts Joined 08/08
14 Aug 2008
Problems compiling simple UDF (plusudf).

I am a new user trying to load a simple UDF into the database but getting some errors. I am on Windows XP using VS2005. Your help is appreciated. Here are the steps:C code:void plusudf(int *a, int *b, int *result){ *result = *a + *b;}CREATE FUNCTION plusudf( a INTEGER, b INTEGER)RETURNS INTEGERLANGUAGE CNO SQLEXTERNAL NAME 'SS!plusudf!c:\mysrc\plusudf.c'Note - I have tried SL!libcmt! but it did not help. Errors/Warnings reported during compilation------------------------------------------- --------------------------------Microsoft (R) Program Maintenance Utility Version 8.00.50727.762Copyright (C) Microsoft Corporation. All rights reserved. cl /D_CRT_SECURE_NO_DEPRECATE /DWIN32 /GS- -D_USE_32BIT_TIME_T /c /Fosame.obj same.cMicrosoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for80x86Copyright (C) Microsoft Corporation. All rights reserved.same.c cl /D_CRT_SECURE_NO_DEPRECATE /DWIN32 /GS- -D_USE_32BIT_TIME_T /c /FoNCR_new_delete.obj NCR_new_delete.cppMicrosoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for80x86Copyright (C) Microsoft Corporation. All rights reserved.NCR_new_delete.cpp cl /D_CRT_SECURE_NO_DEPRECATE /DWIN32 /GS- -D_USE_32BIT_TIME_T /c /Fopre_plusudf.obj pre_plusudf.cMicrosoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for80x86Copyright (C) Microsoft Corporation. All rights reserved.pre_plusudf.c cl /D_CRT_SECURE_NO_DEPRECATE /DWIN32 /GS- -D_USE_32BIT_TIME_T /Felibudf_0402_0.dll /LD same.obj NCR_new_delete.obj pre_plusudf.obj @FileList udf.lib msvcrt.lib "msvcrt".lib "libcmt".libMicrosoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for80x86Copyright (C) Microsoft Corporation. All rights reserved.cl /link /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libc.libNMAKE : fatal error U1077: '"c:\Program Files\Microsoft Visual Studio 8\VC\bin\cl.EXE"' : return code '0x2'Stop.cufconfig -o :SourceDirectoryPath: C:\Program Files\Teradata\Tdat\tdconfig\Teradata\tdbs_udf\usr\ CompilerTempDirectory: C:\Program Files\Teradata\Tdat\tdconfig\UDFTemp\UDFLibraryPath: C:\Program Files\Teradata\Tdat\tdconfig\udflib\CompilerPath: c:\Program Files\Microsoft Visual Studio 8\VC\bin\CL.EXELinkerPath: c:\Program Files\Microsoft Visual Studio 8\VC\bin\LINK.EXEUDFServerMemPath: C:\Program Files\Teradata\Tdat\tdconfig\udfsrv\ MaximumCompilations: 10UDFServerTasks: 2SecureServerAMPs: 20ParallelUserServerAMPs: 2SecureServerPEs: 20ParallelUserServerPEs: 2TDSPLibBase: C:\Program Files\Teradata\Tdat\tdconfig\tdsplib\ SecureGroupMembership: tdatudfUDFLibPath:UDFIncPath:UDFEnvFile:CLILibPath: c:\Program Files\NCR\Teradata Client\cliv2\libCLIIncPath: c:\Program Files\NCR\Teradata Client\cliv2\incCLIEnvFile:JavaLibraryPath: C:\Program Files\Teradata\Tdat\tdconfig\jarlib\JREPath: C:\Program Files\Java\jre1.6.0_07\JavaLogPath: c:\Temp\JavaEnvFile:JavaServerTasks: 20JavaVersion: 0x10004JavaBaseDebugPort: 0

Adeel Chaudhry 773 posts Joined 04/08
17 Aug 2008

Hello,Can you please provide the whole C code?Regards,Adeel

-- If you are stuck at something .... consider it an opportunity to think anew.

OrangeCrush 2 posts Joined 08/08
18 Aug 2008

The following is the C code I am using for the UDF.void plusudf(int *a, int *b, int *result){ *result = *a + *b;}Thanks

Fred 1096 posts Joined 08/04
19 Aug 2008

May not solve your problem, but that's not a valid prototype for a Teradata UDF. Needs to be something like this (for scalar function with default parameter style TD_GENERAL):#define SQL_TEXT Latin_Text#include void plusudf(INTEGER *a, INTEGER *b, INTEGER *result, char sqlstate[6]){ *result = *a + *b;}

Adeel Chaudhry 773 posts Joined 04/08
19 Aug 2008

Try the following C-code:#define SQL_TEXT Latin_Text#include void plusudf (int *a, int *b, int *result){ *result = *a + *b;}And the following BTEQ script to compile:.LOGON ;CREATE FUNCTION plusudf(a INTEGER,b INTEGER)RETURNS INTEGERLANGUAGE CNO SQLEXTERNAL NAME 'CS!plusudf!c:\mysrc\plusudf.c';.LOGOFF;Running the BTEQ script (bteq ) should compile the UDF.Regards,Adeel

-- If you are stuck at something .... consider it an opportunity to think anew.

Fred 1096 posts Joined 08/04
21 Aug 2008

I see this forum is stripping the header filename in "angle brackets" from the required #include directive. Depending on the path, you may be able to use double quotes. At least this way it should display and show what was meant; you can adjust if needed: #include "sqltypes_td.h"

You must sign in to leave a comment.