No #pragma comment() in C::B?

When I started using this IDE I was a little dissapointed, since it ignored #pragma comment() directives for linking libraries.
However that was one thing I was ready to forgive untill I came up with this:

Creating a WIN32 application you end up with Win95 style(stuff works, but looks old..), so in VS all I had to do was add this at the begining:
1
2
3
#pragma comment(linker,"\"/manifestdependency:type='win32'name='Microsoft.Windows.Common-Controls'\
                version='6.0.0.0' processorArchitecture='*'\
                publicKeyToken='6595b64144ccf1df' language='*'\"") 

And voila! There was new, pretty style of win7/vista. However I can't figure how to do the same on C::B...Does anyone have experience with this?
The behavior of #pragma is implementation-defined (either that or just undefined. I can't remember ATM). There's no point in expecting that two different compilers will respond to the same #pragma the same way.

You probably can do in MinGW most of that fluff you passed to the linker, but you'll have to do it with command line options (Code::Blocks has a configuration dialog for that).
Last edited on
@ Tofiffe
Is there not a Windows XP Look and Feel option on your Plugins menu??

There is on my codeblocks version ( 10.5).
This will put a manifest file in the Release directory - it doesn't seem to work for Debug - but I just copied the manifest file from the Release directory to the Debug directory.
that's it guestgulkan! That did it!

Thanks very much! This is even easier than in VS :P
I always thought that using source files to pass linker options was abominable.
Last edited on
I agree with hanst99. Command-line options, environment variables and configuration files are enough (although I never use environment variables, and configuration files only when necessary).
I always thought that using source files to pass linker options was abominable.


It's quite handy when designing libraries. You can just #include the library header file and it will automatically link to the appropriate lib(s). Makes it much easier for users.
Now you're even suggesting putting those in library headers? Show me the guy who'll appreciate that. You usually don't want to link to a library every single time you compile something that #includes a header from it.
It's only easier when the user has a compiler that understands that pragma and a linker that understands those options. If they dare use a different toolchain than you, then chances are good it won't work as intended (if at all) and might even make things more complicated.

If you want to make things easier for users, use something like CMake. At least that behaves the same with every compiler/platform it supports.
Now you're even suggesting putting those in library headers? Show me the guy who'll appreciate that.
That's how Boost does it in VC++. Beats manually linking to the appropriate libs.

If you want to make things easier for users, use something like CMake.
Well, they're not mutually exclusive. Boost does something like that, as well, only they use their own generator.
So, Boost has a program that automatically writes those pragmas to their header files? Also, on Linux you wouldn't have to have pragmas or manually link to any libraries, since you can just put `pkg-config --libs $library` in your LDFLAGS.
No, the program has the same purpose as CMake.
And yes, that's totally not the same as manually linking a library.
hanst wrote:
You usually don't want to link to a library every single time you compile something that #includes a header from it.


Um... yeah you do. If you are using anything in the header, you'll have to link to the library or you'll get linker errors. And if you aren't using anything that requires linking the library, you probably shouldn't be including the header.

The two go hand in hand.

chrisname wrote:
If they dare use a different toolchain than you, then chances are good it won't work as intended (if at all) and might even make things more complicated.


Right. It only works for a specific toolchain. However putting it there doesn't cause anything to fail if people aren't using that toolchain.

Why not put it there for where it's supported to make it easier for some people? For those people using a different toolchain, they can link the libraries the usual way.

Since it's compiler specific... #ifdef it out:

1
2
3
#ifdef _MSC_VER
#pragma comment(lib, "yourlib.lib")
#endif 


Doesn't hurt anyone to have it there, and it helps everyone using VS.

If you want to make things easier for users, use something like CMake. At least that behaves the same with every compiler/platform it supports.


That is an entirely separate issue. CMake is useful for building libraries. It does nothing to help the user link to them in their own programs.
Last edited on
@helios,
I don't see how using pkg-config is any more manual than using #pragma.

@Disch,
That makes more sense.
Topic archived. No new replies allowed.