Mac OS X Sierra : Undefined symbols for architecture x86_64 - c

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)

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

Related

testu01 installation problems on mac OS X

I installed testu01 on my mac (OS El Capitan). I want to compile one of the examples using gcc, code below. But I get the following error, below. Did anybody run TestU01 on x86_64 successfully? Any other suggestions?
MacBook-Pro-2:examples Joan$ gcc -std=c99 -Wall -O3 -o birth1 birth1.c -I/Users/TestU01/TestU01-1.2.3/include -I/Users/TestU01/TestU01-1.2.3/mylib
Undefined symbols for architecture x86_64:
"_smarsa_BirthdaySpacings", referenced from:
_main in birth1-c99705.o
"_ulcg_CreateLCG", referenced from:
_main in birth1-c99705.o
"_ulcg_DeleteGen", referenced from:
_main in birth1-c99705.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Nauty and Traces on Mac OS X

I am trying to use the code Nauty and Traces http://pallini.di.uniroma1.it/. But when I complied an example, say nautyex8.c (provided by the package), the following error showed up:
Undefined symbols for architecture x86_64:
"_alloc_error", referenced from:
_main in nautyex8-54d9da.o
"_densenauty", referenced from:
_main in nautyex8-54d9da.o
"_dispatch_graph", referenced from:
_main.options in nautyex8-54d9da.o
"_nauty_check", referenced from:
_main in nautyex8-54d9da.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I am using Mac OS X Yosemite (10.10.5) and Xcode (version 7.1). I believe that there is no error in the codes because they are widely used so I guess the problem comes from my system settings.
Thank you so much!
I've just opened a pull request to make brew install nauty work on OS X: https://github.com/Homebrew/homebrew-core/pull/48701
Until then, here's how you would build nautyex8.c on OS X, as of Nauty/Traces 2.6r12.
Step 1 is to download the code and build the library:
wget http://pallini.di.uniroma1.it/nauty26r12.tar.gz
tar zxvf nauty26r12.tar.gz
cd nauty26r12
./configure
make
ls -l nauty.a
Step 2 is to compile nautyex8.c and link it against the library you just built:
gcc -O3 nautyex8.c nauty.a
./a.out
You probably forgot to put that "nauty.a" at the end of your compiler command line. If I do that too, I get:
gcc -O3 nautyex8.c
Undefined symbols for architecture x86_64:
"_alloc_error", referenced from:
_main in nautyex8-05f086.o
"_densenauty", referenced from:
_main in nautyex8-05f086.o
"_dispatch_graph", referenced from:
_main.options in nautyex8-05f086.o
"_nauty_check", referenced from:
_main in nautyex8-05f086.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
which exactly matches the symptom you described.

Gstreamer first steps - "Undefined symbols..." error

Probably a noob question but I can't find an answer to this. I've downloaded and installed Gstreamer for Mac from http://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/chapter-init.html
I copied the code for example 4.1, to initialize GStreamer, from
http://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/chapter-init.html into a file called eg41.c
and used the terminal command gcc eg41.c -I/Library/Frameworks/GStreamer.framework/Headers
. The output was:
Undefined symbols for architecture x86_64:
"_gst_init", referenced from: _main in eg41-9814a5.o
"_gst_version", referenced from: _main in eg41-9814a5.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any ideas?

Undefine symbols for architecture x86_64 using FFTW

Ceeloss-MacBook-Pro:desktop ceelos$ gcc -o prog -I/usr/local/include test.c
Undefined symbols for architecture x86_64:
"_fftw_destroy_plan", referenced from:
_main in test-IBqBdS.o
"_fftw_execute", referenced from:
_main in test-IBqBdS.o
"_fftw_plan_dft_1d", referenced from:
_main in test-IBqBdS.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Ceeloss-MacBook-Pro:desktop ceelos$
What's this telling me?
It's telling you that you forgot to use -L and -l to tell gcc where the FFTW libraries are and what they're called.

Compile simple hello world ZeroMQ C example, compile flags?

Trying to compile the example hello_world.c from the zeromq tutorial:
http://zguide.zeromq.org/page:all#Ask-and-Ye-Shall-Receive
Pretty sure I have everything installed in OSX Mountain Lion.
clang -Wall hwserver.c -o hwserver
gives me an error:
Undefined symbols for architecture x86_64:
"_zmq_bind", referenced from:
_main in hwserver-OgrEe6.o
"_zmq_ctx_new", referenced from:
_main in hwserver-OgrEe6.o
"_zmq_msg_close", referenced from:
_main in hwserver-OgrEe6.o
"_zmq_msg_data", referenced from:
_main in hwserver-OgrEe6.o
"_zmq_msg_init", referenced from:
_main in hwserver-OgrEe6.o
"_zmq_msg_init_size", referenced from:
_main in hwserver-OgrEe6.o
"_zmq_msg_recv", referenced from:
_main in hwserver-OgrEe6.o
"_zmq_msg_send", referenced from:
_main in hwserver-OgrEe6.o
"_zmq_socket", referenced from:
_main in hwserver-OgrEe6.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I'm not the most experienced in C. Not sure if I sure be adding a compiler flag for the zmq dylib or headers or my $PATH being off.
in /usr/local/lib:
libzmq.3.dylib
libzmq.a
libzmq.dylib
libzmq.la
and in /usr/local/include:
zmq.h
zmq_utils.h
and echo $PATH:
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/lib/:/usr/local/include/
You list the ZeroMQ libraries in your question, but you do not actually link with them. Change the command line to this:
clang -Wall hwserver.c -o hwserver -L/usr/local/lib -lzmq
Explanation of the extra arguments:
-L/usr/local/lib tells the linker to add a path (/usr/local/lib) to the library search path.
-lzmq tells the library to link with the zmq library.
The $PATH environment variable have nothing to do with this, it just tells the shell where to look for commands.

Resources