Build 64bit OCILIB Libraries for CodeBlocks

www.pdf24.org    Send article as PDF   

I tend to compile with gcc, in a bash session, on Windows 7. I use Code::Blocks as my IDE of choice and one of my projects, well, quite a few, use the excellent OCILIB library for accessing Oracle databases, by Vincent Rogier. I can’t recommend this library highly enough.

However, it comes with a Code::Blocks project file to build 32 bit libraries, but I need 64 bits. Here’s how I do it.

None of the following is needed if you use something like Visual C as your compiler. I don’t!

Download the source code

Got to https://github.com/vrogier/ocilib/releases and grab the latest release. Watch out for version 4.6.0 as it will not compile on a system with an Oracle 12.1 client – but I have a fix. Version 4.6.1 (when it’s available) has the fix built in.

You need the file ocilib-x.x.x-windows.zip, so download it to wherever you keep your source files, and unzip it.

Amend the Supplied Project File

There is a project file called proj\mingw\ocilib_static_lib_mingw.cbp, so open that in Code::Blocks. You will notice that it has two options – ‘Release – ANSI’ and ‘Release – UNICODE’. I use the ANSI version, but the following gives instructions for both.

The project as supplied uses the built in compiler which is a 32 bit only, version of gcc. My system has a separately installed version that compiles 32 and 64 bit applications. So I need to change the existing targets to use my compiler instead of the built in one.

Change the Default Compiler

Go to Project -> Build Options.

Select the top level ocilib_static_lib_mingw option on the left. Do not select either of the two release targets at this stage.

The default, built in 32 bit, compiler is named ‘GNU GCC Compiler’ I need to change this to ‘GNU GCC Compiler 32/64bit (TDM-GCC-64)’ which is the name my separately installed compiler is called. If you are prompted to save the settings, choose ‘Yes’ then ‘OK’ on all the remaining dialogues that pop-up. Finally, ‘OK’ your way back to the main screen.

The compiler has now been changed for all targets currently defined. Now, to add the new 64 bit targets.

Add 64bit Targets.

Go to Project -> Properties and select the ‘Build targets’ tab.

Select ‘Release – ANSI’ on the left and click the ‘Duplicate’ button, change the name to ‘Release 64bit – ANSI’ and ‘OK’.

Select the new target, if not already selected.

Under the ‘Output filename’ option, towards the right side, change the ‘lib32’ to ‘lib64’. Everything else remains the same.

Now repeat the above to create the ‘Release 64bit – UNICODE’ target, and ‘OK’ back to the main screen.

That now gives us 4 targets, but they are all 32 bit at present. We now need to change the compiler options.

Change the Compiler Options

Go to Project -> Build Options and select the very top of the tree – ocilib_static_lib_mingw. Do not select any of the sub-targets, yet.

On the ‘Compiler settings’ tab, scroll down the options list and make sure that both ‘Target X86 (32bit)’ and ‘Target X86 (64bit)’ are unselected.

Click ‘Release – ANSI’ on the left, and select ‘Target X86 (32bit)’.

Click ‘Release – UNICODE’ on the left, and select ‘Target X86 (32bit)’. Select ‘yes’ if prompted to save changes.

Click ‘Release 64bit – ANSI’ on the left, and select ‘Target X86 (64bit)’. Select ‘yes’ if prompted to save changes.

Click ‘Release 64bit – UNICODE’ on the left, and select ‘Target X86 (64bit)’. Select ‘yes’ if prompted to save changes.

Now ‘OK’ back to the main screen.

Build the Libraries

Now that we have 4 targets, it’s time to build the different libraries. In the main screen, select each of the 4 targets in turn, and then select Build -> Rebuild to make sure that any existing versions are rebuilt with the new compiler and options.

When done, there should be two new files in each of the lib32 and lib64 folders, these will be named libociliba.a and libocilibw.a.

Fix 4.6.0 Errors

If you get an error about OCI_ATTR_COL_PROPERTY_IS_CONID then you need to apply the following fix if release 4.6.1 is not yet available.

Edit the file src/column.c and change the code to the following at lines 260 onwards – there’s only two lines to add.

  259             if (value & OCI_ATTR_COL_PROPERTY_IS_GEN_BY_DEF_ON_NULL)
260 {
261 col->props |= OCI_CPF_IS_GEN_BY_DEFAULT_ON_NULL;
262 }
263
264 #if OCI_VERSION_COMPILE >= OCI_18_1
265
266 if (value & OCI_ATTR_COL_PROPERTY_IS_LPART)
267 {
268 col->props |= OCI_CPF_IS_LPART;
269 }
270
271 if (value & OCI_ATTR_COL_PROPERTY_IS_CONID)
272 {
273 col->props |= OCI_CPF_IS_CONID;
274 }
275 #endif
276
277 }
278 }

All that is required is to add the two lines numbered 264 and 275 above, but not the line numbers please! You should now be able to compile the code.

Job done, I can now build 32 and 64 bit versions of my applications to access the databases.

Useful AIX Unix Commands

www.pdf24.org    Send article as PDF   

proctree

The proctree command acts like the Linux pstree and displays the hierarchy of processes from a given starting process id.

View Large Files

If, when you view a large file you get an errors about it being too big, try the following:

echo "set ll=3501720 dir=/tmp" >> ~/.exrc

That will allow you to read up to 3501720 lines in a single text file.

Generate Entity Relationship Diagrams from a SQL Script.

Sometimes, just occasionally, you find yourself as a DBA on a site where, for some strange and unknown reason, you don’t have an Entity Relationship Diagram (ERD) for the database that you are working on. You could use a tool such as Toad, or SQL*Plus (or even, SQL Developer – if you must) to generate a list of referential integrity constraints. There has to be a better way. Continue reading Generate Entity Relationship Diagrams from a SQL Script.

Snorkelling in the Oracle Listener Logs.

(Snorkelling is not quite as in depth as a “deep dive”!)

Attempting to parse a listener.log will probably bend your brain, but I needed to do it recently to determine which unique servers and/or desktops and/or application servers were still connecting to a database prior to that database going down for maintenance. This was an exercise in confirming that the documentation we have, is correct.

Continue reading Snorkelling in the Oracle Listener Logs.

Arduino Nano – Cannot Upload Sketches after Board Upgrade to 1.6.21

www.pdf24.org    Send article as PDF   

My Arduino Nano started to refuse to upload sketches after I upgraded the boards library to version 1.6.21 from 1.6.20. All I got was this:

...
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
...

Repeat 100 times!

After reverting back to the previous boards library, version 1.6.20, everything worked. I upgraded and everything stopped working.

The solution, from the arcduino.cc forums, is simple:

Tools -> Processor -> ATmega328P (Old Bootloader)

Read the forum thread at https://forum.arduino.cc/index.php?topic=532983.0 if you wish. I’m just noting this here for my own reference and definitely not claiming any credit.

Using FUSE to Mount an SSH Folder Locally

I have recently come across a pretty nifty Linux utility that allows me to mount a remote filesystem on an SSH server, locally and without requiring root privileges to do so. The remote filesystem happens to be where my backups are located, so that’s going to be useful for making and restoring backups! Continue reading Using FUSE to Mount an SSH Folder Locally

FLAC to MP3 as Easy as Pie!

I have ripped all my music, well most of it, to FLAC for the quality aspect. Sometimes though, I need to convert to MP3 for some of the lesser audio players out there that I might have to use from time to time.

I have recently come across a pretty nifty (Linux) way to do this, without having to cope with having duplicate files in FLAC and MP3 formats on my hard drives. Continue reading FLAC to MP3 as Easy as Pie!