我创建了一个简单的使用静态库的拼写检查程序,因为我希望其他人能够使用拼写检查功能。这两个问题区域位于库源代码和库头中。当我编译库时,这是我得到的错误:C++静态库链接器错误
ar -cvq libspellcheck.a checker.o
a - checker.o
g++ -o spell-check main.o meta.o libspellcheck.a
libspellcheck.a(checker.o): In function `check_spelling(char*, char*)':
checker.cpp:(.text+0x0): multiple definition of `check_spelling(char*, char*)'
libspellcheck.a(checker.o):checker.cpp:(.text+0x0): first defined here
collect2: ld returned 1 exit status
make: *** [spellcheck] Error 1
checker.cpp代码位于here。 头文件(spellcheck.h)位于here。
我想知道是什么导致上述错误,因为我无法弄清楚。
谢谢。你的解决方案完美运作 – Igor