In MSVC you have the
pragma to tell the linker to include that library. Does gcc have anything similar, or is the -l command line switch the only way?Code:#pragma comment(lib, "library-name")
In MSVC you have the
pragma to tell the linker to include that library. Does gcc have anything similar, or is the -l command line switch the only way?Code:#pragma comment(lib, "library-name")
The "-l" switch is portable while the pragma directive is not, so why bother.
How is "-l" any more portable? It's just as gcc specific as that pragma is microsoft specific.
And yes, using directx libraries in a discussion about portability might seem stupid But it was hard finding a standard function that the linker didn't include a library for by default.Code:C:\src\cpp>cl 1.cpp -ld3d9 Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.21003.01 for 80x86 Copyright (C) Microsoft Corporation. All rights reserved. cl : Command line warning D9002 : ignoring unknown option '-ld3d9' 1.cpp Microsoft (R) Incremental Linker Version 10.00.21003.01 Copyright (C) Microsoft Corporation. All rights reserved. /out:1.exe 1.obj 1.obj : error LNK2019: unresolved external symbol _Direct3DCreate9@4 referenced in function _main 1.exe : fatal error LNK1120: 1 unresolved externals
Guess I work only on the ones that have a CLI and the "-l' switch is common to all of 'em.
Okey, if it can't be done then it can't be done. No big deal, I normally compile under cygwin if I need to make sure my code is portable.
I was just curious if you could do something like
but I guess not.Code:#if defined(MSVC) #pragma ...etc #elif defined(GCC) #includelib .. #endif