Library importing: #pragma comment VS Visual studio project input

  1. using #pragma comment(lib, "../../xxx.lib")
  2. using Visual studio project option

What is the advantage and disadvantage between two method? I'm finding way which is better convenient to manage for many projects.

And what method does Microsoft recommend?


The advantage of #pragma comment is that the user of your library cannot forget to add the setting. Or add the wrong one, it is not uncommon to get lost at the difference between the debug and release build and the /MD vs /MT build. One disadvantage is that troubleshooting linker problems can be difficult in some cases.

There's a third way that's hard to beat for convenience in a solution. Right-click the project that requires the library and click Project Dependencies. Tick the library project. This ensures that the library project is always built before the project and the .lib is automatically added.

Need Your Help

Get the request URL in a JSF bean?

java jsf servlets

How do you get the request URL in a bean backing a JSF page? I've been looking through the FacesContext docs and the best way I could find seems terribly long:

Is it possible to generate random numbers using physical sensors?

random arduino microcontroller avr entropy

I've heard about people using light sensors, geiger counters, and other physical sensors to generate random numbers, but I'm skeptical. Is there really a way to generate random numbers from taking