4
votes

I am trying to build a C source file based on Linphone in Mac OS X Sierra but getting the following error.

This is the link for the C source file. http://www.linphone.org/docs/liblinphone/group__basic__call__tutorials.html

Edited:

I am trying to compile the source code with this command

clang -o tt tt.c -I/Users/softdev/Downloads/linphone-sdk-3.11.1-mac/include/

Error:

Undefined symbols for architecture x86_64
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I have tried to change the target cpu but didn't work.

My system has XCode 8. Any help regarding this will be appreciated.

Edited: Complete Output

Undefined symbols for architecture x86_64:
  "_linphone_call_get_state", referenced from:
      _main in tt-ca2045.o
  "_linphone_call_ref", referenced from:
      _main in tt-ca2045.o
  "_linphone_call_unref", referenced from:
      _main in tt-ca2045.o
  "_linphone_core_destroy", referenced from:
      _main in tt-ca2045.o
  "_linphone_core_invite", referenced from:
      _main in tt-ca2045.o
  "_linphone_core_iterate", referenced from:
      _main in tt-ca2045.o
  "_linphone_core_new", referenced from:
      _main in tt-ca2045.o
  "_linphone_core_terminate_call", referenced from:
      _main in tt-ca2045.o
  "_ms_usleep", referenced from:
      _main in tt-ca2045.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
1
It has nothing to do with the target or the CPU. It's about you not linking with something you need to link with. The linker would have told you what symbols are missing, why don't you tell us that? Please edit your question to include the full error output.Some programmer dude
Where are you getting your liblinphone library from? The documentation you're referring to dates from 2010 (which might be before x86_64 was even an option in Xcode). I do see a much more recent version of liblinphone at github.com/BelledonneCommunications/linphone-iphoneMichael Dautermann
@Someprogrammerdude I have edited my question.SoftDev
@MichaelDautermann, I have downloaded the binary from the below link. I don't want to use linphone. I just want to use the underlying liblinphone libraries in my custom software for Mac linphone.org/technical-corner/liblinphone/downloadsSoftDev
So you don't actually link with the library you want to use? Then I assume the undefined symbols are all functions from that library (since you still haven't included the full and complete error output)? You need to link with the actual library as well. Is there a file beginning with lib and ending with .a in the installation of the library? Pass the full path to that file when you build.Some programmer dude

1 Answers

4
votes

I got the sample code to compile using this:

clang -o hello hello.c -Ilinphone-sdk-3/include -Llinphone-sdk-3/lib -llinphone -lmediastreamer_base

Clang's -I parameter points to the where the header (.h) files live

And as for my additions, -L specifies the path for clang to get to where the lib files live. In your case, it might live in -L/Users/softdev/Downloads/linphone-sdk-3.11.1-mac/lib

then -l specifies which dylibs you want to include (strip off the lib prefix and the dylib suffix).

Lastly, you need to add a missing line to the sample code you pointed to. Add:

#include <unistd.h>

after signal.h