Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in compiling C project with MySQL "error: unknown type name ‘uint’" in Linux

Tags:

c

linux

mysql

gcc

In what cases do this error occur?

I am trying to do a MySQL connection on Linux machine in a project.

The options I have included in my GCC compilation are:

gcc a.c -o a -I/usr/include/mysql -Wall -g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing -L/usr/lib64 -lmysqlclient -lpthread -lm -ldl

   ]$ make

gcc  -g -O3 -Wall -std=c99 -pedantic -Wformat-security -Wno-format-zero-length -Werror -Wwrite-strings -Wformat -fdiagnostics-show-option -Wextra -Wsign-compare -Wcast-align -Wno-unused-parameter -fPIC -o clitest.o -c b.c  -I/usr/include/mysql -Wall -g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing -L/usr/lib64 -lmysqlclient -lpthread -lm -ldl

In file included from a.h:1:0,
                 from b.c:17:
/usr/include/mysql/my_global.h:1004:1: error: unknown type name ‘ulong’
 typedef ulong nesting_map;  /* Used for flags of nesting constructs */
 ^

In file included from a.h:1:0,
                 from b.c:17:
/usr/include/mysql/my_global.h:1035:1: error: unknown type name ‘ulong’
 typedef ulong  myf; /* Type of MyFlags in my_funcs */
 ^

In file included from /usr/include/mysql/my_global.h:1062:0,
                 from a.h:1,
                 from b.c:17:
/usr/include/mysql/my_dbug.h:32:3: error: unknown type name ‘uint’
   uint level;            /* this nesting level, highest bit enables tracing */
   ^

/usr/include/mysql/my_dbug.h:49:64: error: unknown type name ‘uint’
 extern void _db_enter_(const char *_func_, const char *_file_, uint _line_,
                                                                ^

/usr/include/mysql/my_dbug.h:51:26: error: unknown type name ‘uint’
 extern  void _db_return_(uint _line_, struct _db_stack_frame_ *_stack_frame_);
                          ^

/usr/include/mysql/my_dbug.h:52:25: error: unknown type name ‘uint’
 extern  void _db_pargs_(uint _line_,const char *keyword);
                         ^

/usr/include/mysql/my_dbug.h:55:24: error: unknown type name ‘uint’
 extern  void _db_dump_(uint _line_,const char *keyword,
                        ^

In file included from /usr/include/mysql/mysql.h:73:0,
                 from a.h:2,
                 from b.c:17:

/usr/include/mysql/mysql_com.h:548:41: error: unknown type name ‘uint’
 void my_net_set_write_timeout(NET *net, uint timeout);
                                         ^

/usr/include/mysql/mysql_com.h:549:40: error: unknown type name ‘uint’
 void my_net_set_read_timeout(NET *net, uint timeout);
                                        ^

/usr/include/mysql/mysql_com.h:643:1: error: unknown type name ‘ulong’
 ulong STDCALL net_field_length(uchar **packet);
 ^

make: *** [clitest.o] Error 1
like image 207
Ek1234 Avatar asked Dec 30 '14 06:12

Ek1234


1 Answers

Make sure you have my_global.h as the very first include.

like image 130
AntonioCS Avatar answered Oct 21 '22 05:10

AntonioCS