skip to Main Content

When building my mini project on macOS/XCode/C++, I get the linker error mentioned in the subject line, and I don’t understand why I get it, and what I can do to avoid it.

My code is extremely simple, it’s essentially the code that was autogenerated by XCode during the creation of the project (a command line application), plus the two curl-related lines I added myself:

#include <iostream>

#include <curl/curl.h>

int main(int argc, const char * argv[]) {
    CURL *easy_handle = curl_easy_init();
    
    std::cout << "Hello, World!n";
    return 0;
}

The linker complains about the symbol _curl_easy_init() as being missing, even though I have added the libcurl.4.tbd framework to the project, and inspecting the details of the framework in XCode shows the that the symbol in question is exported. At least that’s what it looks like.

So I’m really at a loss as to what the problem is and how to solve it. Thanks in advance for any hint or suggestion.

2

Answers


  1. Chosen as BEST ANSWER

    I found the solution. I had to add the library under "Target > Build Phases > Link Binary With Libraries", and not under "Target > General > Frameworks and Libraries", even though it will appear under the latter as well, automatically.


  2. Despite appearances, it’s not enough to add the framework to the list of Linked Frameworks in the Project Navigator in the left-hand pane. You also have to add it to ‘Frameworks, Libraries and Embedded Content’ in the ‘General’ settings for your build target (which will be your application, in this case).

    A couple of screenshots should make this clear. In this case, I’m adding the SystemConfiguration framework to my build:

    Before:
    Before
    After:
    enter image description here
    Then build your project again.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search