编译c++出了点问题,帮看下怎么回事
时间:2010-08-22
来源:互联网
- g++ -o rzfy ./server.o ./lib/function.o ./lib/instruction_test.o ./lib/policy.o ./lib/stptok.o ./class/app/application.o ./class/app/people_chat.o ./class/control/control.o ./class/data_deal/data_module.o ./class/data_deal/role_move.o ./class/data_deal/war.o -lpthread -lmemcached -lcurl -ljson -D__STRICT_ANSI__ -D_SVID_SOURCE -fno-stack-protector
- g++ -o rzfy ./server.o -lpthread -lmemcached -lcurl -ljson -D__STRICT_ANSI__ -D_SVID_SOURCE -fno-stack-protector
作者: jd808 发布时间: 2010-08-22
作者: jd808 发布时间: 2010-08-23
呮
再呮一声
呮
呮
作者: drangon 发布时间: 2010-08-23
作者: hellioncu 发布时间: 2010-08-23
应该是声明放头文件吧
作者: cstdio 发布时间: 2010-08-23
- [root@test src]# make
- g++ -g -O2 -lpthread -lmemcached -lcurl -ljson -D__STRICT_ANSI__ -D_SVID_SOURCE -fno-stack-protector -o rzfy server.o function.o instruction_test.o policy.o stptok.o application.o people_chat.o control.o data_module.o monster.o role_move.o war.o
- function.o: In function `patoca(char*, char*)':
- /www/game/server++/src/lib/function.cpp:1020: multiple definition of `gag'
- server.o:/www/game/server++/src/class/control/../../class/data_deal/../../class/app/application.h:26: first defined here
- function.o: In function `patoca(char*, char*)':
- /www/game/server++/src/lib/function.cpp:1020: multiple definition of `ics'
- server.o:/www/game/server++/src/class/control/../../class/data_deal/../../class/app/application.h:26: first defined here
- function.o: In function `user_on(int, ARG*)':
- /www/game/server++/src/lib/function.cpp:499: multiple definition of `EXECUTION_PATH'
- server.o:/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/iostream:76: first defined here
- function.o: In function `user_on(int, ARG*)':
- /www/game/server++/src/lib/function.cpp:493: multiple definition of `ev'
- server.o:/www/game/server++/src/server.cpp:489: first defined here
- function.o: In function `user_on(int, ARG*)':
- /www/game/server++/src/lib/function.cpp:493: multiple definition of `epfd'
- /**
- * 指针字符串数组转字符串数组
- *
- * @param char* arr 指针字符串数组
- * @param char *returnarr 返回数组 char returnarr[50];
- */
- void patoca(char *arr,char *returnarr) //这里是functions的1020行
- {
- int i;
- for(i=0;i<sizeof(arr)/sizeof(arr[0]);i++)
- {
- if(arr[i])
- {
- returnarr[i]=arr[i];
- }
- }
- }
- int user_on(int user_id,struct ARG *arg)//这里是function文件的493行
- {
- if(!user_id){return 0;}
- int i;
- for (i=0;i<arg->config.ONLINE;i++)
- {
- if(arg->connfd[i][6]==user_id)//这里是function文件的499行
- {
- return 1;
- }
- }
- return 0;
- }
作者: jd808 发布时间: 2010-08-23
我的变量和声明全部在头文件就是.H文件里的
比如policy.h文件如下
- #ifndef POLICY_H_
- #define POLICY_H_
-
- #ifndef FUNCTION_H_
- #include "lib/function.h"
- #endif
-
- void policy(void);
- void sendpolicy(int connectfd);
- #endif
- #ifndef STPTOK_H_
- #define STPTOK_H_
-
- #ifndef FUNCTION_H_
- #include "lib/function.h"
- #endif
-
- int iscc(unsigned char ch);
- static int cc1(unsigned char *bp,unsigned char *bufp);
- int firstcc(unsigned char *bp,unsigned char *bufp);
- int secondcc(unsigned char *bp,unsigned char *bufp);
- char *stptok(char *src,char *trg,int len,char *tok);
- #endif
还有一点 我的所有变量和常量以及要引入的外部库的头文件均在 function.h里头定义的,所以很多文件都引入了这个文件
作者: jd808 发布时间: 2010-08-23
作者: davelv 发布时间: 2010-08-23
作者: jd808 发布时间: 2010-08-23
作者: davelv 发布时间: 2010-08-23
/www/game/server++/src/class/control/../../class/data_deal/../../class/app/application.h 文件里面内容如何?
初步猜测,application.h 文件中定义了变量 int gag = 1; 然后多次应用后就重复定义了。
头文件中改成声明 extern int gag; 然后找某个cpp文件放定义 int gag = 1;
作者: drangon 发布时间: 2010-08-23
/www/game/server++/src/class/control/../../class/data_deal/../../class/app ...
drangon 发表于 2010-08-23 16:57
赞同。。。
作者: davelv 发布时间: 2010-08-23
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28