[freetds] SUMMARY2: Newcomer to FreeTDS - in search of sample C code for a re lative b eginner

Andy Cranston a.cranston at selwaymoore.com
Tue Mar 30 09:28:50 EST 2004


I forgot to include the step to set LD_LIBRARY_PATH.

Before running:

./t0001

type:

LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/freetds/lib
export LD_LIBRARY_PATH

If you don't then running:

./t0001

will give an error message similar to:

ld.so.1: ./t0001: fatal: libsybdb.so.3: open failed: No such file or
directory
Killed

Regards,

Andy Cranston.

> -----Original Message-----
> From: Andy Cranston [mailto:a.cranston at selwaymoore.com]
> Sent: 30 March 2004 14:28
> To: 'freetds at lists.ibiblio.org'
> Subject: [freetds] SUMARY: Newcomer to FreeTDS - in search of sample C
> code for a re lative b eginner
> 
> 
> Many thanks to Bill and Daniel,
> 
> First of all I was looking in the wrong place.  Next time 
> I'll take a look
> at the source distribution for source files - D'Oh!
> 
> I decided to follow Bill's advice and look at db-library 
> first.  The t0001.c
> unit test under:
> 
>   freetds-61.2/src/dtlib/unittests
> 
> was my first test.  To get this to compile I did the following:
> 
> I added:
> 
> #define MAXPATHLEN 2048
> 
> to the common.c source file.
> 
> Produced the common.o object file with:
> 
>   gcc -c common.c
> 
> it generated some compiler warnings:
> 
> common.c: In function `read_PWD':
> common.c:79: warning: assignment makes pointer from integer 
> without a cast
> common.c: In function `read_login_info':
> common.c:106: warning: assignment makes pointer from integer 
> without a cast
> common.c:107: warning: assignment makes pointer from integer 
> without a cast
> 
> which I brazenly ignored :-)
> 
> Copied everything in /usr/local/freetds/include to 
> /usr/include.  I used "cp
> -i" to check for any file name clashes - there were none.
> 
> Next I compiled t0001.c as follows:
> 
> gcc -L /usr/local/freetds/lib -lsybdb -lct -o t0001 common.o t0001.c
> 
> This produced the t0001 executable.
> 
> Added the following to /etc/hosts:
> 
> 10.1.1.25    sandbox.internal.selwaymoore.com sandbox SANDBOX
> 
> Added the following to /usr/local/freetds/etc/freetds.conf:
> 
> [SANDBOX]
>         host = sandbox.internal.selwaymoore.com
>         port = 1433
>         tds version = 7.0
> 
> Created a PWD file in freetds-0.61.2 with the following lines in it:
> 
> UID=ac
> PWD=*******
> SRV=SANDBOX
> DB=snag
> 
> Ran t0001 as follows:
> 
> ./t0001
> 
> and it worked!
> 
> Now I can look at the code in common.c, common.h and t0001.c 
> to learn about
> the API in more detail and write some code of my own.
> 
> Thanks again!
> 
> Regards,
> 
> Andy Cranston.
> 
> > -----Original Message-----
> > From: Andy Cranston [mailto:a.cranston at selwaymoore.com]
> > Sent: 30 March 2004 12:23
> > To: 'freetds at lists.ibiblio.org'
> > Subject: [freetds] Newcomer to FreeTDS - in search of sample 
> > C code for
> > a relative b eginner
> > 
> > 
> > Hello list,
> > 
> > I am a newcomer to FreeTDS and I am in search of sample C 
> > code to show me
> > how to access a Microsoft SQL Server database from a C 
> > program on a UNIX
> > system.  Here are my platform details:
> > 
> >   UNIX side:
> > 
> >   Solaris 8 running on a Sun Microsystems Ultra-1
> >   FreeTDS version 0.61
> >   GNU gcc version 3.2.2
> > 
> >   Database side:
> > 
> >   Windows NT Server 4.0 service pack 6a
> >   Microsoft SQL Server version 8.0 / 2000
> > 
> > I compiled and installed FreeTDS "out of the box" 
> > (./configure, make, make
> > install).
> > 
> > I can use the tsql utility to access the databases on the SQL Server
> > although I do need to login as the Administrator user 
> > supplying the Windows
> > NT domain admin password if I want to be able to see all the 
> > tables in each
> > database.
> > 
> > I have gotton as far as selecting columns of information 
> from selected
> > tables via a UNIX expect script which drives a tsql session 
> > but I would like
> > to do this "properly" by using a suitable API from within a C 
> > program to
> > connect to the database, authenticate, issue one or more 
> > select statements
> > and then gracefully close the connection.
> > 
> > I have had a look at the FAQ on the FreeTDS website but have 
> > not found any
> > sample code for using an API from C.  I'm probably just 
> > looking in the wrong
> > place (apologies if I am) but if somebody could point me in 
> the right
> > direction to get started I'd be very grateful.
> > 
> > Regards,
> > 
> > Andy Cranston.
> > 
> 
> ______________________________________________________________
> __________
> This message has been checked for all known viruses by the 
> Selway Moore
> scanning service powered by MessageLabs. For further information and
> statistics on current viruses visit 
http://www.messagelabs.com/stats.asp
________________________________________________________________________
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds

________________________________________________________________________
This message has been checked for all known viruses by the Selway Moore
scanning service powered by MessageLabs. For further information and
statistics on current viruses visit http://www.messagelabs.com/stats.asp
________________________________________________________________________

________________________________________________________________________
This message has been checked for all known viruses by the Selway Moore
scanning service powered by MessageLabs. For further information and
statistics on current viruses visit http://www.messagelabs.com/stats.asp
________________________________________________________________________


More information about the FreeTDS mailing list