
在LINUX的多线程通信中的问题!求指教!
/tmp/cci83lvM.o:(.data+0x0):multipledefinitionof`available_id'/tmp/ccZ4MNqq.o:(.data+...
/tmp/cci83lvM.o:(.data+0x0): multiple definition of `available_id'
/tmp/ccZ4MNqq.o:(.data+0x0): first defined here
/tmp/cci83lvM.o:(.bss+0x0): multiple definition of `msgid'
/tmp/ccZ4MNqq.o:(.bss+0x0): first defined here
/tmp/cci83lvM.o: In function `send_msg':
msg_svr.c:(.text+0x4c): multiple definition of `send_msg'
/tmp/ccZ4MNqq.o:msg_client.c:(.text+0x0): first defined here
/tmp/cci83lvM.o: In function `time2str':
msg_svr.c:(.text+0xf0): multiple definition of `time2str'
/tmp/ccZ4MNqq.o:msg_client.c:(.text+0xa4): first defined here
/tmp/cci83lvM.o: In function `init_msg_queue':
msg_svr.c:(.text+0x12c): multiple definition of `init_msg_queue'
/tmp/ccZ4MNqq.o:msg_client.c:(.text+0xe0): first defined here
/tmp/cci83lvM.o: In function `main':
msg_svr.c:(.text+0x1d3): multiple definition of `main'
/tmp/ccZ4MNqq.o:msg_client.c:(.text+0xb48): first defined here
collect2: ld 返回 1 展开
/tmp/ccZ4MNqq.o:(.data+0x0): first defined here
/tmp/cci83lvM.o:(.bss+0x0): multiple definition of `msgid'
/tmp/ccZ4MNqq.o:(.bss+0x0): first defined here
/tmp/cci83lvM.o: In function `send_msg':
msg_svr.c:(.text+0x4c): multiple definition of `send_msg'
/tmp/ccZ4MNqq.o:msg_client.c:(.text+0x0): first defined here
/tmp/cci83lvM.o: In function `time2str':
msg_svr.c:(.text+0xf0): multiple definition of `time2str'
/tmp/ccZ4MNqq.o:msg_client.c:(.text+0xa4): first defined here
/tmp/cci83lvM.o: In function `init_msg_queue':
msg_svr.c:(.text+0x12c): multiple definition of `init_msg_queue'
/tmp/ccZ4MNqq.o:msg_client.c:(.text+0xe0): first defined here
/tmp/cci83lvM.o: In function `main':
msg_svr.c:(.text+0x1d3): multiple definition of `main'
/tmp/ccZ4MNqq.o:msg_client.c:(.text+0xb48): first defined here
collect2: ld 返回 1 展开
展开全部
你的问题在于多重定义,根源在于源文件没有加
#ifndef XXX
#def XXX
你的code
#endif
一个源文件被编译两次
#ifndef XXX
#def XXX
你的code
#endif
一个源文件被编译两次
更多追问追答
追问
那个/tmp 是文件夹吗? #endif 是要删除一个/
追答
宏放在文件的首尾,保证每次你的code只编译一次
/tmp是文件夹
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询