5

I'm getting a linker error whenever I #include in my program. I have downloaded libcurl from haxx.se, compiled libcurl.dll, and added -Icurl to my GCC options when compiling (as well as tried adding a direct path using -L to the dll). However, I still get the following errors:

undefined reference to `_imp__curl_easy_init'
undefined reference to `_imp__curl_easy_setopt'
undefined reference to `_imp__curl_easy_setopt'
undefined reference to `_imp__curl_easy_perform'
undefined reference to `_imp__curl_easy_strerror'
undefined reference to `_imp__curl_easy_cleanup'

My compile command includes this:

-Icurl -L"F:/GCCnew/lib/libcurl.dll"

What am I doing wrong? I suspect it's something simple but I can't work it out and searching hasn't given me a solution that doesn't use something like Code::blocks.

2
  • hello there, running into similar issues. did you ever manage to find a solution? Commented Sep 30, 2020 at 15:50
  • @Clyme sorry, it's been quite a long time since I posted this and I do not remember! Commented Oct 5, 2020 at 0:37

1 Answer 1

1

My compile command includes this:

-Icurl -L"F:/GCCnew/lib/libcurl.dll"

If you use mingw gcc, then:

  • First, -L must have a folder name, not a library name.
  • Second, there must be '-l' option. For example -lcurl.
  • Third, -Icurl is irrelevant to your linker error

So the command to build might look like:

gcc your-file.c -o executable_name -L"F:/GCCnew/lib" -lcurl

Useful links:

Sign up to request clarification or add additional context in comments.

2 Comments

Unfortunately that didn't work. I've also tried placing libcurl.a, libcurldll.a, and libcurl.dll in the same directory as the file I'm compiling and using -L. -lcurl as options, but that also didn't work.
@Birdie: were u able to solve this?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.