c++ undefined references with static library

后端 未结 5 1437
青春惊慌失措
青春惊慌失措 2020-12-02 09:55

I\'m trying to make a static library from a class but when trying to use it, I always get errors with undefined references on anything. The way I proceeded was creating the

5条回答
  •  死守一世寂寞
    2020-12-02 10:34

    Another possible cause: forgetting extern "C".

    I ran into this because I was trying to link a C++ program with a C static library. The library's header didn't have extern "C" so the linker was looking for a mangled function name, and the library actually had the unmangled function name.

    It took a while to figure out what was going on, so I hope this helps someone else.

提交回复
热议问题