473,387 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

sqlext.h - ODBC link time error - dev-c++ IDE with mingw compiler

trying the following code to test SQL connection to MS SQL server using
machine DNS name.

receiving errors:
[linker error] undefined reference to 'SQLAllocEnv@4'
[linker error] undefined reference to 'SQLAllocConnect@8'
(etc. for all SQL function calls in the code)

using Dev-C++ 4.9.9.2 and the latest mingw WindowsAPI package (where
the sql header files are)

I've found others who have had the same problem, but no solution -
going nuts!

test code:

#include <windows.h>
#include <sqlext.h>
#include <cstdlib>
#include <iostream>

int main(int argc, char *argv[])
{
HENV hEnv = NULL; // Env Handle from SQLAllocEnv()
HDBC hDBC = NULL; // Connection handle
HSTMT hStmt = NULL;// Statement handle
UCHAR szDSN[SQL_MAX_DSN_LENGTH] = "mydsn";// Data Source Name
buffer
UCHAR szUID[13] = "username";// User ID buffer
UCHAR szPasswd[7] = "passwd";// Password buffer
UCHAR szModel[128];// Model buffer
SDWORD cbModel;// Model buffer bytes recieved
UCHAR szSqlStr[128]= "SELECT test FROM testtable where test =
'test_success'";

RETCODE retcode;

// Allocate memory for ODBC Environment handle
SQLAllocEnv (&hEnv);

// Allocate memory for the connection handle
SQLAllocConnect (hEnv, &hDBC);

// Connect to the data source "szDSN" using userid and password.
retcode = SQLConnect (hDBC, szDSN, SQL_NTS, szUID, SQL_NTS, szPasswd,
SQL_NTS);

if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
{
// Allocate memory for the statement handle
retcode = SQLAllocStmt (hDBC, &hStmt);

// Prepare the SQL statement by assigning it to the statement
handle
retcode = SQLPrepare (hStmt, szSqlStr, sizeof (szSqlStr));

// Execute the SQL statement handle
retcode = SQLExecute (hStmt);

// Project only column 1 which is the models
SQLBindCol (hStmt, 1, SQL_C_CHAR, szModel, sizeof(szModel),
&cbModel);

// Get row of data from the result set defined above in the
statement
retcode = SQLFetch (hStmt);

// Free the allocated statement handle
SQLFreeStmt (hStmt, SQL_DROP);

// Disconnect from datasource
SQLDisconnect (hDBC);
}

std::cout << retcode << "\n";

// Free the allocated connection handle
SQLFreeConnect (hDBC);

// Free the allocated ODBC environment handle
SQLFreeEnv (hEnv);
system("PAUSE");
return EXIT_SUCCESS;
}

Aug 28 '05 #1
3 10205
mike wrote:
trying the following code to test SQL connection to MS SQL server using
machine DNS name.

receiving errors:
[linker error] undefined reference to 'SQLAllocEnv@4'
[linker error] undefined reference to 'SQLAllocConnect@8'
(etc. for all SQL function calls in the code)


This is off-topic here. Try an MSSQL group.

It looks like you're missing a library in your link phase.
Aug 28 '05 #2
This is actually a well known mingw problem with DLLs, and its
relatively simple to fix. People who use MySQL know this problem well:

http://www.emmestech.com/software/cy...43/moron1.html

http://mywebpage.netscape.com/yongweiwu/stdcall.htm

http://dev.mysql.com/doc/mysql/en/wi...compiling.html

http://lists.trolltech.com/qt-intere...ad00014-0.html

see ya
Paul

Aug 29 '05 #3
I was able to figure it out based on the sources you referenced. Thank
you very much.

Aug 30 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Andreas Lauffer | last post by:
I changed from Access97 to AccessXP and I have immense performance problems. Details: - Access XP MDB with Jet 4.0 ( no ADP-Project ) - Linked Tables to SQL-Server 2000 over ODBC I used...
2
by: yopwojtek | last post by:
Witam, piszę program dialogowy w VC7 z uzyciem MFC. mam osobna klase ktora odpowiada za polaczenie ODBC, i chcialem korzystac nie z MFC w tym wypadku a z API i includowac plik sqlext.h i sql.h....
2
by: yopwojtek | last post by:
HI All, i'm writting dialogue programm using VC& and MFC. there is class to connecting with datavase trought ODBC. in case of that class i would like to use only API functions from headers...
11
by: DJJ | last post by:
I am using the MySQL ODBC 3.51 driver to link three relatively small MySQL tables to a Microsoft Access 2003 database. I am finding that the data from the MySQL tables takes a hell of a long time...
8
by: Dominic Martin | last post by:
Hi, I need to setup an ODBC link over our Internet connection between MS Access (local) and a MySQL server (Remote - the local PC has the MySQL ODBC driver installed). What kind of bandwidth...
12
by: Remco Groot Beumer | last post by:
Hello all, Currently we are implementing an Access database which has to send some (not much) data over a WAN. We are using an Access front end and an Access back end. Basicly the front end runs...
0
by: Me | last post by:
Hi all, Each new login to the PC, all the ODBC links to the SQL Server tables fail with the error "Connection failed" SQL Server Error 10061 Connection Open (connect()) Connection failed:
4
by: David Siroky | last post by:
Hi! I'm trying to connect to a MDB file via ODBC like this: char *DSN = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\\dev-cpp\\test\\1.mdb"; SQLAllocEnv(&env); SQLAllocConnect(env,...
2
by: SKB | last post by:
Hi, I am absolutely new to this area. I am getting the following difficulty : Access denied for user 'ODBC'@'localhost' (using password: NO) when I try the mysql command from within the...
7
by: ApexData | last post by:
Hello I currently Link the FE/BE using the LinkTables Option and the Linked Table Manager. Any time I need to move the BE to another location, I have to go through this process over again. I...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.