我正在写一个简单的Makefile,看起来像这样
CC=gcc CXX=g++ DEBUG=-g COMPILER=${CXX} a.out: main.cpp Mail.o trie.o Spambin.o ${COMPILER} ${DEBUG} main.cpp Mail.o trie.o Re2/obj/so/libre2.so trie.o: trie.cpp ${COMPILER} ${DEBUG} -c trie.cpp Mail.o: Mail.cpp ${COMPILER} ${DEBUG} -c Mail.cpp Spambin.o: Spambin.cpp ${COMPILER} ${DEBUG} -c Spambin.cpp clean: rm -f *.o
我有一个文件名config.h,这是Mail.cpp和Spambin.cpp所必需的,所以我有
#include“config.h”在Mail.cpp和Spambin.cpp中. config.h看起来像这样:
#ifndef __DEFINE_H__ #define __DEFINE_H__ #include<iostream> namespace config{ int On = 1; int Off = 0; double S = 1.0; } #endif
But when I try to compile the code it gives me Mail.o:(.data+0x8): multiple definition of `config::On' /tmp/ccgaS6Bh.o:(.data+0x8): first defined here Mail.o:(.data+0x10): multiple definition of `config::Off' /tmp/ccgaS6Bh.o:(.data+0x10): first defined here
有人可以帮我调试吗