C-library not linking using gcc/g++

后端 未结 3 1128
终归单人心
终归单人心 2020-12-28 15:19

I have a c-library which I use in gcc. The library has the extension .lib but is always linked as a static library. If i write a program which uses the library as c-code, ev

3条回答
  •  自闭症患者
    2020-12-28 15:58

    Does your header file have the usual

    #ifdef __cplusplus
    extern "C" {
    #endif
    
    // ...
    
    #ifdef __cplusplus
    } /* extern "C" */
    #endif
    

    to give the library functions C linkage explicitly.

    .cpp files are compiled with C++ linkage i.e. name mangling by default.

提交回复
热议问题