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

Linking error (cygwin, make, windows, sql)

PG
I am trying to compile a simple ODBC and C example on Windows XP SP2.
I have Cygwin_NT 5.1.

This is the code (obtained from
http://www.easysoft.com/developer/la...rial.html#dm_f...)
i am attempting to compile.

ODBCTest.c

#include <stdio.h>
#include <windows.h>
#include <sql.h>
#include <sqlext.h>

main() {
SQLHENV env;
char dsn[256];
char desc[256];
SQLSMALLINT dsn_ret;
SQLSMALLINT desc_ret;
SQLUSMALLINT direction;
SQLRETURN ret;

SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0);

direction = SQL_FETCH_FIRST;
while(SQL_SUCCEEDED(ret = SQLDataSources(env, direction,
dsn, sizeof(dsn), &dsn_ret,
desc, sizeof(desc),
&desc_ret))) {
direction = SQL_FETCH_NEXT;
printf("%s - %s\n", dsn, desc);
if (ret == SQL_SUCCESS_WITH_INFO) printf("\tdata truncation\n");
}

}

Makefile

CC=gcc
INCPATH=-I/usr/include -Iinclude
LIBS=-L. -lodbc32
LD=ld
all: clean ODBCTest.exe

ODBCTest.o : ODBCTest.c
$(CC) $(INCPATH) $(CFLAGS) -o ODBCTest.o -c ODBCTest.c
ODBCTest.exe : ODBCTest.o
$(CC) $(LIBS) $(CFLAGS) -o ODBCTest.exe ODBCTest.o
clean:
-rm *.o
-rm *.exe
Make output and Errors:

$ make
rm *.o
rm *.exe
rm: cannot remove `*.exe': No such file or directory
make: [clean] Error 1 (ignored)
gcc -I/usr/include -Iinclude -o ODBCTest.o -c ODBCTest.c
gcc -L. -lodbc32 -o ODBCTest.exe ODBCTest.o
ODBCTest.o:ODBCTest.c:(.text+0x4a): undefined reference to
`_SQLAllocHandle@12'
ODBCTest.o:ODBCTest.c:(.text+0x70): undefined reference to
`_SQLSetEnvAttr@16'
ODBCTest.o:ODBCTest.c:(.text+0xca): undefined reference to
`_SQLDataSources@32'
collect2: ld returned 1 exit status
make: *** [ODBCTest.exe] Error 1
Things i have checked:
libodbc32.a exists in c:\cygwin\lib\w32api.
If i remove the above lib, i get a "lib not found" kind of error when
i run make, meaning this is the lib make is using and there is no path
issue.
if i edit libodbc32.a in a binary editor, i can see the all the three
functions mentioned in the error (_SQLAllocHandle@12,
_SQLSetEnvAttr@16 and _SQLDataSources@32) exist.

How can i fix these linking errors?

Thanks

PG
--
comp.lang.c.moderated - moderation address: cl**@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
Mar 8 '08 #1
5 3855
PG wrote:
I am trying to compile a simple ODBC and C example on Windows XP SP2.
I have Cygwin_NT 5.1.
Why cross-post this to three groups where it is off topic? Try one of
the many windows programming groups.

--
Ian Collins.
--
comp.lang.c.moderated - moderation address: cl**@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
Mar 17 '08 #2
PG wrote, On 08/03/08 18:21:
I am trying to compile a simple ODBC and C example on Windows XP SP2.
I have Cygwin_NT 5.1.
Since you are not using C why cross-post to a C++ group?
This is the code (obtained from
http://www.easysoft.com/developer/la...rial.html#dm_f...)
i am attempting to compile.
ODBC is not topical here since it is not standard C. There are, however,
mailing lists for unixODBC, see the unixODBC web site for details. For
the MS implementation there are plenty of Microsoft groups.

<snip>
How can i fix these linking errors?
How to drive your tools to link to non-standard libraries is also not
topical here. However, there are Cygwin mailing lists. However I suggest
you try specifying the libraries you need after the object files that
reference them.
--
Flash Gordon
--
comp.lang.c.moderated - moderation address: cl**@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
Mar 17 '08 #3
On Sat, 8 Mar 2008 12:21:40 -0600 (CST), PG <go*****@gmail.comwrote:
>I am trying to compile a simple ODBC and C example on Windows XP SP2.
I have Cygwin_NT 5.1.

This is the code (obtained from
http://www.easysoft.com/developer/la...rial.html#dm_f...)
You will probably have beeter asking on the site you got the code from
or a newsgroup where ODBC and/or Windows is topical.
Remove del for email
--
comp.lang.c.moderated - moderation address: cl**@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
Mar 17 '08 #4
On Mar 8, 1:21 pm, PG <gosa...@gmail.comwrote:
I am trying to compile a simple ODBC and C example on Windows XP SP2.
I have Cygwin_NT 5.1.
Note that questions about ODBC, cygwin, XP, etc. really aren't topical
here (your question isn't about the C language as such, which is what
this group focuses on). In the future, you should direct such
questions to newsgroups devoted to embedded SQL or ODBC programming.
However, I think I know the answer to your problem.

[snip]
Makefile

CC=gcc
INCPATH=-I/usr/include -Iinclude
LIBS=-L. -lodbc32
I suspect you need to add the path to the libodbc32.a library to your
LIBS variable, like so:

-L/cygdrive/c/lib/w32api

Give that a shot, let me know if it works.
--
comp.lang.c.moderated - moderation address: cl**@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
Mar 20 '08 #5
On Mar 8, 1:21 pm, PG <gosa...@gmail.comwrote:
I am trying to compile a simple ODBC and C example on Windows XP SP2.
I have Cygwin_NT 5.1.
Note that questions about ODBC on Windows using Cygwin are not topical
for this newsgroup; our focus is on the C language itself, not
applications using C. However, I think I know what your problem is:
[snip]
>
Makefile

CC=gcc
INCPATH=-I/usr/include -Iinclude
LIBS=-L. -lodbc32
You need to specify the path to the libodbc32.a library, otherwise it
will only look in the standard library path. Add the following to
your LIBS variable:

-L/cygdrive/c/cygwin/lib/w32api

I think that's the right path, anyway.
--
comp.lang.c.moderated - moderation address: cl**@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
Mar 20 '08 #6

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

Similar topics

0
by: Jari Aalto+usenet | last post by:
Hi, Where I can specify more linking search directories for a Python module that makes a gcc build? Setting the LD_LIBRARY_PATH on command line does not seem to propagate to the linker. Jari...
0
by: Joonas Paalasmaa | last post by:
Hi, When compiling Sketch's streamfilter C extension the errors below are raised during linking. What could cause the errors? (Python 2.3, MinGw 1.1 with GCC 2.95.3-6, Windows 98) Here are...
1
by: Hadi | last post by:
Hi, I have two files libqdbm.dll.a and qdbm.dll. In cygwin libqdbm.dll.a is located in /usr/local/lib while qdbm.dll is located in windows/system32. I have my test project which I compiled in...
2
by: 63q2o4i02 | last post by:
Hi, I'm using python 2.4 and windows XP. I have two packages in the windows version of python in site-packages. They are PyVisa and ctypes, and both live in c:\python24\lib\site-packages ...
4
by: reachsamdurai | last post by:
Hello, Can you please let me know the procedure to reach db2 command prompt from a cygwin window (hence without using Start-> Run -> db2cmd method). I'm planning to write shell scripts which...
2
by: Manuel T | last post by:
Hello everybody, I'm trying to port a project from Windows+Cygwin to Linux(i'm working on a Debian-like: Kubuntu), but I'm facing a lot of linking problems. This project needs libraries xerces...
0
by: dot | last post by:
I spent a few headache filled days trying to use GMP on windows (XP pro) I finally got it to work and since I found little help on the Web I thought someone might find what i did useful. ...
10
by: Gotch | last post by:
Hi all, I've installed the CDT plugin for Eclipse and I want to use it to work on C/C++ projects under Cygwin. It works, in fact it compiles and runs the usual helloworld c++ program. Now it comes...
3
by: PG | last post by:
I am trying to compile a simple ODBC and C example on Windows XP SP2. I have Cygwin_NT 5.1. This is the code (obtained from...
5
by: PG | last post by:
I am trying to compile a simple ODBC and C example on Windows XP SP2. I have Cygwin_NT 5.1. This is the code (obtained from...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: 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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.