Undefine symbols for architecture x86_64 using FFTW - c

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.

Related

Jansson on Xcode

I am trying to test Jansson on Xcode 7.3.1. I installed according to the instructions, then used cMake when that didn't work, which also didn't work. I think Xcode is having trouble finding the Jansson library. I have modified the project header and library paths in many different ways, after extensive suggestions from searching out this problem. Xcode is able to find the header. Note also that I am able to install Jansson and run it in Eclipse. Any insight would be appreciated.
Here is the error log from Xcode:
Ld /Users/corrychapman/Library/Developer/Xcode/DerivedData/JanssonDev-dispcmnteuwiedaiazlbkwtztfcu/Build/Products/Debug/JanssonDev normal x86_64
cd /Users/corrychapman/Desktop/jansson-2.11/JanssonDev
export MACOSX_DEPLOYMENT_TARGET=10.11
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -L/Users/corrychapman/Library/Developer/Xcode/DerivedData/JanssonDev-dispcmnteuwiedaiazlbkwtztfcu/Build/Products/Debug -L/usr/local/lib -L/Users/corrychapman/Desktop/jansson-2.11/JanssonDev -F/Users/corrychapman/Library/Developer/Xcode/DerivedData/JanssonDev-dispcmnteuwiedaiazlbkwtztfcu/Build/Products/Debug -filelist /Users/corrychapman/Library/Developer/Xcode/DerivedData/JanssonDev-dispcmnteuwiedaiazlbkwtztfcu/Build/Intermediates/JanssonDev.build/Debug/JanssonDev.build/Objects-normal/x86_64/JanssonDev.LinkFileList -mmacosx-version-min=10.11 -Xlinker -no_deduplicate -Xlinker -dependency_info -Xlinker /Users/corrychapman/Library/Developer/Xcode/DerivedData/JanssonDev-dispcmnteuwiedaiazlbkwtztfcu/Build/Intermediates/JanssonDev.build/Debug/JanssonDev.build/Objects-normal/x86_64/JanssonDev_dependency_info.dat -o /Users/corrychapman/Library/Developer/Xcode/DerivedData/JanssonDev-dispcmnteuwiedaiazlbkwtztfcu/Build/Products/Debug/JanssonDev
Undefined symbols for architecture x86_64:
"_json_array_get", referenced from:
_main in main.o
"_json_array_size", referenced from:
_main in main.o
"_json_delete", referenced from:
_json_decref in main.o
"_json_loads", referenced from:
_main in main.o
"_json_object_get", referenced from:
_main in main.o
"_json_string_value", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Found it. Build Settings -> Linking -> Other Linker Flags: -ljansson

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)

Mac OS X Sierra : Undefined symbols for architecture x86_64

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

Getting Apple Mach-O Linker error C99. How do i fix it?

Ld /Users/ashutoshagarwal/Library/Developer/Xcode/DerivedData/c-cnyfflmvjyaashaoduqduqqsfegd/Build/Products/Debug/c normal x86_64
cd /Users/ashutoshagarwal/Desktop/c
setenv MACOSX_DEPLOYMENT_TARGET 10.9
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -L/Users/ashutoshagarwal/Library/Developer/Xcode/DerivedData/c-cnyfflmvjyaashaoduqduqqsfegd/Build/Products/Debug -F/Users/ashutoshagarwal/Library/Developer/Xcode/DerivedData/c-cnyfflmvjyaashaoduqduqqsfegd/Build/Products/Debug -filelist /Users/ashutoshagarwal/Library/Developer/Xcode/DerivedData/c-cnyfflmvjyaashaoduqduqqsfegd/Build/Intermediates/c.build/Debug/c.build/Objects-normal/x86_64/c.LinkFileList -mmacosx-version-min=10.9 -framework Foundation -Xlinker -dependency_info -Xlinker /Users/ashutoshagarwal/Library/Developer/Xcode/DerivedData/c-cnyfflmvjyaashaoduqduqqsfegd/Build/Intermediates/c.build/Debug/c.build/Objects-normal/x86_64/c_dependency_info.dat -o /Users/ashutoshagarwal/Library/Developer/Xcode/DerivedData/c-cnyfflmvjyaashaoduqduqqsfegd/Build/Products/Debug/c
Undefined symbols for architecture x86_64:
"_add_history", referenced from:
_main in main.o
"_readline", referenced from:
_main in main.o
_source in main.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 getting Apple-Mach-O Linker (Id) Error, have sent hours trying to fix this one, Dunno what to do.
It looks like you are using the GNU readline and GNU history libraries, which are available, by default, on the mac in libedit.dylib:
$ nm /usr/lib/libedit.dylib | fgrep readline
0000000000009899 T _readline
000000000001f444 D _readline_echoing_p
000000000001f400 D _rl_readline_name
000000000001f3f8 D _rl_readline_version
$ nm /usr/lib/libedit.dylib | fgrep add_history
000000000000acbc T _add_history
(the T indicates that the symbol is in the library's text section).
Therefore you need to add -ledit to your linker command line. If you are using Xcode then you can add libedit.dylib to the list of libraries to link against or if you are using make then you probably have to edit the LIBS variable in your Makefile.
The error message:
Undefined symbols for architecture x86_64: "_add_history", referenced from: _main in main.o
"_readline", referenced from: _main in main.o _source in main.o ld: symbol(s) not found for
architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)'
Tells you that the linker cannot find the symbols readline and add_history. Without seeing your source code, and the precise linker and compiler command-lines, it's hard to speculate the exact cause. A likely cause is that you failed to link with external libraries, or other modules of your program.

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