Installing twitcurl on OS X

443 Views Asked by At

I am attempting to install twitcurl on OS X and have met with some problems.

At first, running make would return the clang error: ld: unknown option: -soname. I looked through the responses from other users with similar problems on OS X and found the following advice:

In the makefile, change:

LDFLAGS += -Wl,-rpath-link=$(STAGING_DIR)/usr/lib

to:

LDFLAGS += -rpath=$(STAGING_DIR)/usr/lib

change:

$(CC) -shared -Wl,-soname,lib$(LIBNAME).so.1 $(LDFLAGS) -o lib$(LIBNAME).so.1.0 .o -L$(LIBRARY_DIR) -lcurl

to:

$(CC) -dynamiclib -shared -Wl,-install_name,lib$(LIBNAME).dylib.1 $(LDFLAGS) -o lib$(LIBNAME).dylib .o -L$(LIBRARY_DIR) -lcurl

I tried this, but the only result was another clang error: clang: error: unknown argument: '-rpath=/usr/lib'

Any advice towards installing twitcurl on an OS X system will be greatly appreciated.

----UPDATE----

I just wanted to put in one place all the steps I took to make this work, in case any OS X users with similar problems come across this in the future. My thanks to Andy Piper for the crucial pieces.

open the makefile and replace:

LDFLAGS += -Wl,-rpath-link=$(STAGING_DIR)/usr/lib

with:

LDFLAGS += -rpath $(STAGING_DIR)/usr/lib

and:

$(CC) -shared -Wl,-soname,lib$(LIBNAME).so.1 $(LDFLAGS) -o lib$(LIBNAME).so.1.0 .o -L$(LIBRARY_DIR) -lcurl

with:

$(CC) -dynamiclib -shared -Wl,-install_name,lib$(LIBNAME).dylib.1 $(LDFLAGS) -o lib$(LIBNAME).dylib *.o -L$(LIBRARY_DIR) -lcurl (note that this is different by two characters from the advice another OS X user gave above)

after running make, copy libtwitcurl.dylib into /usr/lib/

Downloading the twitterClient (which is also the only code example I could find) will be the same, but for compiling it or your own programs you will need to link -lcurl as well. (g++ appname.cpp -ltwitcurl -lcurl)

Finally, once you compile a program, the path name will likely be incorrect in the executable which is created. Use install_name_tool to correct it. For me this looks like:

install_name_tool -change libtwitcurl.dylib.1 /usr/lib/libtwitcurl.dylib nameofexecutable

but if that doesn't work for you, use otool to find the actual path:

otool -L nameofexecutable

and then the first argument after -change should be the erroneous path for libtwitcurl. You can use otool again after running install_name_tool to be sure the change was successful.

1

There are 1 best solutions below

6
On BEST ANSWER

I can get the shared / dynamic library to compile but needed to make a couple of adjustments to your Makefile:

LDFLAGS += -rpath $(STAGING_DIR)/usr/lib

and

$(CC) -dynamiclib -shared -Wl,-install_name,lib$(LIBNAME).dylib.1 $(LDFLAGS) -o lib$(LIBNAME).dylib *.o -L$(LIBRARY_DIR) -lcurl

I've now also built the associated twitterClient utility. To do so, I had to symbolically link libtwitcurl.dylib as libtwitcurl.dylib.1 and also change the consumer key and secret in the code to match a valid one from apps.twitter.com on my account. Works fine.

I assume you want to use the twitcurl library from code? Twitter maintains a Ruby-based utility, twurl, which has a similar function and may also be useful.