简体   繁体   中英

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
  • 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. 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. I had to do the following trick, to compile my solution: #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. 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. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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