Error while compiling ncurses app on Mac OS X - c

I'm trying to compile ncurses based app on Mac OS X 10.6.8 but I get this error.
Undefined symbols for architecture x86_64:
"_initscr", referenced from:
_main in ccf8K8YG.o
"_printw", referenced from:
_main in ccf8K8YG.o
"_stdscr", referenced from:
_main in ccf8K8YG.o
"_wrefresh", referenced from:
_main in ccf8K8YG.o
"_wgetch", referenced from:
_main in ccf8K8YG.o
"_endwin", referenced from:
_main in ccf8K8YG.o
What could be the problem ?

I'm pretty sure this is because you're not including the ncurses library when compiling.
Try adding:
-lncurses
when compiling.
For example (for C++):
g++ -o hello main.cpp -lncurses
Or using gcc (for C):
gcc -o hello main.cpp -lncurses
This short command will compile and execute:
gcc -o hello main.cpp -lncurses && ./hello
This was my issue, I hope this helps someone.

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)

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