Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

gcc stopped being able to find references to odbc api functions

Status
Not open for further replies.

pipemole

Programmer
May 9, 2003
19
0
0
IE
subj: gcc stopped being able to find references to odbc api functions definitions;

I am writing / re-writing c , c++ code, to conduct database queries from a program via odbc calls. The api for this communications connection comes with unixODBC package. Environment involves commends issued into shell windows from KDE, in Suse8.0 Linux.

Command gcc prog1.c -o prog1 now terminates with errors. It no longer finds the references to functions provided by unixODBC, although it normally did so previously. This was checked by trying to compile again the code from several days ago which had compiled and run correctly earlier. But now it too fails to compile / link. The sql*.h files in /usr/include remain readable in a text editor. Removal of unixODBC and restore using the Suse cdrom disks via Yast2 gui did not fix things. Those sql*.h files are present only when packages unixodbc and unixodbc - development are currently installed.

Below appear 4 out of about 9-12 similar error message lines from the compile attempt.

/tmp/ccbPLX4E.o: In function ‘main’:0
/tmp/ccbPLX4E.o: (.text+0x72) undefined reference to ‘SQLAllocHandle’
/tmp/ccbPLX4E.o: (.text+0xc3) undefined reference to ‘SQLSetEnvAttr’
/tmp/ccbPLX4E.o: (.text+0x103) undefined reference to ‘SQLAllocHandle’

Ideas?
- - pipemole - - 4/16/2005;
 
Well you have to name the libraries as well (those are linker errors).
The .h files are used by the compiler to know the names of functions, and to pass the right number and type of parameters.

The library files are used by the linker to find the actual code which will do the actual work you wanted.

Example
Code:
gcc prog1.c -o prog1 -lmysqlclient
The [tt]-l[/tt] command line option allows you to name additional object libraries.

--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top