473,396 Members | 2,081 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,396 software developers and data experts.

Linking error

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...dm_fns_drivers)
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
Mar 5 '08 #1
3 1695
PG wrote:
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...dm_fns_drivers)
i am attempting to compile.
<snip>
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
1. Get rid of the funny graphics in your messages.
2. Try an ODBC newsgroup. libodbc32 is not a MySQL library
3. Don't even think of crossposting to every SQL-related newsgroup you
can find. Such will get you no help at all.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Mar 5 '08 #2
PG
I did not know if this was a problem with makefile, cygwin, or the
specific odbc library, hence i submitted this question to multiple
groups.

Anyway, after some more work, found out that the makefile is resulting
in this command
gcc -L/lib/w32api -lodbc32 -o ODBCTest.exe ODBCTest.o <-- Fails with
link errors.

When i change the command to
gcc -o ODBCTest.exe ODBCTest.o /lib/w32api/libodbc32.a <-- Succeeds.

Not sure of the diff between the two but it will do for now.

On Mar 4, 7:24 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
PG wrote:
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.

<snip>
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

1. Get rid of the funny graphics in your messages.
2. Try an ODBC newsgroup. libodbc32 is not a MySQL library
3. Don't even think of crossposting to every SQL-related newsgroup you
can find. Such will get you no help at all.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
Mar 5 '08 #3
PG schrieb:
I did not know if this was a problem with makefile, cygwin, or the
specific odbc library, hence i submitted this question to multiple
groups.

Anyway, after some more work, found out that the makefile is resulting
in this command
gcc -L/lib/w32api -lodbc32 -o ODBCTest.exe ODBCTest.o <-- Fails with
link errors.
But that is not what you posted earlier on, see your previously posted
error output:

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'
no -L/lib/w32api :-)

And hey, this is has nothing to do with databases, this is a simple
gcc,make problem!

Cheers Hans
Mar 5 '08 #4

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

Similar topics

0
by: Wolfgang | last post by:
I have a problem with linking my CPP Code under a irix6 machine (sgi, UNIX). In my CPP code I use some Functions which are written in Python. So its a kind of CPP wrapper for my Python functions In...
3
by: Saurabh Aggrawal | last post by:
Hi, I am porting an application for 64-bit AMD processor and while linking the application i am getting the following errors: Processing directory uidll... Linking DLL...
7
by: wmkew | last post by:
Hello everyone I'm encountering a R6002 Runtime error and several bugs when trying to generate a simple Managed C++ application with .NET 2003. The main problem seems to arise from linking with...
1
by: Joannes Vermorel | last post by:
I am currently trying to port a small open source scientfic library written in C++ to .Net. The code (including the VS solution) could be found at http://www.vermorel.com/opensource/selfscaling.zip...
1
by: Kay | last post by:
I already specified to ignore specific library: MSVCPRT.lib MSVCRT.lib LIBC.lib MSVCRTD.lib LIBCD.lib command line is like: /INCREMENTAL /NOLOGO /DLL /NODEFAULTLIB:"MSVCPRT.lib MSVCRT.lib LIBC.lib...
4
by: Sanjay Kumar | last post by:
Folks ! I am working with VC++ after a long time and having problem linking latest xerces 2.7 in VC++ 2005 Express Edition. I have done following: 1. downloaded and unpacked the the...
0
by: Adam Clauss | last post by:
I have managed C++ library (is bridging between a Win32 .dll and a C# application). All was well when compiled under VS2003, but I am running into a series of linking errors when compiling...
0
by: Philip Lowman | last post by:
I am in the process of trying to migrate a couple of build solutions to Visual Studio Express 2005 from VS 2003 Professional and I am running into a weird C/C++ runtime library linking issue when...
0
by: xieml2007 | last post by:
Dear Madam or Sir, I encountered one problem which is quite similiar to the discussions launched at the web site: http://www.thescripts.com/forum/thread280324.html
0
by: dotyet | last post by:
Hi Everyone, I am trying to build a DB2 UDB UDF which can perform regex over the table data. The user defined function will call an external .dll file to do the task. I am referring to the...
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?
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.