C++经典错误 already defined in *****.obj 解决方法
2010-11-02 21:17
274 查看
我的程序是如下形状:一个头文件.h,一个主函数.cpp,一个操作函数.cpp。操作函数包含头文件,然后主函数包含操作函数.cpp。运行时出现错误:
错误症状:
Linking...
xz.obj : error LNK2005: "public: __thiscall XZ::XZ(void)" (??0XZ@@QAE@XZ) already defined in xzmain.obj
xz.obj : error LNK2005: "public: void __thiscall XZ::pdc(void)" (?pdc@XZ@@QAEXXZ) already defined in xzmain.obj
xz.obj : error LNK2005: "public: void __thiscall XZ::pcd(void)" (?pcd@XZ@@QAEXXZ) already defined in xzmain.obj
xz.obj : error LNK2005: "public: void __thiscall XZ::pzf(void)" (?pzf@XZ@@QAEXXZ) already defined in xzmain.obj
xz.obj : error LNK2005: "public: __thiscall XZ::~XZ(void)" (??1XZ@@QAE@XZ) already defined in xzmain.obj
Debug/xzmain.exe : fatal error LNK1169: one or more multiply defined symbols found
执行 link.exe 时出错.
解决方案一:
把主函数所包含的操作函数.cpp,改为头文件.h,然后就可以解决如上错误。
解决方案二:
重新打开编译器,重新打开刚才的文件,先打开主函数.cpp,然后编译运行,打开Fileview,其中有一个external dependencies,把头文件.h,和操作函数.cpp添加到这里,这样再编译运行主函数.cpp,程序运行成功!
文章转自:http://hi.baidu.com/3512/blog/item/d568bc340c002cb4d0a2d3d6.html
错误症状:
Linking...
xz.obj : error LNK2005: "public: __thiscall XZ::XZ(void)" (??0XZ@@QAE@XZ) already defined in xzmain.obj
xz.obj : error LNK2005: "public: void __thiscall XZ::pdc(void)" (?pdc@XZ@@QAEXXZ) already defined in xzmain.obj
xz.obj : error LNK2005: "public: void __thiscall XZ::pcd(void)" (?pcd@XZ@@QAEXXZ) already defined in xzmain.obj
xz.obj : error LNK2005: "public: void __thiscall XZ::pzf(void)" (?pzf@XZ@@QAEXXZ) already defined in xzmain.obj
xz.obj : error LNK2005: "public: __thiscall XZ::~XZ(void)" (??1XZ@@QAE@XZ) already defined in xzmain.obj
Debug/xzmain.exe : fatal error LNK1169: one or more multiply defined symbols found
执行 link.exe 时出错.
解决方案一:
把主函数所包含的操作函数.cpp,改为头文件.h,然后就可以解决如上错误。
解决方案二:
重新打开编译器,重新打开刚才的文件,先打开主函数.cpp,然后编译运行,打开Fileview,其中有一个external dependencies,把头文件.h,和操作函数.cpp添加到这里,这样再编译运行主函数.cpp,程序运行成功!
文章转自:http://hi.baidu.com/3512/blog/item/d568bc340c002cb4d0a2d3d6.html
相关文章推荐
- C++经典错误之already defined in *****.obj解决方法[转]
- Java中调用c/c++语言出现Exception in thread "main" java.lang.UnsatisfiedLinkError: Test.testPrint(Ljava/lang/String;)V...错误
- Maven经典错误之三:was cached in the local repository, resolution will not be reattempted until the upda
- Handling Errors Exceptionally Well in C++ 在C++中良好地捕获意外的错误
- C++经典错误之already defined in .obj解决方法之补充
- C++经典错误之already defined in .obj解决方法之补充
- C++中关于assign 0 to _debugger_hook_dummy so that the function is not folded in retail的错误
- 经典基础教程---Programming TCP/IP Windows Sockets in C++
- QT经典错误:/usr/include/qt4/QtCore/qatomic_i386.h:132: error: impossible constraint in 'asm'
- C++编译错误no type named ‘iterator_category’ in ‘class Point’,distance重名
- ios 经典错误:"duplicate symbol _OBJC_METACLSS_$_类名 in"
- C++ - "'itoa' was not declared in this scope" 错误
- 经典错误重现->Java RunTime Environment (JRE) or Java Development Kit (JDK) must be available in order to
- 关于错误 Unhandled exception in (KERNEL32.DLL):0xE06D7363:Microsoft C++ Exce vc and access insert 记录
- c++链接错误:error LNK2005:*** already defined in ***
- 错误检查--Thinking in C++
- C++经典错误之already defined in .obj解决方法之补充
- C++中stray\'\\241\'in program 错误
- C++ - 错误: " 'strdup' was not declared in this scope "
- C++编译错误:multiple types in one declaration