undefined reference to function declared in *.h file

后端 未结 4 789
挽巷
挽巷 2020-12-10 16:41

I am a unskilled programmer and new to linux, I run into a problem when complining. I have two files \'ex_addinst.c\' and \'lindo.h\' in the same folder, I input command :

4条回答
  •  伪装坚强ぢ
    2020-12-10 17:25

    Ok, lindo.h contains the prototypes for those functions, but where are the functions actually defined? If they're in another C file you need to compile that one too, and link both the object files together.

    If the functions are part of another static library, you need to tell the linker to link that library along with your object file.

    If they're defined with a shared library, you can probably get g++ to still link to it at compile time, and take care of the library loading etc. Otherwise you'll need to load the library at runtime and reference the functions from the library. This Wikipedia article on dynamic loading of shared libraries contains some example code.

提交回复
热议问题