473,836 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(e nv, SQL_ATTR_ODBC_V ERSION, (void *) SQL_OV_ODBC3, 0);

direction = SQL_FETCH_FIRST ;
while(SQL_SUCCE EDED(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_WIT H_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:ODBC Test.c:(.text+0 x4a): undefined reference to
`_SQLAllocHandl e@12'
ODBCTest.o:ODBC Test.c:(.text+0 x70): undefined reference to
`_SQLSetEnvAttr @16'
ODBCTest.o:ODBC Test.c:(.text+0 xca): undefined reference to
`_SQLDataSource s@32'
collect2: ld returned 1 exit status
make: *** [ODBCTest.exe] Error 1
Things i have checked:
libodbc32.a exists in c:\cygwin\lib\w 32api.
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 (_SQLAllocHandl e@12,
_SQLSetEnvAttr@ 16 and _SQLDataSources @32) exist.

How can i fix these linking errors?

Thanks

PG
--
comp.lang.c.mod erated - moderation address: cl**@plethora.n et -- 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 3884
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.mod erated - moderation address: cl**@plethora.n et -- 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.mod erated - moderation address: cl**@plethora.n et -- 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.mod erated - moderation address: cl**@plethora.n et -- 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.mod erated - moderation address: cl**@plethora.n et -- 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.mod erated - moderation address: cl**@plethora.n et -- 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
1651
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 root@w2kpicasso:/usr/share/site-python/xmldiff-0.6.3# echo $LD_LIBRARY_PATH
0
4935
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 the occurrences of FilterType that may be relevant: ------- C:\sketch\sketch-0.7.12\Filter\filterobj.c: 949: PyTypeObject FilterType = {
1
2128
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 cygwin using the following command: gcc -I/usr/local/include -o test test.c -L/usr/local/lib -lqdbm
2
3248
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 I'd like to move these to the cygwin version of python on the same system. I tried copying the PyVisa and ctypes directorices (including
4
14069
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 accesses DB2 database on windows platform hence I installed cygwin but I'm unable to connect to database as it fails with the error message. $ db2 DB21061E Command line environment not initialized.
2
6019
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 and gsl, more specifically libxerces-c, libgsl, libgslblas. The project comes with an own makefile, automatically generated by Eclipse cdt on Windows, on wich I made some change to fit it for Linux.
0
3318
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. Creating an environment suitable for GMP programming. 1) Create 'cygwin' environment (see below) 2)add GMP to the cygwin directory (see below)
10
8546
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 difficult when I try to add external libs. Such as... GTK. Let's explain what I tried. (oh well, I'm using Eclipse Europa 3.3.1 and CDT 4.0.1). First I just added the path of the cygwin includes throug the project->properties- GNU C the path to...
3
2499
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 http://www.easysoft.com/developer/languages/c/odbc_tutorial.html#dm_fns_drivers) i am attempting to compile. ODBCTest.c #include <stdio.h> #include <windows.h>
5
476
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 http://www.easysoft.com/developer/languages/c/odbc_tutorial.html#dm_f...) i am attempting to compile. ODBCTest.c #include <stdio.h>
0
9825
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
9673
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
10859
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10560
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
10602
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
6984
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
5829
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4463
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4023
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.