如何在VC ++中管理更大的项目?

时间:2015-01-17 11:30:56

标签: visual-studio visual-c++ project-management debug-symbols

我已经写了很长时间的小片段或单个项目,但这次我遇到了一个“解决方案”,需要连接多个项目。

那么,为什么需要呢?因为我的项目以下列方式站起来:

  • 核心位于静态库中
  • 有一个可执行文件需要核心功能
  • 有一个需要核心功能的DLL
  • 其他一些小项目

好吧,它甚至都不难,这是合乎逻辑的。我不想每次都编译核心,所以我把它放在lib中。当我开始编译时,唯一的问题就开始发生了。

简单的#pragma comment(lib,"mylibrary.lib")还不够,解决方案无法找到此文件。我必须做以下技巧,才能编译我的解决方案:#pragma comment(lib,"..\\Release\\mylib.lib")

当然,这不是最好的解决方案,因为如果我在调试模式下编译它会怎么样?也许我可以写一个定义,但它感觉不太专业。编译后甚至出现问题。我收到了很多警告:

2>Lib32Anticheat.lib(disasm.obj) : warning LNK4204: 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\Lib32Anticheat.pdb' is missing debugging information for referencing module; linking object as if no debug info
2>Lib32Anticheat.lib(disasm_x86.obj) : warning LNK4204: 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\Lib32Anticheat.pdb' is missing debugging information for referencing module; linking object as if no debug info
2>Lib32Anticheat.lib(cpu.obj) : warning LNK4204: 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\Lib32Anticheat.pdb' is missing debugging information for referencing module; linking object as if no debug info
2>LIBCMT.lib(dyn_tls_dtor.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(dyn_tls_dtor.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(dyn_tls_init.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(dyn_tls_init.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(matherr_detection.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(matherr_detection.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(guard_support.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(guard_support.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(gs_cookie.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(gs_cookie.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(gs_report.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(gs_report.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(gs_support.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(gs_support.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(pesect.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(pesect.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(cpu_disp.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(cpu_disp.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(ehprolg3.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(ehprolg3.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(secchk.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(secchk.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(loadcfg.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(loadcfg.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(argv_mode.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(argv_mode.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(commit_mode.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(commit_mode.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(denormal_control.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(denormal_control.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(file_mode.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(file_mode.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(fltused.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(fltused.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(invalid_parameter_handler.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(invalid_parameter_handler.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(matherr.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(matherr.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(new_mode.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(new_mode.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(thread_locale.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(thread_locale.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(ehvecdtr.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(ehvecdtr.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(std_type_info_static.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(std_type_info_static.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(tncleanup.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(tncleanup.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(delete_array.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(delete_array.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(delete_scalar.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(delete_scalar.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(new_array.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(new_array.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(new_scalar.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(new_scalar.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(throw_bad_alloc.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(throw_bad_alloc.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(thread_safe_statics.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(thread_safe_statics.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(exe_main.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(exe_main.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(tlssup.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(tlssup.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(initializers.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(initializers.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(utility.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(utility.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(default_precision.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(default_precision.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(utility_desktop.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(utility_desktop.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(utility_static.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(utility_static.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>LIBCMT.lib(initsect.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'LIBCMT.lib(initsect.obj)' or at 'C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\libcmt.pdb'; linking object as if no debug info
2>  Win32Anticheat.vcxproj -> C:\Users\Unknown User\Desktop\Lib32Anticheat\Release\Win32Anticheat.exe

因此,在该日志之后,我认为它缺少调试信息,这可能使查找bug变得更难。在调试模式下,我没有得到这样的警告,但我认为我应该调整一些东西或做一些不同的事情,以确保释放模式不会发出警告。

1 个答案:

答案 0 :(得分:1)

就个人而言,我不会将您产品的核心作为静态库。你的DLL和你的EXE都将获得它自己的副本,它将是两个截然不同的独立实体。任何应该是静态和单一的东西,都会翻倍。并且您的程序可能无法按预期运行。

其次,我认为无法抑制LNK4099警告。如果你得到它们,可能是因为你在构建调试时链接在发布库中,反之亦然。

我个人不会使用#pragma语句进行链接。我以前看过它,这些项目总是很差。在项目中指定库链接或生成文件:这就是它们的用途。