Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C Moderated > Linking error (...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 6 Topic 1056 of 1099
Post > Topic >>

Linking error (cygwin, make, windows, sql)

by PG <gosavip@[EMAIL PROTECTED] > Mar 8, 2008 at 12:21 PM

I am trying to compile a simple ODBC and C example on Windows XP SP2.
I have Cygwin_NT 5.1.

This is the code (obtained from
http://www.easysoft.com/developer/languages/c/odbc_tutorial.html#dm_f...)
i am attempting to compile.

ODBCTest.c

#include <stdio.h>
#include <windows.h>
#include <sql.h>
#include <sqlext.h>

main() {
  SQLHENV env;
  char dsn[256];
  char desc[256];
  SQLSMALLINT dsn_ret;
  SQLSMALLINT desc_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 = SQLDataSources(env, direction,
                                           dsn, sizeof(dsn), &dsn_ret,
                                           desc, sizeof(desc),
&desc_ret))) {
    direction = SQL_FETCH_NEXT;
    printf("%s - %s\n", dsn, desc);
    if (ret == SQL_SUCCESS_WITH_INFO) printf("\tdata truncation\n");
  }

}

Makefile

CC=gcc
INCPATH=-I/usr/include  -Iinclude
LIBS=-L. -lodbc32
LD=ld
all: clean ODBCTest.exe

ODBCTest.o : ODBCTest.c
        $(CC) $(INCPATH)  $(CFLAGS) -o ODBCTest.o -c ODBCTest.c
ODBCTest.exe :  ODBCTest.o
        $(CC)  $(LIBS) $(CFLAGS) -o ODBCTest.exe ODBCTest.o
clean:
        -rm *.o
        -rm *.exe


Make output and Errors:

$ make
rm *.o
rm *.exe
rm: cannot remove `*.exe': No such file or directory
make: [clean] Error 1 (ignored)
gcc -I/usr/include  -Iinclude   -o ODBCTest.o -c ODBCTest.c
gcc  -L. -lodbc32  -o ODBCTest.exe ODBCTest.o
ODBCTest.o:ODBCTest.c:(.text+0x4a): undefined reference to
`_SQLAllocHandle@[EMAIL PROTECTED]
'
ODBCTest.o:ODBCTest.c:(.text+0x70): undefined reference to
`_SQLSetEnvAttr@[EMAIL PROTECTED]
'
ODBCTest.o:ODBCTest.c:(.text+0xca): undefined reference to
`_SQLDataSources@[EMAIL PROTECTED]
'
collect2: ld returned 1 exit status
make: *** [ODBCTest.exe] Error 1


Things i have checked:
libodbc32.a exists in c:\cygwin\lib\w32api.
If i remove the above lib, i get a "lib not found" kind of error when
i run make, meaning this is the lib make is using and there is no path
issue.
if i edit libodbc32.a in a binary editor, i can see the all the three
functions mentioned in the error (_SQLAllocHandle@[EMAIL PROTECTED]
 and _SQLDataSources@[EMAIL PROTECTED]
) exist.

How can i fix these linking errors?

Thanks

PG
-- 
comp.lang.c.moderated - moderation address: clcm@[EMAIL PROTECTED]
 -- you must
have an appropriate newsgroups line in your header for your mail to be
seen,
or the newsgroup name in square brackets in the subject line.  Sorry.




 6 Posts in Topic:
Linking error (cygwin, make, windows, sql)
PG <gosavip@[EMAIL PRO  2008-03-08 12:21:40 
Re: Linking error (cygwin, make, windows, sql)
Ian Collins <ian-news@  2008-03-17 15:18:53 
Re: Linking error (cygwin, make, windows, sql)
Flash Gordon <spam@[EM  2008-03-17 15:20:32 
Re: Linking error (cygwin, make, windows, sql)
Barry Schwarz <schwarz  2008-03-17 15:21:27 
Re: Linking error (cygwin, make, windows, sql)
John Bode <john_bode@[  2008-03-20 01:09:41 
Re: Linking error (cygwin, make, windows, sql)
John Bode <john_bode@[  2008-03-20 01:09:43 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed May 14 6:40:48 CDT 2008.