#pragma comment(lib, "opengl32.lib")
I''ve found a nice way to #include lib files in project:
#pragma comment(lib, "opengl32.lib")
is this the same as chainging settings of the project, or does it make build process longer?
Kosma
It has the same effect.
It is unnoticeably longer.
It is not portable.
[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
It is unnoticeably longer.
It is not portable.
[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
what do you mean not portable?? most compilers support it. I''ve been using it for ever using vc++ and cbuilder
quote:
Original post by Fruny
It has the same effect.
It is unnoticeably longer.
It is not portable.
[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
Yes, but now I don''t have to go into my project settings to add my libraries. I have multiple files that I include in my projects (my own personal libraries of code)... some require certain libs to be included, and they all include it themselves without me having to bother remember which .lib file I need to add to my project settings. And, even if it''s not portable, it''s easy enough to comment out 2-3 lines and add the proper libs in if the compiler doesn''t support it (you have the lib name written right there!!). If you just add it to the settings, that''s not exactly portable either, since when you create a new project in another compiler, you will have to change the settings anyways, so I don''t see what you''re losing? That, and now you have the .lib names right in front of you, otherwise you''d have to copy down which ones you need, or put them in as a comment.
what do you mean not portable?? most compilers support it. I''ve been using it for ever using vc++ and cbuilder
Pragmas are, by definition, compiler-specific. Unsupported pragmas are just ignored. You can''t generalize from two examples.
If you just add it to the settings, that''s not exactly portable either, since when you create a new project in another compiler, you will have to change the settings anyways, so I don''t see what you''re losing?
I''m not criticising the use of this pragma - it is convenient, I''m just stating the facts.
That, and now you have the .lib names right in front of you, otherwise you''d have to copy down which ones you need, or put them in as a comment.
You may also end up scattering your library dependencies all over your source files instead of having them where they belong - in the linker settings. In a large (real world) project this would become a nightmare.
[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
Pragmas are, by definition, compiler-specific. Unsupported pragmas are just ignored. You can''t generalize from two examples.
If you just add it to the settings, that''s not exactly portable either, since when you create a new project in another compiler, you will have to change the settings anyways, so I don''t see what you''re losing?
I''m not criticising the use of this pragma - it is convenient, I''m just stating the facts.
That, and now you have the .lib names right in front of you, otherwise you''d have to copy down which ones you need, or put them in as a comment.
You may also end up scattering your library dependencies all over your source files instead of having them where they belong - in the linker settings. In a large (real world) project this would become a nightmare.
[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement