错误:VS单元测试出现LNK2019错误

解决方法:

To link the tests to the object or library files

If the code under test doesn't export the functions that you want to test, you can add the output .obj or .lib file to the dependencies of the test project. Modify the test project's properties to include the headers and library or object files that are required for unit testing.

  1. In Solution Explorer, on the shortcut menu of the test project, choose Properties. The project properties window opens.

  2. Select the Configuration Properties > Linker > Input page, then select Additional Dependencies.

    Choose Edit, and add the names of the .obj or .lib files. Don't use the full path names.

  3. Select the Configuration Properties > Linker > General page, then select Additional Library Directories.

    Choose Edit, and add the directory path of the .obj or .lib files. The path is typically within the build folder of the project under test.

  4. Select the Configuration Properties > VC++ Directories page, then select Include Directories.

    Choose Edit, and then add the header directory of the project under test.

发布了2 篇原创文章 · 获赞 0 · 访问量 552

猜你喜欢

转载自blog.csdn.net/dongyw10/article/details/105716688