Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Library importing: #pragma comment VS Visual studio project input

Tags:

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

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?

like image 918
Benjamin Avatar asked Jun 09 '11 02:06

Benjamin


People also ask

What is import to library?

An import library (. lib) file contains information the linker needs to resolve external references to exported DLL functions, so the system can locate the specified DLL and exported DLL functions at run time. You can create an import library for your DLL when you build your DLL.

What is importing library in Python?

Import in python is similar to #include header_file in C/C++. Python modules can get access to code from another module by importing the file/function using import. The import statement is the most common way of invoking the import machinery, but it is not the only way. import module_name.

What does from library import * mean?

It just means that you import all(methods, variables,...) in a way so you don't need to prefix them when using them.


1 Answers

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.

like image 142
Hans Passant Avatar answered Jun 22 '23 22:06

Hans Passant