Linking curl library problems

后端 未结 1 2033
天命终不由人
天命终不由人 2021-01-24 19:15

I\'m trying to build curl library sample program that downloads file from ftp. I\'m using Eclipse IDE , OS -Ubuntu.

I have installed curl using

相关标签:
1条回答
  • 2021-01-24 19:50

    You shall specify the linker option of -lcurl, at the location of C/C++ build -> Settings -> GCC C Linker -> Libraries in project properties.

    EDITED:

    Let's be more detailed.

    I see heades files in /usr/include/curl (I don't know where are c files)

    Typically such packages don't consist of source codes, instead they provide pre-compiled object files called libraries.bu all curl functions used in program are maked with 'undefined reference'.

    Looks Eclipse is happy with #include

    That's true since the path /usr/include/ is typically inside the include path (where the compiler tries to find the header files), so you don't need to setup anything for this.

    bu all curl functions used in program are maked with 'undefined reference'.

    In the code you use functions like curl_global_init without implementing them yourself, which means those functions are treated as external functions that are expected to be imported. You shall "tell" the linker where to find these functions (to be more exact, these symbols). That's done by using the option -l followed by the library name. And for specifying the paths of libraries, use -L.

    For further information, you could see the section of linker options in Option Sammary of GCC

    0 讨论(0)
提交回复
热议问题