[unixODBC-dev] Urgent Help: undefined reference errors

sythan shweyeesyt at yahoo.com
Mon Mar 10 03:55:48 GMT 2008


Hi,

I'm just new to Linux OS and ODBC. Could you pls tell me how to link odbc
(-lodbc) to gcc?
Thanks.

Regars,
SYT


Hor Meng Yoong wrote:
> 
> Hi:
> 
>   You need to ask gcc to link with odbc (-lodbc)
> 
> Regards
> Hor Meng
> 
> On Mon, Mar 10, 2008 at 9:44 AM, Shwe Yee Than <shweyeesyt at yahoo.com>
> wrote:
>> Hello,
>>
>>  I'm using unixODBC 2.2.12 and trying to compile the following program
>> and
>> got some errors.  I have been trying to solve this problem for about 2
>> weeks
>> already. Can anyone help me?
>>
>>  #include <stdio.h>
>> #include "/usr/local/easysoft/unixODBC/include/sql.h"
>> #include "/usr/local/easysoft/unixODBC/include/sqlext.h"
>>
>> main() {
>>  SQLHENV env;
>>  char driver[256];
>>  char attr[256];
>>  SQLSMALLINT driver_ret;
>>  SQLSMALLINT attr_ret;
>>  SQLUSMALLINT direction;
>>  SQLRETURN ret;
>>
>>  SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
>>  SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0);
>>
>>  direction = SQL_FETCH_FIRST;
>>  while(SQL_SUCCEEDED(ret = SQLDrivers(env, direction,
>>  driver, sizeof(driver), &driver_ret,
>>  attr, sizeof(attr), &attr_ret))) {
>>  direction = SQL_FETCH_NEXT;
>>  printf("%s - %s\n", driver, attr);
>>  if (ret == SQL_SUCCESS_WITH_INFO) printf("\tdata truncation\n");
>>  }
>> }
>>  The compilation and the output is as follows:
>>
>>  [root at fsktm src]$ gmake
>>  gcc -g -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
>> -DPORTNAME_linux -DPARA_OPR=1 -DFED_MCAT -DPORTNAME_linux -DFED_MCAT
>> -I./include -I/home/srb/SRB3_4_2/src/include
>> -I/home/srb/SRB3_4_2/src/catalog/include
>> -I/home/srb/SRB3_4_2/utilities/include   -c -o alpha1.o alpha1.c
>>  gcc -c sample_main.c -g -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
>> -D_LARGEFILE64_SOURCE -DPORTNAME_linux -DPARA_OPR=1 -DFED_MCAT
>> -DPORTNAME_linux -DFED_MCAT -I./include -I/home/srb/SRB3_4_2/src/include
>> -I/home/srb/SRB3_4_2/src/catalog/include
>> -I/home/srb/SRB3_4_2/utilities/include
>>  gcc alpha1.o sample_main.o -o etd.cgi
>> /home/srb/SRB3_4_2/utilities/obj/srbClientUtil.o -L/home/srb/SRB3_4_2/obj
>> -lSrbClient -lm -lpthread
>>  undefined reference to `SQLAllocHandle'
>>  undefined reference to `SQLSetEnvAttr'
>>  undefined reference to `SQLDrivers'
>>  collect2: ld returned 1 exit status
>>  gmake: *** [etd.cgi] Error 1
>>
>>  Really appreciate for the helping hands.
>>
>>  With Regards,
>>  SYT
>>
>>
>>  ________________________________
>> Never miss a thing. Make Yahoo your homepage.
>> _______________________________________________
>>  unixODBC-dev mailing list
>>  unixODBC-dev at easysoft.com
>>  http://mail.easysoft.com/mailman/listinfo/unixodbc-dev
>>
>>
> _______________________________________________
> unixODBC-dev mailing list
> unixODBC-dev at easysoft.com
> http://mail.easysoft.com/mailman/listinfo/unixodbc-dev
> 
> 

-- 
View this message in context: http://www.nabble.com/Urgent-Help%3A-undefined-reference-errors-tp15949441p15950486.html
Sent from the unixODBC - Dev mailing list archive at Nabble.com.




More information about the unixODBC-dev mailing list