During each day of January 2013, I am creating a new video showing you how to use the new C++Builder XE3 compilers for Win32, Win64 and OSX to create multi-platform, database, multi-tier, HD and 3D applications. In this twenty-eight video you’ll learn how to build, install and use an InterBase 64-bit UDF (user defined function) built with the C++Builder 64-bit compiler for Windows. Stay tuned to my blog for additional C++ programming videos each day.
Building the DLL:
1. Create a new Dll Project. File|New|Dynamic Link Library
2. Add a target for Win 64
3. Add a target for Mac OSX. To build for Mac you will need a remote Mac profile setup.
4. Add these 3 files for using ib_util_malloc, as InterBase UDFs using Delphi and C++Builder need to allocate and free memory using the same memory allocation convention.
ib_util.lib for Win32
ib_util64.a for Win64
ib_util.dylib for Mac OSX
5. Add these 2 paths for the compiler include path
C:\ProgramData\Embarcadero\InterBase\rad_xe3\examples is the path for example.h
C:\Program Files (x86)\Embarcadero\RAD Studio\10.0\InterBaseXE3\SDK\include is the path for ib_util.h
6. Because the dll is C++ but the example code is C the code for the .cpp file and the included ib_util.h need to be defined as extern C
7. If the Compiler can't find some header files these are the default locations
C:\ProgramData\Embarcadero\InterBase\rad_xe3\examples is the path for example.h
C:\Program Files (x86)\Embarcadero\RAD Studio\10.0\InterBaseXE3\SDK\include for ib_util.h
Deploying the dll
To Deploy on win32 and Win64 copy IBUDF.dll to the InterBase\UDF directory.
To Deploy on Mac OSX, the file libcgunwind.1.0.dylib must be copied to /usr/lib along with IBUDF.dylib being copied to the InterBase/UDF Directory
Adding the UDF in InterBase - In either isql or with IBConsole execute the following SQL
DECLARE EXTERNAL FUNCTION LOWER
VARCHAR(256) CHARACTER SET NONE
RETURNS CSTRING(80) CHARACTER SET NONE FREE_IT
ENTRY_POINT 'fn_lower_c' MODULE_NAME 'IBUDF';
Using the UDF - In either isql or with IBConsole execute the following SQL
select lower(FIRST_NAME) from employee
January 28, 2013 - Building, installing and using a C++Builder 64-bit InterBase UDF (user defined function)
Filename: 2013-01-28-CppInterBaseUDF64.mp4
Download: http://cc.embarcadero.com/item/29310
Watch on YouTube: http://www.youtube.com/watch?v=asVIl1ttLUk
Duration: 5 minutes and 16 seconds
Size: 15.6mb
Format: MP4
Watch/Download the C++Builder 64-bit Compiler Preview Video
Additional details about the 64-bit C++Builder compiler are available in the preview video. Watch the C++ 64-bit compiler preview video on YouTube at http://www.youtube.com/watch?v=PwwMpBUoR6Y. You can also download the MP4 video file at http://cc.embarcadero.com/item/29197. The preview video is 9 minutes long.
Try the C++Builder 64-bit compiler
The C++Builder XE3 and RAD Studio XE3 free trial downloads have been updated to include the new C++Builder 64-bit compiler. Trial downloads are available at https://downloads.embarcadero.com/free/c_builder
Post a Comment