473,379 Members | 1,235 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,379 software developers and data experts.

ODBC link-time error

Hi,
I've got some problems using ODBC with C++.

First, I use Dev-cpp with gcc/g++ v3.4.2 on Win XP.
I got to connect to a system DSN installed on my computer so I use the
standard SQL API provided with my compiler.
Here is a code snippet from my sources :

#include <windows.h>
#include <iostream>
#include <sql.h>
#include <sqlext.h>
#include <sqltypes.h>
#include <odbcinst.h>
#include <sqlucode.h>
#define STR_LEN 30
#define _DEBUG 1
#if _DEBUG
#define DEBUG(str) cout<<str<<endl;
#else
#define DEBUG(str)
#endif

SQLHENV henv; /* environment handle */
SQLHDBC hdbc; /* connection handle */
HSTMT hstmt; /* statement handle */
SDWORD retcode; /* return code */
UCHAR info[STR_LEN]; /* info string for SQLGetInfo
*/
SQLSMALLINT inf;
int main(void){
retcode = SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&hen v);
retcode = SQLAllocConnect(henv,&hdbc);
retcode = SQLConnect(hdbc, (SQLCHAR*)"SAGE_GESCOM", SQL_NTS,
(SQLCHAR*)"Mo", SQL_NTS, (SQLCHAR*)"",SQL_NTS);
retcode = SQLGetInfo(hdbc,SQL_DBMS_VER, &info, STR_LEN,&inf);

printf("Current DBMS version is %s\n", info);

SQLDisconnect(hdbc);
SQLFreeConnect(hdbc);
SQLFreeEnv(henv);
return 0;
}

As you can see, this code is very simple. It's purpose is to connect to
a given DSN (SAGE_GESCOM), with a given userid (Mo) and a given
password (\0). IMO it should work fine, if only I could manage to
compile and link it !

Here are the command lines for compiling and linking and the errors I
get from the linker :

g++.exe -c main.cpp -o main.o
-I"C:/Dev-Cpp5/lib/gcc/mingw32/3.4.2/include"
-I"C:/Dev-Cpp5/include/c++/3.4.2/backward"
-I"C:/Dev-Cpp5/include/c++/3.4.2/mingw32"
-I"C:/Dev-Cpp5/include/c++/3.4.2" -I"C:/Dev-Cpp5/include"

g++.exe main.o -o "sageedi.exe" -L"C:/Dev-Cpp5/lib"
main.o(.text+0x142):main.cpp: undefined reference to
`SQLAllocHandle@12'
main.o(.text+0x160):main.cpp: undefined reference to
`SQLAllocConnect@8'
main.o(.text+0x1a6):main.cpp: undefined reference to `SQLConnect@28'
main.o(.text+0x1dc):main.cpp: undefined reference to `SQLGetInfo@20'
main.o(.text+0x206):main.cpp: undefined reference to `SQLDisconnect@4'
main.o(.text+0x216):main.cpp: undefined reference to `SQLFreeConnect@4'
main.o(.text+0x226):main.cpp: undefined reference to `SQLFreeEnv@4'
collect2: ld returned 1 exit status

Cannot understand why the linker spits such errors. The libraries I
have in my C:/Dev-Cpp5/lib directory are :
libodbccp32.a
libodbc32.a

I guess a library is missing in this dir, but I don't know which and
where to retrieve it.

Any help welcome,
Regards,

Mohamed Rambil

Jul 23 '05 #1
0 2776

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

Similar topics

1
by: Lyle Fairfield | last post by:
I created a new MS-SQL Database, "TestODBC". I made Table1 and StoredProcedure1. I made an ODBC DSN for that MS-SQL Database. I created a new AccessXP mdb, "TestODBC". I linked to the...
13
by: Eric E | last post by:
Two questions regarding ODBC. 1) I am connecting to a MySQL database using the following code: Function LoginToMySQL(sUsername As String, sPW As String) As Boolean Dim dbMySQL As Database Dim...
1
by: Salad | last post by:
Hi: I am developing an application using FoxPro 2.x tables. My client has AccessXP. AccessXP uses Visual Foxpro ODBC to connect to tables. It does not accept the ISAM Foxpro driver used in A97....
4
by: Phil Latio | last post by:
Scenario is: We have an intranet on which a Helpdesk application can be accessed. Data input into the Helpdesk is stored in a Access 2000 database, held on a server. This is great, works fine,...
0
by: Kris | last post by:
hi, if have the following problem: i have two (informix-)odbc connections i need to work with. link the first one, choosing my tables. open them - fine! link the second one, choosing my...
1
by: RLN | last post by:
RE: Access 2003 using WinXP SP2 Problem: When I start up my app I double click either one of my two Oracle tables in the table list, it asks for an id and pass. I need them to be linked at...
4
by: Michael Kintner | last post by:
How do I create and ODBC connection enbedded inside a link???? The upsizing wizard worked great however when it created the ODBC connection somehow it enbeddeds the link and does not add to USER...
7
by: Salad | last post by:
I am converting an application from A97 to A2003. I have 2 tables created by another application as a Foxpro.dbf. The table has no index. The connect string in A97 is FoxPro...
3
by: Salad | last post by:
With the database window open I click on Help, then click on "About Microsoft Office Access". A dialog window is presented and there are 4 buttons at the bottom right of the form. One is...
1
by: david.triplett | last post by:
I am using MS Access 2007 and have an issue with writing queries against ODBC connected tables. After providing the appropriate ODBC connection string in the properties page, the Show Tables...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.