4

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)
SoftDev
  • 43
  • 1
  • 1
  • 5
  • 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 Mar 28 '17 at 12:55
  • 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 https://github.com/BelledonneCommunications/linphone-iphone – Michael Dautermann Mar 28 '17 at 13:00
  • @Someprogrammerdude I have edited my question. – SoftDev Mar 28 '17 at 13:02
  • @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 http://www.linphone.org/technical-corner/liblinphone/downloads – SoftDev Mar 28 '17 at 13:03
  • 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 Mar 28 '17 at 13:08
  • @Someprogrammerdude, I have added full error output. – SoftDev Mar 28 '17 at 13:14

1 Answers1

4

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

Michael Dautermann
  • 88,797
  • 17
  • 166
  • 215
  • Thanks It worked but I am getting ortp error now. I have tried with -lortp also. Error is > "ortp-error-Error in connect: No route to host". Any idea Micheal? – SoftDev Mar 28 '17 at 13:31
  • Now that you got things to compile, it sounds like a brand new problem. Look closely at the source code you pointed to. I don't see an actual hostname in there (e.g. "stackoverflow.com" or "apple.com"). – Michael Dautermann Mar 28 '17 at 13:36
  • I am using the demo SIP uri mentioned in the tutorial there. https://wiki.linphone.org/xwiki/wiki/public/view/Lib/Getting%20started/Linux-MAC/ – SoftDev Mar 28 '17 at 13:42