Build 64bit OCILIB Libraries for CodeBlocks    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 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, 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 }
267 {
268 col->props |= OCI_CPF_IS_LPART;
269 }
272 {
273 col->props |= OCI_CPF_IS_CONID;
274 }
275 #endif
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.

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.

Dropping Temporary Tables (With Bonus, Broken Check Constraints!)

I found a broken check constraint, one that simply wouldn’t work, on a database. It was created as:


Try it yourself, it doesn’t work! Anyway, I needed to find if there were any other check constraints broken in this manner, so I did the following:

Continue reading Dropping Temporary Tables (With Bonus, Broken Check Constraints!)