链接静态C库和C ++代码时出现“未定义的引用”错误
我有一个测试文件(仅用于链接测试),其中我使用我自己的/ 库调用来重载new/ delete运算符。但是在链接静态库时,我一直得到“未定义的引用”错误,即使我改变了和的顺序。但是一切都适用于连接这个库的其他C程序。我对这个问题很困惑,并且感谢任何线索。mallocfreelibxmalloc.atest.o-lxmalloc
错误消息:g++ -m64 -O3 -I/usr/include/ethos -I/usr/include/nacl/x86_64 -c -o test.o test.cpp
g++ -m64 -O3 -L. -o demo test.o -lxmalloc
test.o: In function `operator new(unsigned long)':
test.cpp:(.text+0x1): undefined reference to `malloc(unsigned long)'
test.o: In function `operator delete(void*)':test.cpp:(.text+0x11): undefined reference to `free(void*)'
test.o: In function `operator new[](unsigned long)':
test.cpp:(.text+0x21): undefined reference to `malloc(unsigned long)'test.o: In function `operator delete[](void*)':
test.cpp:(.text+0x31): undefined refe