lib curl symbol not found

痴心易碎 提交于 2019-12-30 06:12:05

问题


Really stupid C question.

I'm trying to build the source code here so I can start on modifying it for myself

http://curl.haxx.se/libcurl/c/ftpget.html

I download the file, then run

gcc -o test ftpget.c

and get

Undefined symbols:
  "_curl_global_init", referenced from:
      _main in ccFchguB.o
  "_curl_easy_perform", referenced from:
      _main in ccFchguB.o
  "_curl_easy_setopt", referenced from:
      _main in ccFchguB.o
      _main in ccFchguB.o
      _main in ccFchguB.o
      _main in ccFchguB.o
  "_curl_easy_cleanup", referenced from:
      _main in ccFchguB.o
  "_curl_easy_init", referenced from:
      _main in ccFchguB.o
  "_curl_global_cleanup", referenced from:
      _main in ccFchguB.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

which makes no sense to me, because

/usr/local/include/curl/curl.h

exists and has these functions. I'm sure this is some basic c compilation thing I'm missing.

Many thanks for any pointers.


回答1:


You need to link with the curl library:

gcc -o test ftpget.c -lcurl


来源:https://stackoverflow.com/questions/3840957/lib-curl-symbol-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!