Problem is the same for Release mode, i.e. the program ran OK from commandline and failed from Run menu in codeblocks.
I have written a minimal test program in main.cpp that shows the problem. This (small as program, but a bit long as text in a post):
#include <stdio.h>
#include <string.h>
#include "sql.h"
#include "sqlext.h"
static void dspmessage ( const char * title , const char * msg )
   {
   printf ( "%s: %s " , title , msg ) ;
   printf ( "Press Return/Enter to continue\n" ) ;
   getchar ( ) ;  //to wait
   }
static void sqlerrinfo ( int handletp , int handle , const char * logstring )
   {
   char txt [ 4002 ] ;
   int maxlen = 4000 ;
   int ofs = sprintf ( txt , "%s\n" , logstring ) ;
   int recnbr = 1;
   long nerr ;
   short lenerrmsg ;
   int ln ;
   unsigned char state [ 12 ] = { 0 } ;
   unsigned char msg [ SQL_MAX_MESSAGE_LENGTH+1 ] = { 0 } ;
   char line [ 802 ] = { 0 } ;
   int rc = SQL_SUCCESS ;
   while ( rc != SQL_NO_DATA_FOUND)
      {
      rc = SQLGetDiagRec ( handletp , (SQLHANDLE)handle , recnbr ,
                           state, &nerr , msg , SQL_MAX_MESSAGE_LENGTH ,
                           &lenerrmsg ) ;
      ln = sprintf ( line , "%d: st=%s, nerr=%d, msg=\n%s\n" ,
                     recnbr , state , (int)nerr , msg ) ;
      if ( ln+ofs < maxlen )
         {
         strcpy ( txt+ofs , line ) ;
         ofs += ln ;
         }
      else
         {
         break ;
         } ;
      recnbr++; // for next diagnostic record.
      }
   dspmessage ( "usage error" , txt ) ;
   }
static bool success ( SQLRETURN rc )
   {
   return (rc == SQL_SUCCESS) || (rc == SQL_SUCCESS_WITH_INFO) ;
   }
static bool connectSrv ( const char * dsn , const char * uid , const char * pwd )
   {
   SQLHENV henv;
   SQLRETURN rc = SQLAllocHandle ( SQL_HANDLE_ENV , SQL_NULL_HANDLE , &henv ) ;
   if ( !success ( rc ) )
      {
      dspmessage ( "sqlapi" , "SQLAllocHandle Env failed" ) ;
      return false ;
      }
   rc = SQLSetEnvAttr ( henv, SQL_ATTR_ODBC_VERSION , (void*)SQL_OV_ODBC3 , 0 ) ;
   if ( !success ( rc ) )
      {
      sqlerrinfo ( SQL_HANDLE_ENV , (int)henv , "Set ODBC version fail" ) ;
      SQLFreeEnv ( henv ) ;
      return false ;
      } ;
   SQLHDBC hdbc;
   rc = SQLAllocHandle ( SQL_HANDLE_DBC , henv , &hdbc ) ;
   if ( !success ( rc ) )
      {
      sqlerrinfo ( SQL_HANDLE_ENV , (int)hdbc , "Alloc connection handle error" ) ;
      SQLFreeEnv ( henv ) ;
      return false ;
      } ;
   SQLSetConnectAttr ( hdbc , SQL_LOGIN_TIMEOUT , (void*)5 , 0 ) ;
   char msg [ 100 ] ;
   rc = SQLConnect ( hdbc , (SQLCHAR*)dsn , SQL_NTS,
                      (SQLCHAR*) uid , SQL_NTS,
                      (SQLCHAR*) pwd , SQL_NTS);
   if ( !success ( rc ) )
      {
      sprintf ( msg , "SQLConn: dsn=%s user=%s pwd=%s\n" , dsn , uid , pwd ) ;
      sqlerrinfo ( SQL_HANDLE_DBC , (int)hdbc , msg ) ;
      SQLFreeConnect ( hdbc ) ;
      SQLFreeEnv ( henv ) ;
      dspmessage ( "sqlapi" , "SQLConnect failed" ) ;
      return false ;
      } ;
   SQLHSTMT hstmt;
   rc = SQLAllocHandle ( SQL_HANDLE_STMT , hdbc , &hstmt);
   if ( !success ( rc ) )
      {
      sqlerrinfo ( SQL_HANDLE_DBC , (int)hdbc , "Alloc Stmt error" ) ;
      SQLDisconnect ( hdbc ) ;
      SQLFreeConnect ( hdbc ) ;
      SQLFreeEnv ( henv ) ;
      return false ;
      } ;
   return true ;
   }
int main ( int argc , char * argv[] )
   {
   if ( connectSrv ( "TestDBDSN"  , "hr" , "hr" ) )
      {
      dspmessage ( "sqlapi" , "ODBC Connect OK\n" ) ;
      }
   return 0 ;
   }
I am using unixODBC 2.2.11-16build2 available via Synaptic package Manager in Ubuntu 8.10. The sql header files are from the Include directory of the installed unixODBC. The unixODBC is in usr/lib/libodbc.so.1 and is linked using local linker settings section in codeblocks. There are no global linker settings.
The oracle ODBC driver is in /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib/libsqora.so.10.1 
I have added the following to the Ubuntu startup script: 
#  Added by ken for oracle
ODBCINI=/etc/odbc.ini
export ODBCINI
ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server
export ORACLE_HOME
TNS_ADMIN=$ORACLE_HOME/network/admin
export TNS_ADMIN
LD_LIBRARY_PATH=/usr/lib:/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib
export LD_LIBRARY_PATH
Earlier on I had exactly the same error when I had set the LD_LIBRARY_PATH incorrectly, but it is correct now. Is there any possibility of codeblocks disturbing the LD_LIBRARY_PATH value? OR is there anything that I may have done wrong when setting up the project that might cause this? 
To summarise:
 THISAPP + unixODBC in Debug mode OK on commandline
 THISAPP + unixODBC in Release mode OK on commandline
 THISAPP + unixODBC + CodeBlocks Start in Debug mode fails to load the Oracle ODBC driver
   APP + unixODBC + CodeBlocks Run in Release mode fails to load the Oracle ODBC driver
What else can I do to try to pinpoint the problem?