| | |
Linker error in Database connectivity..
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2006
Posts: 5
Reputation:
Solved Threads: 0
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.....
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.....
![]() |
Similar Threads
- Database Connectivity in C (C)
- facing problem in database connectivity in jsp to mysql (JSP)
- Dev-C++, GLUI linker error, undefined reference (C++)
- Linker Error when program is run (Urgent help required Please") (C++)
Other Threads in the C++ Forum
- Previous Thread: Operator Overloading Question
- Next Thread: Difficulty with IO
| Thread Tools | Search this Thread |
api array based beginner bitmap c++ c/c++ calculator char class classes code coding compile compiler console conversion count database delete deploy desktop developer directshow dll download dynamic email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news node number output parameter pointer problem program programming project python random read recursion recursive return sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






