Remove hardcode pragma for library linkage

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
Jiang
Posts: 77
Joined: Tue Feb 20, 2007 11:03 am

Remove hardcode pragma for library linkage

Post by Jiang »

As we know the all the examples in irrlicht use following pragma

Code: Select all


#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#endif

or something like that (_MSC_VER) to detect windows platform and link the necessary library.

I suggest removing the above hardcode pragma and adding irrlicht.lib to the linker option. This is because:

1. Source code should not have such a strong dependency on library name(consider you must run both of the release/debug build...).

2. #pragma is actually not portable and macros must be used for above purpose, which is not clean. And for compilers other than visual studio, the above pragma is meaningless.

3. It saves nothing, the library search path still must be specified in linker option and why not just add the library name there directly?

Regards,

Jiang
Spkka
Posts: 32
Joined: Fri Jan 02, 2009 8:30 am

Post by Spkka »

Its ignoring the pragma comment on windows using code::blocks
I linked it under project options also
Dorth
Posts: 931
Joined: Sat May 26, 2007 11:03 pm

Post by Dorth »

On the contrary!
If anything it is an EXCELLENT way of telling dependencies across multiple port of the system. While another compiler or os can't use the pragma, you still know all the libs used by the original dev, giving you all the needed info to compile yourself.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

I agree that it shouldn't be there really as it's not cross platform or even cross compiler on the same platform...

Having said that it's just used in the examples, not Irrlicht, so it's really up to you whether you use it or not....
Image Image Image
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

I'm not fanatical about it, but it seems to be an effective example of one way of linking the Irrlicht lib.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Spkka
Posts: 32
Joined: Fri Jan 02, 2009 8:30 am

Post by Spkka »

Rogerborg is true that its good to show it in a example like this for new people. Its was one of the first things i googled when i started using irrlicht.

I think it would be more usefull to learn people how to link libraries using the search directories/linkers etc instead
Post Reply