compling error on libmicrohttpd using ld - ld

http://www.gnu.org/s/libmicrohttpd/tutorial.html#Hello-browser-example
gcc helloworld.c -lmicrohttpd -I/opt/local/include/
helloworld.c: In function ‘answer_to_connection’:
helloworld.c:18: warning: incompatible implicit declaration of built-in function ‘strlen’
ld: library not found for -lmicrohttpd
collect2: ld returned 1 exit status
I am using snow leopard with latest xcode
and installed libmicrohttpd using macports

never used OSX but you need something like: -L/opt/local/lib
Check where the lib resides.. the linked docs says -L$PATH_TO_LIBMHD_INCLUDES

Related

How do I make use of SSLSetALPNProtocols?

I'm working on a TLS library for the vapor project and am supporting both Apple's (Transport-)Security and OpenSSL for use in an HTTP/2 client and server.
On this line of code I'm trying to call SSLSetALPNProtocols. Regardless of my approach, I'm met with an ld linker error on that line of code.
Undefined symbols for architecture x86_64:
"_SSLSetALPNProtocols", referenced from:
__T08AppleSSL9SSLOptionV4alpnACSaySSG9protocols_tFZySo10SSLContextCKcfU_ in Options.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
There's no documentation available to highlight a possible obvious mistake since the page is empty.
So, how do I get this code to compile with ALPN support?
Currently that's impossible. Apple forgot to export the SSLSetALPNProtocols and SSLCopyALPNProtocols function.
I already filed rdar://34790589 (duplicate of rdar://33907676)
As of the latest macOS and Xcode beta with Swift 4.1 I've got this up and running.

Using C++ library with Matlab

Hi I read one similar question- on using mex + nvcc linker problems with standard library. My problem is similar as I have code which compiles Ok with gcc on the Mac OS X. ( I am a beginner)
Code
gcc -lstdc++ trnr.c -o trnr works fine
Error
But I get these errors when I use mex
Building with 'Xcode with Clang'.
Error using mex
Undefined symbols for architecture x86_64:
"_mexFunction", referenced from:
-exported_symbol[s_list] command line option
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Not sure how to procede can anyone help

How to install Cairo using Homebrew on Lion?

I am trying to install Cairo using Homebrew on Mac OS X Lion, but I get the following error:
Undefined symbols for architecture x86_64:
"_png_set_longjmp_fn", referenced from:
_read_png in cairo-png.o
_png_simple_error_callback in cairo-png.o
_write_png in cairo-png.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make[3]: *** [libcairo.la] Error 1
I thought it might be that libpng was missing, and it's included with X11 in Lion, so I added ENV.x11 to Cairo's formula, this didn't fix it.
What's the next place I should look? Should I post more of the error/log?
I reinstalled libpng using this package: http://ethan.tira-thompson.com/Mac_OS_X_Ports.html, that solved the problem.

iPhone toolchain problems

I built an iPhone toolchain on Ubuntu based on the directions at http://www.saurik.com/id/4 . When I try to compile something as simple as:
int main () {
return 4;
}
It gives me this:
Undefined symbols:
"_main", referenced from:
_main$non_lazy_ptr in crt1.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
This happens for both the crt1.o from the iPhone SDK and from the http://code.google.com/p/iphone-dev/wiki/Building . Using -save-temps, I found out that the cc1 command produced no output. Why is that? Is there something wrong with my specs file?
Using built-in specs.
Target: arm-apple-darwin10
Configured with: ../llvm-gcc-4.2-2.8.source/configure --target=arm-apple-darwin10 --prefix=/home/kevin/it --with-sysroot=/home/kevin/is --enable-languages=c,c++,objc,obj-c++ --with-as=/home/kevin/it/bin/arm-apple-darwin10-as --with-ld=/home/kevin/it/bin/arm-apple-darwin10-ld --enable-wchar_t=no --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658)
/home/kevin/it/libexec/gcc/arm-apple-darwin10/4.2.1/cc1 -quiet -v -D__DYNAMIC__ test.c -miphoneos-version-min=3.0 -fPIC -fno-builtin-strcat -fno-builtin-strcpy -quiet -dumpbase test.c -auxbase test -version -o /tmp/ccyVHwhV.s
ignoring nonexistent directory "/home/kevin/is/usr/local/include"
ignoring nonexistent directory "/home/kevin/is/home/kevin/it/lib/gcc/arm-apple-darwin10/4.2.1/../../../../arm-apple-darwin10/include"
ignoring nonexistent directory "/home/kevin/is/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/home/kevin/it/lib/gcc/arm-apple-darwin10/4.2.1/include
/home/kevin/is/usr/include
/home/kevin/is/System/Library/Frameworks (framework directory)
End of search list.
GNU C version 4.2.1 (Based on Apple Inc. build 5658) (arm-apple-darwin10)
compiled by GNU C version 4.4.5.
GGC heuristics: --param ggc-min-expand=150 --param ggc-min-heapsize=131072
Compiler executable checksum: 47b826ed9d7049d0b0acd26e928e4c9e
/home/kevin/it/bin/arm-apple-darwin10-as -arch arm -force_cpusubtype_ALL -o /tmp/cck3gviA.o /tmp/ccyVHwhV.s
ERROR: ld.so: object '/etc/override.so' from /etc/ld.so.preload cannot be preloaded: ignored.
ERROR: ld.so: object '/etc/override.so' from /etc/ld.so.preload cannot be preloaded: ignored.
/home/kevin/it/libexec/gcc/arm-apple-darwin10/4.2.1/collect2 -dynamic -arch arm -force_cpusubtype_ALL -iphoneos_version_min 3.0 -syslibroot /home/kevin/is -weak_reference_mismatches non-weak -o test -lcrt1.o -L/home/kevin/is/usr/lib -L/home/kevin/it/lib/gcc/arm-apple-darwin10/4.2.1 -L/home/kevin/it/lib/gcc/arm-apple-darwin10/4.2.1/../../../../arm-apple-darwin10/lib /tmp/cck3gviA.o -lgcc -lSystem
ERROR: ld.so: object '/etc/override.so' from /etc/ld.so.preload cannot be preloaded: ignored.
ld warning: unknown option to -iphoneos_version_min, not 1.x or 2.x
Undefined symbols:
"_main", referenced from:
_main$non_lazy_ptr in crt1.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Never mind, it turns out that I forgot to compile llvm along with it, and I didn't realize that obviously llvm-gcc would need llvm to function correctly.

Undefined symbols when attempting to use CoverStory with iPhone app: _vproc_transaction_end, _vproc_transaction_begin

After following these steps to set up an iphone project with CoverStory, my build fails with two linker errors.
Undefined symbols:
"_vproc_transaction_end", referenced from:
_gcov_exit in libgcov.a(_gcov.o)
_vproc_transaction_end$non_lazy_ptr in libgcov.a(_gcov.o)
(maybe you meant: _vproc_transaction_end$non_lazy_ptr)
"_vproc_transaction_begin", referenced from:
___gcov_init in libgcov.a(_gcov.o)
_vproc_transaction_begin$non_lazy_ptr in libgcov.a(_gcov.o)
(maybe you meant: _vproc_transaction_begin$non_lazy_ptr)
ld: symbol(s) not found
collect2: ld returned 1 exit status
I'm using Xcode 3.2, GCC 4.2 on Snow Leopard. Any ideas what I'm missing?
Here's how to get gcov running with Xcode 3.2.2, GCC 4.2 on Snow Leopard:
http://code.google.com/p/coverstory/wiki/SnowLeopardGCov
Did you add "-lgcov" to Other Linker Flags as the Web page directs?
What is the value of the MACOSX_DEPLOYMENT_TARGET setting? This page and this page suggests the value needs to be set to 10.6.