Search code examples
pythoncmacossetuptoolsqr-code

Adding a library to C


I'm working with python, but I have a basic understanding of packaging with C. However I don't know how to build the c 'path.' Also, my google searches seem to be failing me returning results on c++. Or is that my solution?

The objective is to include qrencode.h, I can surly put it in the same folder but I'd like to know how to link to it instead.

Thanks!

PS. As always, addition to read material that is relevant would be much appreciated!


Solution

  • You use an include directive to include the *.h file in your C/C++ code:

    #include "qrencode.h"
    

    As @Ignacio Vazquez-Abrams says, though, that's just a header, which declares functions; you need the actual functions, and they'll be in a *.dylib or *.so file, which needs to be linked into an executable. Compiling is turning one *.c file into a *.o file; linking is when you put all the *.o files and libraries together into an application. The -L option on the linker command line tells it where to look for libraries; the -l option tells it to include a library.