Linker error in Database connectivity..

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2006
Posts: 5
Reputation: Sivakumar_K is an unknown quantity at this point 
Solved Threads: 0
Sivakumar_K Sivakumar_K is offline Offline
Newbie Poster

Linker error in Database connectivity..

 
0
  #1
Oct 3rd, 2006
Hello Group,

I am looking for some help with DevC++ compiler. Version 4.9.9.2. In my database Management II Course, we are supposed to compile a sample ODBC Application written in C Code. When I open the compiler, I cut and pasted the code into the work space because the code is rather long. I've read in other C forum that the error messages I am getting is due to a linkage problem with SQL libraries. Can someone explain the proper steps to fixing this problem of my. I have been trying to figure this out for the past 5 days and could not seem to find a good manuel or tutorial about SQL Libraries and how to link them. Here is the error messages I am getting:



Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\Makefile.win"
Executing make...
make.exe -f "C:\Dev-Cpp\Makefile.win" all
gcc.exe main.o -o "Sample.c" -L"C:/Dev-Cpp/lib"
main.o(.text+0x72):main.c: undefined reference to `SQLGetDiagField@28'
main.o(.text+0xe2):main.c: undefined reference to `SQLGetDiagRec@32'
main.o(.text+0x1c0):main.c: undefined reference to `SQLAllocHandle@12'
main.o(.text+0x1f8):main.c: undefined reference to `SQLSetEnvAttr@16'
main.o(.text+0x227):main.c: undefined reference to `SQLAllocHandle@12'
main.o(.text+0x26b):main.c: undefined reference to `SQLConnect@28'
main.o(.text+0x2a5):main.c: undefined reference to `SQLAllocHandle@12'
main.o(.text+0x323):main.c: undefined reference to `SQLPrepare@12'
main.o(.text+0x3bd):main.c: undefined reference to `SQLBindParameter@40'
main.o(.text+0x457):main.c: undefined reference to `SQLBindParameter@40'
main.o(.text+0x4f1):main.c: undefined reference to `SQLBindParameter@40'
main.o(.text+0x58b):main.c: undefined reference to `SQLBindParameter@40'
main.o(.text+0x61d):main.c: undefined reference to `SQLExecute@4'
main.o(.text+0x6b9):main.c: undefined reference to `SQLPrepare@12'
main.o(.text+0x753):main.c: undefined reference to `SQLBindParameter@40'
main.o(.text+0x7b9):main.c: undefined reference to `SQLExecute@4'
main.o(.text+0x80c):main.c: undefined reference to `SQLBindCol@24'
main.o(.text+0x844):main.c: undefined reference to `SQLBindCol@24'
main.o(.text+0x859):main.c: undefined reference to `SQLFetch@4'
main.o(.text+0x8db):main.c: undefined reference to `SQLEndTran@12'
main.o(.text+0x8fb):main.c: undefined reference to `SQLFreeHandle@8'
main.o(.text+0x90f):main.c: undefined reference to `SQLDisconnect@4'
main.o(.text+0x92f):main.c: undefined reference to `SQLFreeHandle@8'
main.o(.text+0x94b):main.c: undefined reference to `SQLFreeHandle@8'
collect2: ld returned 1 exit status
make.exe: *** [Sample.c] Error 1
Execution terminated





Here is the code i am using

#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <odbcinst.h>
#include <sql.h>
#include <sqlext.h>
#include <sqltypes.h>


int main()
{

SQLHENV env;
SQLHDBC dbc;
SQLHSTMT stmt;
SQLRETURN ret; /* ODBC API return status */
SQLSMALLINT columns; /* number of columns in result-set */
int row = 0;

/* Allocate an environment handle */
SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
/* We want ODBC 3 support */
SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0);
/* Allocate a connection handle */
SQLAllocHandle(SQL_HANDLE_DBC, env, &dbc);
/* Connect to the DSN mydsn */
/* You will need to change mydsn to one you have created and tested */
SQLDriverConnect(dbc, NULL, "DSN=shruthiks;", SQL_NTS,
NULL, 0, NULL, SQL_DRIVER_COMPLETE);
/* Allocate a statement handle */
SQLAllocHandle(SQL_HANDLE_STMT, dbc, &stmt);
/* Retrieve a list of tables */
SQLTables(stmt, NULL, 0, NULL, 0, NULL, 0, "TABLE", SQL_NTS);
/* How many columns are there */
SQLNumResultCols(stmt, &columns);
/* Loop through the rows in the result-set */
while (SQL_SUCCEEDED(ret = SQLFetch(stmt)))
{
SQLUSMALLINT i;
printf("Row %d\n", row++);
/* Loop through the columns */
for (i = 1; i <= columns; i++)
{
SQLINTEGER indicator;
char buf[512];
/* retrieve column data as a string */
ret = SQLGetData(stmt, i, SQL_C_CHAR,
buf, sizeof(buf), &indicator);
if (SQL_SUCCEEDED(ret))
{
/* Handle null columns */
if (indicator == SQL_NULL_DATA) strcpy(buf, "NULL");
printf(" Column %u : %s\n", i, buf);
}
}
}
}


Can any one tell what could be the problem for those linker erros.

Give me a some explanation regarding this.....

Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,342
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1460
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning

Re: Linker error in Database connectivity..

 
0
  #2
Oct 3rd, 2006
looks like a missing library. you probably need to add libodbccp32.a to library list.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 5
Reputation: Sivakumar_K is an unknown quantity at this point 
Solved Threads: 0
Sivakumar_K Sivakumar_K is offline Offline
Newbie Poster

Re: Linker error in Database connectivity..

 
0
  #3
Oct 4th, 2006
I added the particular library.. But still Linker error is coming..

please any one tell the correct way to solve this problem..

please explain clearly..
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,342
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1460
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning

Re: Linker error in Database connectivity..

 
0
  #4
Oct 4th, 2006
I just successfully linked you program using these libraries:

lib/libodbc32.a
lib/libodbccp32.a


To add then to the project, use menu Project --> Project Options --> hit the Parameters tab, then put the library names in the Linker box.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC