简体   繁体   English

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

[英]How to manage a bigger project in VC++?

I've been writing small snippets or single projects for quite long time, but this time I came across a 'solution', which requires more than one project to be attached. 我写小片段或单个项目已经很长时间了,但是这次我遇到了一个“解决方案”,需要附加多个项目。

So, why does this needed? 那么,为什么需要这样做呢? Because my project stands up the following way: 因为我的项目以下列方式站立:

  • The core is in a static library 核心在静态库中
  • There's an executable which requires functions from the core 有一个可执行文件需要核心功能
  • There's a DLL which requires functions from the core 有一个DLL需要核心功能
  • Some other minor projects 其他一些小型项目

Okay, it's not even hard, it's logical. 好吧,这并不难,这是合乎逻辑的。 I don't want to compile the core each time, so I put it in a lib. 我不想每次都编译内核,因此将其放在一个lib中。 The only problem started to occur, when I started to compile. 当我开始编译时,唯一的问题开始出现。

A simple #pragma comment(lib,"mylibrary.lib") wasn't enough, the solution couldn't find this file. 一个简单的#pragma comment(lib,"mylibrary.lib")还不够,解决方案找不到该文件。 I had to do the following trick, to compile my solution: #pragma comment(lib,"..\\\\Release\\\\mylib.lib") . 我必须执行以下技巧来编译我的解决方案: #pragma comment(lib,"..\\\\Release\\\\mylib.lib")

Of course it's not the best solution, since what if I'm compiling it in debug mode? 当然,这不是最好的解决方案,因为如果我以调试模式进行编译怎么办? Maybe I could write a define, but it doesn't feel quite professional. 也许我可以写一个定义,但是感觉并不专业。 Even a problem occurs after compilation. 编译后甚至出现问题。 I'm getting tons of warnings: 我收到大量警告:

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

So, after that log, I assume that it's missing debug information, which can make bug finding harder. 因此,在该日志之后,我假定它缺少调试信息,这会使查找错误变得更加困难。 In Debug mode I'm not getting such warnings, but I think that I should adjust something or make something different just to make sure that Release mode isn't giving such warnings. 在“调试”模式下,我没有收到此类警告,但我认为我应该进行一些调整或做出其他更改,以确保“发布”模式未发出此类警告。

Personally I would not make the core of your product a static library. 我个人不会将您产品的核心设为静态库。 Your DLL and your EXE will each get their own copy of it, which will be two distinct and separate entities. 您的DLL和EXE将各自获得其自己的副本,这将是两个不同且独立的实体。 Anything that is supposed to be static and single, will instead be doubled up. 那些应该是静态的和单一的东西,将被加倍。 And your program may not behave as expected. 并且您的程序可能无法按预期方式运行。

Second, I think that LNK4099 warnings cannot be suppressed. 其次,我认为LNK4099警告不能被抑制。 If your getting them, it's probably because you are linking in a release lib when you are building debug, or vice versa. 如果得到它们,可能是因为在构建调试时链接了发行版库,反之亦然。

I would personally not use #pragma statements to do your linking. 我个人不会使用#pragma语句进行链接。 I've seen it done in the past, and those projects were always poorly built. 我过去看过它,而且那些项目总是建得不好。 Specify your library linkage in the project or make files: that is what they are there for. 在项目中指定您的库链接或生成文件:这就是它们的用途。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM