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

Why won't this mysql code compile in MS VC++? 1

Status
Not open for further replies.

vcherubini

Programmer
May 29, 2000
527
US
Hello, I am working on integrating C/C++ with the C/C++ mysql api to make an application.

However, I can not, for the life of me, get this code to compile in VC++.

I have installed the mysql++.lib file that you compile when you download the C/C++ API from along with putting the correct header files in the Include directory.

Here is the code, I got it from the book MySQL by Paul DuBois:


[tt]
/* client1.c */

#include <stdio.h>
#include <mysql.h>

#define def_host_name localhost /* host to connect to (default = localhost) */
#define def_user_name username /* user name (default = your login name) */
#define def_password password /* password (default = none) */
#define def_db_name database /* database to use (default = none) */

MYSQL *conn; /* pointer to connection handler */

int
main (int argc, char *argv[])
{
conn = mysql_init (NULL);
mysql_real_connect (
conn, /* pointer to connection handler */
def_host_name, /* host to connect to */
def_user_name, /* user name */
def_password, /* password */
def_db_name, /* database to use */
0, /* port (use default) */
NULL, /* socket (use default) */
0); /* flags (none) */
mysql_close (conn);
exit (0);
}
[/tt]

Here are the errors I am getting:

[tt]
client1.obj : error LNK2001: unresolved external symbol _mysql_close@4
client1.obj : error LNK2001: unresolved external symbol _mysql_real_connect@32
client1.obj : error LNK2001: unresolved external symbol _mysql_init@4
[/tt]

Any help is appreciated.

Thanks,
-Vic vic cherubini
krs-one@cnunited.com
====
Knows: Perl, HTML, JavScript, C/C++, PHP, Flash
====
 
I believe so. I have the mysql++.lib file that I compiled from the source and put it in the Lib directory, but I don't believe that I have added it that way.

I will try that when I get home and let you know what happens.

Thanks,
-Vic vic cherubini
krs-one@cnunited.com
====
Knows: Perl, HTML, JavScript, C/C++, PHP, Flash
====
 
If I change localhost on remote one I got runtime error message:

File 'c:\mysql\\share\charsets\?.conf' not found (Errcode: 2) Character set '#14' is not a compiled character set and is not specified in the 'c:\mysql\\share\charsets\Index' file

I have not mysql on my host
What is the reason of the error?
Thanks
 
I tried to compile a sample program to connect to mysql. Bu t I am getting compile time error messages like this.


c:\mysql\include\mysql_com.h(115) : error C2061: syntax error : identifier 'SOCKET'
c:\mysql\include\mysql_com.h(130) : error C2059: syntax error : '}'
c:\mysql\include\mysql_com.h(160) : error C2143: syntax error : missing ')' before '*'
c:\mysql\include\mysql_com.h(160) : error C2143: syntax error : missing '{' before '*'
c:\mysql\include\mysql_com.h(160) : error C2371: 'Vio' : redefinition; different basic types
c:\mysql\include\mysql_com.h(109) : see declaration of 'Vio'
c:\mysql\include\mysql_com.h(160) : error C2143: syntax error : missing ';' before '*'
c:\mysql\include\mysql_com.h(160) : error C2059: syntax error : ')'
c:\mysql\include\mysql_com.h(161) : error C2143: syntax error : missing ')' before '*'
c:\mysql\include\mysql_com.h(161) : error C2143: syntax error : missing '{' before '*'
c:\mysql\include\mysql_com.h(161) : error C2059: syntax error : ')'
c:\mysql\include\mysql_com.h(162) : error C2143: syntax error : missing ')' before '*'
c:\mysql\include\mysql_com.h(162) : error C2143: syntax error : missing '{' before '*'
c:\mysql\include\mysql_com.h(162) : error C2059: syntax error : ')'
c:\mysql\include\mysql_com.h(163) : error C2143: syntax error : missing ')' before '*'
c:\mysql\include\mysql_com.h(163) : error C2143: syntax error : missing '{' before '*'
c:\mysql\include\mysql_com.h(163) : error C2059: syntax error : ')'
c:\mysql\include\mysql_com.h(164) : error C2143: syntax error : missing ')' before '*'
c:\mysql\include\mysql_com.h(164) : error C2143: syntax error : missing '{' before '*'
c:\mysql\include\mysql_com.h(164) : error C2059: syntax error : 'type'
c:\mysql\include\mysql_com.h(164) : error C2059: syntax error : ')'
c:\mysql\include\mysql_com.h(165) : error C2143: syntax error : missing ')' before '*'
c:\mysql\include\mysql_com.h(165) : error C2143: syntax error : missing '{' before '*'
c:\mysql\include\mysql_com.h(165) : error C2059: syntax error : 'type'
c:\mysql\include\mysql_com.h(166) : error C2059: syntax error : ')'
c:\mysql\include\mysql_com.h(167) : error C2143: syntax error : missing ')' before '*'
c:\mysql\include\mysql_com.h(167) : error C2143: syntax error : missing '{' before '*'
c:\mysql\include\mysql_com.h(167) : error C2059: syntax error : 'type'
c:\mysql\include\mysql_com.h(167) : error C2059: syntax error : ')'
c:\mysql\include\mysql_com.h(168) : error C2143: syntax error : missing ')' before '*'
c:\mysql\include\mysql_com.h(168) : error C2143: syntax error : missing '{' before '*'
c:\mysql\include\mysql_com.h(168) : error C2059: syntax error : ')'
c:\mysql\include\mysql.h(141) : error C2061: syntax error : identifier 'NET'
c:\mysql\include\mysql.h(163) : error C2059: syntax error : '}'
c:\mysql\include\mysql.h(176) : error C2061: syntax error : identifier 'MYSQL'
c:\mysql\include\mysql.h(178) : error C2059: syntax error : '}'
c:\mysql\include\mysql.h(183) : error C2143: syntax error : missing ')' before '*'
c:\mysql\include\mysql.h(183) : error C2143: syntax error : missing '{' before '*'
c:\mysql\include\mysql.h(183) : error C2059: syntax error : ')'
c:\mysql\include\mysql.h(184) : error C2143: syntax error : missing ')' before '*'
c:\mysql\include\mysql.h(184) : error C2143: syntax error : missing '{' before '*'
c:\mysql\include\mysql.h(184) : error C2059: syntax error : ')'
c:\mysql\include\mysql.h(185) : error C2143: syntax error : missing ')' before '*'
c:\mysql\include\mysql.h(185) : error C2143: syntax error : missing '{' before '*'
c:\mysql\include\mysql.h(185) : error C2059: syntax error : ')'
c:\mysql\include\mysql.h(186) : error C2143: syntax error : missing ')' before '*'
c:\mysql\include\mysql.h(186) : error C2143: syntax error : missing '{' before '*'
c:\mysql\include\mysql.h(187) : error C2059: syntax error : 'type'
c:\mysql\include\mysql.h(187) : error C2059: syntax error : ')'
c:\mysql\include\mysql.h(188) : error C2143: syntax error : missing ')' before '*'
c:\mysql\include\mysql.h(188) : error C2143: syntax error : missing '{' before '*'
c:\mysql\include\mysql.h(188) : error C2059: syntax error : ')'
c:\mysql\include\mysql.h(189) : error C2143: syntax error : missing ')' before '*'
c:\mysql\include\mysql.h(189) : error C2143: syntax error : missing '{' before '*'
c:\mysql\include\mysql.h(189) : error C2059: syntax error : ')'
c:\mysql\include\mysql.h(190) : error C2143: syntax error : missing ')' before '*'
c:\mysql\include\mysql.h(190) : error C2143: syntax error : missing '{' before '*'
c:\mysql\include\mysql.h(190) : error C2059: syntax error : ')'
c:\mysql\include\mysql.h(192) : error C2143: syntax error : missing ')' before '*'
c:\mysql\include\mysql.h(192) : error C2143: syntax error : missing '{' before '*'
c:\mysql\include\mysql.h(192) : error C2059: syntax error : ')'
c:\mysql\include\mysql.h(193) : error C2143: syntax error : missing ')' before '*'
c:\mysql\include\mysql.h(193) : error C2143: syntax error : missing '{' before '*'
c:\mysql\include\mysql.h(193) : error C2059: syntax error : ')'
c:\mysql\include\mysql.h(194) : error C2143: syntax error : missing ')' before '*'
c:\mysql\include\mysql.h(194) : error C2143: syntax error : missing '{' before '*'
c:\mysql\include\mysql.h(194) : error C2059: syntax error : ')'
c:\mysql\include\mysql.h(195) : error C2143: syntax error : missing ')' before '*'
c:\mysql\include\mysql.h(195) : error C2143: syntax error : missing '{' before '*'
c:\mysql\include\mysql.h(195) : error C2059: syntax error : ')'
c:\mysql\include\mysql.h(196) : error C2143: syntax error : missing ')' before '*'
c:\mysql\include\mysql.h(196) : error C2143: syntax error : missing '{' before '*'
c:\mysql\include\mysql.h(196) : error C2059: syntax error : ')'
c:\mysql\include\mysql.h(197) : error C2143: syntax error : missing ')' before '*'
c:\mysql\include\mysql.h(197) : error C2143: syntax error : missing '{' before '*'
c:\mysql\include\mysql.h(197) : error C2059: syntax error : ')'
c:\mysql\include\mysql.h(198) : error C2143: syntax error : missing ')' before '*'
c:\mysql\include\mysql.h(198) : error C2143: syntax error : missing '{' before '*'
c:\mysql\include\mysql.h(198) : error C2059: syntax error : ')'
c:\mysql\include\mysql.h(199) : error C2143: syntax error : missing ')' before '*'
c:\mysql\include\mysql.h(199) : error C2143: syntax error : missing '{' before '*'
c:\mysql\include\mysql.h(199) : error C2059: syntax error : ')'
c:\mysql\include\mysql.h(201) : error C2143: syntax error : missing '{' before '*'
c:\mysql\include\mysql.h(201) : error C2143: syntax error : missing ')' before '*'
c:\mysql\include\mysql.h(201) : error C2143: syntax error : missing '{' before '*'
c:\mysql\include\mysql.h(201) : error C2059: syntax error : ')'
c:\mysql\include\mysql.h(209) : error C2143: syntax error : missing '{' before '*'
c:\mysql\include\mysql.h(209) : error C2143: syntax error : missing ')' before '*'
c:\mysql\include\mysql.h(209) : error C2143: syntax error : missing '{' before '*'
c:\mysql\include\mysql.h(209) : error C2059: syntax error : 'type'
c:\mysql\include\mysql.h(210) : error C2059: syntax error : ')'
c:\mysql\include\mysql.h(211) : error C2143: syntax error : missing ')' before '*'
c:\mysql\include\mysql.h(211) : error C2143: syntax error : missing '{' before '*'
c:\mysql\include\mysql.h(211) : error C2059: syntax error : 'type'
c:\mysql\include\mysql.h(212) : error C2059: syntax error : ')'
c:\mysql\include\mysql.h(214) : error C2143: syntax error : missing '{' before '*'
c:\mysql\include\mysql.h(214) : error C2143: syntax error : missing ')' before '*'
c:\mysql\include\mysql.h(214) : error C2143: syntax error : missing '{' before '*'
c:\mysql\include\mysql.h(214) : error C2059: syntax error : 'type'
c:\mysql\include\mysql.h(220) : error C2059: syntax error : ')'
c:\mysql\include\mysql.h(229) : error C2143: syntax error : missing ')' before '*'
c:\mysql\include\mysql.h(229) : error C2143: syntax error : missing '{' before '*'
c:\mysql\include\mysql.h(229) : fatal error C1003: error count exceeds 100; stopping compilation
Error executing cl.exe.

mysql_connect.exe - 102 error(s), 0 warning(s)


Kindly help me

Regards
Rafeeq C E
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top