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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linking a C program to MySQL

Status
Not open for further replies.

eagarwal

Programmer
Dec 6, 2000
1
US
I am compiling a C program and then trying to link it with the command:

gcc -g url.cc url.o -lm -L/usr/lib/mysql -lmysqlclient

Once I enter the above command, I get an error that looks like

url.o(.text+0x0): multiple definition of `PrintHTMLHeader(void)'
where url.o is my object file ... and PrintHTMLHeader is some function ...

I am getting this error for every function that I have defined ...

Could you tell me what is wrong?

Ekta
 
Is url.o an object file produced from url.cc? If so, you shouldn't be compiling both at the same time like that -- you're probably getting the multiple definition error because your functions are defined in both url.cc and url.o. Try:

gcc -g url.cc -lm -L/usr/lib/mysql -lmysqlclient

OR

gcc -g url.o -lm -L/usr/lib/mysql -lmysqlclient

Is this a C or a C++ program? If it's a C program the source file suffix should be .c instead of .cc

HTH,

Russ
bobbitts@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top