Search code examples
cxcodestatic-linking

How do I statically link to a lib when creating a command line program in xcode?


I'm new to OSX and XCode and I'm trying to statically link to a C app. I downloaded and installed libconfig and I link to the installed libconfig.a. It works great on my machine but when I run my binary on another machine I get an error that says libconfig.dylib can't be found. Naturally, I don't want to have to install libconfig everywhere I use my app.

I've scoured through the xcode build settings and the only reference I see is the one for libconfig.a. What am I doing wrong?


Solution

  • I got this to work. This seems to be a libconfig build issue, maybe expected behavior but it surprised me. I was linking to libconfig.a, but it appears that libconfig.a was linking to libconfig.dylib. I reconfigure libconfig and reinstalled it.

    ./configure --disable-shared
    make clean
    make
    make install