Skip to content

Instantly share code, notes, and snippets.

@edenhill
Last active August 29, 2015 14:02
Show Gist options
  • Save edenhill/30885d7e6781d6a43f2e to your computer and use it in GitHub Desktop.
Save edenhill/30885d7e6781d6a43f2e to your computer and use it in GitHub Desktop.
osx 10.9 static linking problems with -g
Creating shared library librdkafka.so.1
gcc -g -shared -dynamiclib -Wl,-install_name,/usr/local/lib/librdkafka.so.1 rdkafka.o rdkafka_broker.o rdkafka_msg.o rdkafka_topic.o rdkafka_defaultconf.o rdkafka_timer.o rdkafka_offset.o rdcrc32.o rdgz.o rdaddr.o rdrand.o rdthread.o rdqueue.o rdlog.o snappy.o -o librdkafka.so.1 -lpthread -lz
Creating static library librdkafka.a
ar rcs librdkafka.a rdkafka.o rdkafka_broker.o rdkafka_msg.o rdkafka_topic.o rdkafka_defaultconf.o rdkafka_timer.o rdkafka_offset.o rdcrc32.o rdgz.o rdaddr.o rdrand.o rdthread.o rdqueue.o rdlog.o snappy.o
$ ranlib librdkafka.a
$
..
Linking librdkafka statically with -g fails:
gcc -g -O2 -fPIC -Wall -Werror -Wfloat-equal -Wpointer-arith -I../src rdkafka_example.c -o rdkafka_example -g \
../src/librdkafka.a -lpthread -lz
Assertion failed: (!"Unknown operand"), function LinkLocation, file /SourceCache/dwarf_utilities/dwarf_utilities-114/source/DWARFdSYM.cpp, line 1704.
clang: error: unable to execute command: Abort trap: 6
clang: error: dsymutil command failed due to signal (use -v to see invocation)
make[1]: *** [rdkafka_example] Error 254
Works without -g:
$ gcc -O2 -fPIC -Wall -Werror -Wfloat-equal -Wpointer-arith -I../src rdkafka_example.c -o rdkafka_example ../src/librdkafka.a -lpthread -lz
Why?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment