美文网首页
Undefined symbols for architectu

Undefined symbols for architectu

作者: ben大福 | 来源:发表于2020-08-26 22:59 被阅读0次

    连结时发生错误。原因是找不到源代码中使用的函数或全局变量。

    错误有多种原因和解决方案

    函数名称错误

    tset(); 
    test(); // 拼写正确
    

    功能未定义

    /* file.h */
    extern void a(); // 生命
    /* file.c */
    void a() {}      // 定义(必须定义)
    

    头文件不包括在内

    // 正确的引入头文件
    #include <sqlite3.h>
    #include <zlib.h>
    

    外部库无法链接

    clang -lsqlite3 hello.c
    

    C和C ++文件混合

    /* file.hpp */
    #ifdef __cplusplus
    extern "C" {
      void foo();
      void bar();
    }
    #endif
    

    模板实体不存在

    /* file.hpp */
    template<class T> T max(T a, T b);
    /* file.cpp */
    template<class T> T max(T a, T b) { return a < b ? b : a; }
    

    相关文章

      网友评论

          本文标题:Undefined symbols for architectu

          本文链接:https://www.haomeiwen.com/subject/cxkqsktx.html