stprtool box matlab mex - c

I am trying to use the kernel function of stprtool box in Matlab. As it is a c file, I used the mex function to link it. However, I encountered the following errors:
Undefined symbols for architecture x86_64:
"_arg1", referenced from:
_mexFunction in kernel.o
"_dataA", referenced from:
_mexFunction in kernel.o
"_dataB", referenced from:
_mexFunction in kernel.o
"_dim", referenced from:
_mexFunction in kernel.o
"_ker", referenced from:
_mexFunction in kernel.o
"_kernel", referenced from:
_mexFunction in kernel.o
"_kernel_id", referenced from:
_mexFunction in kernel.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
mex: link of ' "kernel.mexmaci64"' failed.
arg1 to kernel_id are some variables in the kernel.c. Would you have any idea to fix this problem?

Related

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

Linker symbols not found

I'm trying to compile something I've fetched off of github with gcc:
users-MBP:Chip-8-Emulator user$ gcc -o chip8 chip8.c
Undefined symbols for architecture x86_64:
"_SDL_Delay", referenced from:
_chip8_draw in chip8-bc89fc.o
"_SDL_Flip", referenced from:
_chip8_draw in chip8-bc89fc.o
"_SDL_GetKeyState", referenced from:
_chip8_execute in chip8-bc89fc.o
_chip8_prec in chip8-bc89fc.o
"_SDL_GetVideoSurface", referenced from:
_chip8_draw in chip8-bc89fc.o
"_SDL_Init", referenced from:
_chip8_prepare in chip8-bc89fc.o
"_SDL_LockSurface", referenced from:
_chip8_draw in chip8-bc89fc.o
"_SDL_PollEvent", referenced from:
_chip8_prepare in chip8-bc89fc.o
_chip8_prec in chip8-bc89fc.o
"_SDL_SetVideoMode", referenced from:
_chip8_prepare in chip8-bc89fc.o
"_SDL_UnlockSurface", referenced from:
_chip8_draw in chip8-bc89fc.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The error seems to be an issue with the SDL library in this case, but I've had the exact same issue with several other little projects I treid to compile. Before compiling, I installed the SDL libs and checked they are there:
users-MBP:Chip-8-Emulator user$ ls /usr/local/lib/
...
libSDL-1.2.0.dylib
libSDL.a
libSDL.dylib
libSDLmain.a
...
After lots of Googling it seems I'm not the only one with this problem and I couldn't find solution that worked. It seems that osx doesn't include /use/local/lib in the default linker paths.
How can I fix this (a permanent solution would be welcome)?
EDIT
Following a suggestion from user Alex I tried with $ gcc -o chip8 -L/usr/local/lib chip8.c. The error and output is identical to the above.
You'll want to add -L/usr/local/lib -lSDL to your GCC invocation.
As for a more permanent solution, this is a convention of OS X, and strictly speaking /usr/local/lib is a non-standard installation location.

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.

How can I use GLUT with CUDA on MACOSX?

I'm having problems compiling a CUDA program that uses GLUT on MacOsX. Here is the command line I use to compile the source:
nvcc main.c -o main -Xlinker "-L/System/Library/Frameworks/OpenGL.framework/Libraries -lGL -lGLU" "-L/System/Library/Frameworks/GLUT.framework"
And here is the errors I get:
Undefined symbols:
"_glutInitWindowSize", referenced from:
_main in tmpxft_00001612_00000000-1_main.o
"_glutInitWindowPosition", referenced from:
_main in tmpxft_00001612_00000000-1_main.o
"_glutDisplayFunc", referenced from:
_main in tmpxft_00001612_00000000-1_main.o
"_glutInitDisplayMode", referenced from:
_main in tmpxft_00001612_00000000-1_main.o
"_glutCreateWindow", referenced from:
_main in tmpxft_00001612_00000000-1_main.o
"_glutMainLoop", referenced from:
_main in tmpxft_00001612_00000000-1_main.o
"_glutInit", referenced from:
_main in tmpxft_00001612_00000000-1_main.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
I am aware that I haven't specified any lib for GLUT but I just can't find it! Does anybody know where it is? By the way, there doesn't seem to be a way to use the GLUT.framework when compiling with nvcc.
Thanks a lot,
omegatai
Looks like you probably already have your answer, but for future reference, you can just use
-Xlinker -framework,OpenGL,-framework,GLUT
instead of the whole
-L/System/Library/Frameworks/OpenGL.framework/Libraries -lGL -lGLU
when working with nvcc. Source: http://forums.nvidia.com/index.php?showtopic=163995
Here it is:
http://developer.apple.com/mac/library/samplecode/glut/index.html
None of these solutions worked for me. What I needed was just:
-framework GLUT -framework openGL -lGLEW

Resources