使用mysql编译c项目时出错:错误:linux中的未知类型名称'uint'

时间:2014-12-30 06:30:38

标签: mysql c linux gcc

任何机构都可以告诉这个错误发生在什么情况下?我正在尝试在项目中的linux机器上进行mysql连接。

我在gcc中包含的选项是:

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

3 个答案:

答案 0 :(得分:4)

确保将my_global.h作为第一个包含。

答案 1 :(得分:2)

我也遇到了同样的问题。我从include头和我编译的示例程序中删除了my_globals.h。请检查它是否适合您。

答案 2 :(得分:0)

types.h头文件中定义了

uint ulong

    /* sysv */
 89 typedef unsigned char           unchar;
 90 typedef unsigned short          ushort;
 91 typedef unsigned int            uint;
 92 typedef unsigned long           ulong;

查看types.h文件

http://lxr.free-electrons.com/source/include/linux/types.h#L91