Build Succeeded, but no .lib file gets created

前端 未结 10 1540
执笔经年
执笔经年 2021-01-31 13:37

I inherited a substantial amount of code, including a visual studio project that is supposed to (as best as I can tell) build a .lib file. Visual studio says \"... Generating C

10条回答
  •  情深已故
    2021-01-31 14:31

    My issue was that in the projects Properties>C/C++>CommandLine, I had specfied the switch incorrectly. That is instead of writting /D_HASHING_BUILD_DLL I had written /D_Hashing_BUILD_DLL.

    Side note:
    This is how I build my DLL/Lib files in Visual studio : (and my Hashing.h looks like this: )

    #ifndef HASHING_H
    #define HASHING_H
    
    /* If we are we on Windows, we want a single define for it.*/
    #if !defined(_WIN32) && (defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__))
    #define _WIN32
    #endif /* _WIN32 */
    
    #if defined(_WIN32) && defined(_HASHING_BUILD_DLL)
    /* We are building Hashing as a Win32 DLL */
    #define HASHING_API __declspec(dllexport)
    #elif defined(_WIN32) && defined(HASHING_DLL)
    /* We are calling Hashing as a Win32 DLL */
    #define HASHING_API __declspec(dllimport)
    #elif defined(__GNUC__) && defined(_HASHING_BUILD_DLL)
    /* We are building Hashing as a shared / dynamic library */
    #define HASHING_API __attribute__((visibility("default")))
    #else
    /* We are building or calling HASHING as a static library */
    #define HASHING_API
    #endif
    
    //your inlcudes
    
    class HASHING_API MyClass
    {
    //...
    };
    
    #endif // !HASHING_H
    

    and in the path I stated earlier, I just use the switch I defined here and there you go, the DLL is built just fine!

提交回复
热议问题