#pragma comment(lib, “xxx.lib”) equivalent under Linux?

There doesn’t seem to be any mention of any equivalent pragmas in the GCC manual’s page on pragmas.

One reason I saw for GCC not supporting linking in source code was that sometimes, correct linking depends on link order; and this would require you to make sure that the linking order happens correctly no matter the order of compilation. If you’re going to go to that much work, you may as well just pass the linker arguments on the command line (or otherwise), I suppose.

Leave a Comment