Skip to main content
added 288 characters in body
Source Link
modanashar
  • 171
  • 3
  • 10

In MSVC it's possible to write:

// in Lib.h
#if USE_OLD_LIB

    #pragma comment(lib, "old_lib.lib")
    #include "old_lib.h"

#else

    #pragma comment(lib, "new_lib.lib")
    #include "new_lib.h"

#endif

How can I do this without having the pragma comment support in GCC?

Edit: I know it's possible to use a make file, but the USE_OLD_LIB conditional macro is connected to some logic inside another library like the following:

// in Lib2.h
#if OBJ_SIZE > 20
#define USE_OLD_LIB
#endif

So, it would be a hassle to use a make file for it.

In MSVC it's possible to write:

// in Lib.h
#if USE_OLD_LIB

    #pragma comment(lib, "old_lib.lib")
    #include "old_lib.h"

#else

    #pragma comment(lib, "new_lib.lib")
    #include "new_lib.h"

#endif

How can I do this without having the pragma comment support in GCC?

In MSVC it's possible to write:

// in Lib.h
#if USE_OLD_LIB

    #pragma comment(lib, "old_lib.lib")
    #include "old_lib.h"

#else

    #pragma comment(lib, "new_lib.lib")
    #include "new_lib.h"

#endif

How can I do this without having the pragma comment support in GCC?

Edit: I know it's possible to use a make file, but the USE_OLD_LIB conditional macro is connected to some logic inside another library like the following:

// in Lib2.h
#if OBJ_SIZE > 20
#define USE_OLD_LIB
#endif

So, it would be a hassle to use a make file for it.

Source Link
modanashar
  • 171
  • 3
  • 10

conditional linking in GCC

In MSVC it's possible to write:

// in Lib.h
#if USE_OLD_LIB

    #pragma comment(lib, "old_lib.lib")
    #include "old_lib.h"

#else

    #pragma comment(lib, "new_lib.lib")
    #include "new_lib.h"

#endif

How can I do this without having the pragma comment support in GCC?