[英]CppUtest example link error
--------------------Configuration: AllTests - Win32 Debug--------------------
Linking...
AllTests.obj : error LNK2001: unresolved external symbol "int externTestGroupMockDocumentation" (?externTestGroupMockDocumentation@@3HA)
AllTests.obj : error LNK2001: unresolved external symbol "int externTestGroupEventDispatcher" (?externTestGroupEventDispatcher@@3HA)
Debug/AllTests.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
AllTests.exe - 3 error(s), 0 warning(s)
為什么我會收到這些錯誤,我該如何解決?
想知道你是否解決了這個問題,
我面臨同樣的問題,雖然我有
IMPORT_TEST_GROUP(my_test_group);
在 AllTests.cpp 中並正確定義
TEST_GROUP(my_test_group) {};
根據 Grenning 先生的建議,在 my_test.cpp 中。
請注意,我已經能夠通過應用以下任一解決方法來編譯它:
1- 將包含 function 定義的 cpp 文件添加到 UnitTest 項目。 或者..
2- 在 header 文件中有 function 定義(如果您的 function 是模板,則為典型)
我不知道任何一個/任何建議是否正確(所以還沒有要求答案),但是,我在這里提到了我的解決方法,希望其他人會覺得它有幫助。
注意,我根據“D:\cpputest-3.6\docsWalkThrough_VS21010.docx”配置了 Visual Studio 2010 的 CppUTest-3.6
哈桑
你的 AllTests.cpp 中有這些行嗎?
IMPORT_TEST_GROUP(MockDocumentation)
IMPORT_TEST_GROUP(EventDispatcher)
如果這樣做,您還需要在構建中定義這些測試組:
TEST_GROUP(MockDocumentation)
TEST_GROUP(EventDispatcher)
詹姆士
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.