473,769 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 ,&henv);
retcode = SQLAllocConnect (henv,&hdbc);
retcode = SQLConnect(hdbc , (SQLCHAR*)"SAGE _GESCOM", SQL_NTS,
(SQLCHAR*)"Mo", SQL_NTS, (SQLCHAR*)"",SQ L_NTS);
retcode = SQLGetInfo(hdbc ,SQL_DBMS_VER, &info, STR_LEN,&inf);

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

SQLDisconnect(h dbc);
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.ex e" -L"C:/Dev-Cpp5/lib"
main.o(.text+0x 142):main.cpp: undefined reference to
`SQLAllocHandle @12'
main.o(.text+0x 160):main.cpp: undefined reference to
`SQLAllocConnec t@8'
main.o(.text+0x 1a6):main.cpp: undefined reference to `SQLConnect@28'
main.o(.text+0x 1dc):main.cpp: undefined reference to `SQLGetInfo@20'
main.o(.text+0x 206):main.cpp: undefined reference to `SQLDisconnect@ 4'
main.o(.text+0x 216):main.cpp: undefined reference to `SQLFreeConnect @4'
main.o(.text+0x 226):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 2792

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

Similar topics

1
5527
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 table of the MS-SQL Database, "TestODBC". I wanted to use StoredProcedure1 as the bound recordsource for a new form Form1. But I
13
8293
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 cnMySQL As DAO.Connection Dim sDSN As String sDSN = "ODBC;DRIVER={MySQL ODBC 3.51 Driver};" _ & "SERVER=127.0.0.1;" _
1
3389
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. I have a problem that when I link to the tables on the client machine AccessXP does not recognize boolean values in the FoxPro tables. I assume this is due to the ODBC driver. I'd like to test this out on my development machine. I...
4
2718
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, Users and IT have a warm fuzzy feeling of contentment. Turns out Helpdesk application is short of decent reporting capabilities. So, I create an Access DB on my machine, via ODBC, link to the tables within the Helpdesk Access database. I set the...
0
1377
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 tybles. open them - fine!
1
3809
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 startup automatically. The Oracle db contains two tables I need. I've already created an ODBC data source that contains the userid and pass to link to the Oracle DB. It works. When I go into linked table manager, I can link to them just fine
4
2532
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 or SYSTEM DNS. Thats cool. How can I do this by hand? The advantage here is understanding how to create an ODBC on the fly with out manually having a create a ODBC DNS connection within the control panel. Thank you in advance for your help...
7
3060
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 2.0;HDR=NO;IMEX=2;DATABASE=C:\Test It's really easy to connect to those tables in A97. I'm having difficulties in A2003. I'm trying to follow the instructions in http://support.microsoft.com/kb/824264/.
3
2103
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 SystemInfo and when I press that I get a Summary dialog box of particulars. One of the options is Office 2003 Applications. If I press on the plus sign O2003Apps, I can drill down and select Access 2003 and drill down to its selections. In the...
1
3548
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 dialog will list the tables in the source database. When selecting a table to add to the design window the requested table will appear on the page but then disappear in the blink of an eye. I am unable to get the ODBC tables to "stick" to the page...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10039
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9990
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8869
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7406
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6668
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5297
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5445
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2814
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.