我有一个在我的系统上编译和运行的项目但是当我尝试在服务器上运行它时会产生编译时错误。以下是我用来在我的系统上编译它的Makefile部分:
CC = gcc
CFLAGS = -g -Wall
COMPLILEFLAGS = `mysql_config --include`
LINKERINFO = `mysql_config --cflags --libs`
exec: main.o
$(CC) $(CFLAGS) -o exec main.o $(LINKERINFO)
main.o: main.c
$(CC) $(CFLAGS) $(COMPLILEFLAGS) -c main.c
当我在服务器上运行相同的文件时,我收到以下错误:
gcc -g -Wall -I/usr/include/mysql -c main.c
In file included from main.c:13:
/usr/include/mysql/my_global.h:688: error: redefinition of typedef ‘my_bool’
/usr/include/mysql/mysql.h:55: note: previous declaration of ‘my_bool’ was here
In file included from main.c:13:
/usr/include/mysql/my_global.h:699: error: redefinition of typedef ‘my_socket’
/usr/include/mysql/mysql.h:69: note: previous declaration of ‘my_socket’ was here
In file included from main.c:13:
/usr/include/mysql/my_global.h:1102: error: redefinition of typedef ‘my_ulonglong’
/usr/include/mysql/mysql.h:132: note: previous declaration of ‘my_ulonglong’ was here
In file included from main.c:14:
/usr/include/mysql/my_getopt.h:64: warning: ‘enum loglevel’ declared inside parameter list
main.c文件是:
#include <stdio.h>
#include <mysql.h>
#include <my_global.h>
int main (void)
{
return 0;
}
任何人都可以建议解决这个问题。我想要的是增加此代码的可移植性。我能想到的一个选项是让文件compiler
和linker
在我的源代码中使用,并使用它们进行编译和链接。
顺便说一句,我使用的是mysql-server 5.5版,服务器有mysql-server version 5.3
答案 0 :(得分:1)
查看MySQL的文档,我发现old versions包含一条警告,指出在my_global.h
之前应该包含mysql.h
以便在Windows上进行编译。
尝试撤消包含的顺序,看看是否能解决问题。如果确实如此,则会急需向MySQL提交错误。