Linking error - Undefined symbols for architecture x86_64 on OSX - macos

The following is returned when trying to compile part of a project under OSX:
gcc -g -pipe -L/Projects/export buf_test.o buf.o -framework CoreFoundation -o buf_test
Undefined symbols for architecture x86_64:
"___assert_rtn", referenced from:
_init in buf.o
_get in buf.o
_put in buf.o
"___sprintf_chk", referenced from:
_test in buf_test.o
"___strcpy_chk", referenced from:
_test_data_copy in buf_test.o
___inline_strcpy_chk in buf_test.o
"_exit", referenced from:
start in crt1.10.6.o
"_printf", referenced from:
_test in buf_test.o
"_puts", referenced from:
_test in buf_test.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
Help would be much appreciated!

Turns out it was a library naming conflict with the standard libraries -- I had a library called libSystem.a in /Projects/export which was masking libSystem.dylib from being found.

Related

httpd(2.4.25), openssl(1.0.2k) - Cannot compile in macOS Sierra Error on make: Undefined symbols for architecture x86_64: "_CRYPTO_malloc_init"

Operating system is macOS Sierra, osx 10.12.3
Configure command line:
./configure --prefix=/usr/local/mac-dev-env/apache-2.4.25 --enable-so --enable-ssl --with-ssl=/usr/local/mac-dev-env/openssl-1.0.2k --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
Error created by make:
/usr/local/apr-1.5.2/build-1/libtool --silent --mode=link gcc -g -O2
-L/usr/local/mac-dev-env/openssl-1.0.2k/lib -lssl -lcrypto -lpthread \
-o ab ab.lo /usr/local/apr-util-1.5.4/lib/libaprutil-1.la -lexpat -liconv /usr/local/apr-1.5.2/lib/libapr-1.la -lpthread Undefined symbols for architecture x86_64: "_CRYPTO_malloc_init", referenced from:
_main in ab.o "_OPENSSL_init_ssl", referenced from:
_main in ab.o "_OPENSSL_sk_num", referenced from:
_ssl_proceed_handshake in ab.o "_OPENSSL_sk_value", referenced from:
_ssl_proceed_handshake in ab.o "_SSL_CTX_set_options", referenced from:
_main in ab.o "_SSL_in_init", referenced from:
_main in ab.o
_ssl_state_cb in ab.o "_TLS_client_method", referenced from:
_main in ab.o "_X509_get_version", referenced from:
_ssl_print_cert_info in ab.o "_X509_getm_notAfter", referenced from:
_ssl_print_cert_info in ab.o "_X509_getm_notBefore", referenced from:
_ssl_print_cert_info in ab.o ld: symbol(s) not found for architecture x86_64
I went to http://www.linuxfromscratch.org/blfs/view/svn/server/apache.html
From there I found two dependencies Apr-Util-1.5.4 and PCRE-8.40.
I configure the build of apr-util with:
./configure --prefix=/usr/local/mac-dev-env/apr-util-1.5.4 --with-apr=/usr/local/mac-dev-env/apr-1.5.2 --with-openssl=/usr/local/mac-dev-env/openssl-1.0.2k --with-crypto
Most important was to build apr-util with --with-openssl=/usr/local/mac-dev-env/openssl-1.0.2k --with-crypto.
I then built pcre-8.40 as I had been attempting to build with pcre-8.39.
I believe the root cause was not building with apr-util-1.5.4 with the --with-openssl=/usr/local/mac-dev-env/openssl-1.0.2k --with-crypto options.
My configuration before make for apache-2.4.25 was:
./configure --prefix=/usr/local/mac-dev-env/apache-2.4.25 --enable-so --enable-ssl --with-ssl=/usr/local/mac-dev-env/openssl-1.0.2k --with-apr=/usr/local/apr --with-apr-util=/usr/local/mac-dev-env/apr-util-1.5.4 --with-ldap

How do I solve the following linker error with my OpenGL program in Xcode?

I am getting the following errors when I try to compile my C++ OpenGL program in Xcode on Mac OS 10.8...What should I do?
Undefined symbols for architecture x86_64:
"_aglChoosePixelFormat", referenced from:
_main in main.o
"_aglCreateContext", referenced from:
_main in main.o
"_aglDestroyContext", referenced from:
_main in main.o
"_aglDestroyPixelFormat", referenced from:
_main in main.o
"_aglSetCurrentContext", referenced from:
_main in main.o
"_aglSetFullScreen", 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)
Since you're using AGL, looking at the reference for AGL, you need to import the framework AGL along with OpenGL.

Undefined Symbols when trying to compile RtAudio

I'm trying to use RtAudio and RtMidi together. I have in the same folder RtAudio.cpp, RtAudio.h, RtHelper.h, RtMidi.cpp and RtMidi.h as well as 2 test programs, midiprobe.cpp and audioprobe.cpp.
Compiling midiprobe with the default command works, but when I try to do the same for audioprobe to test RtAudio, I get the errors.
Here is what I use to compile:
g++ -Wall -D__MACOSX_CORE__ -o audioprobe audioprobe.cpp RtAudio.cpp -framework CoreAudio -lpthread
And these are the errors:
Undefined symbols for architecture x86_64:
"_CFRelease", referenced from:
RtApiCore::getDeviceInfo(unsigned int)in cc89M9Ki.o
"_CFStringGetCString", referenced from:
RtApiCore::getDeviceInfo(unsigned int)in cc89M9Ki.o
"_CFStringGetLength", referenced from:
RtApiCore::getDeviceInfo(unsigned int)in cc89M9Ki.o
"_CFStringGetSystemEncoding", referenced from:
RtApiCore::getDeviceInfo(unsigned int)in cc89M9Ki.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
I'm quite new to this sort of stuff (mostly had frameworks ready-made till now) and haven't been able to figure this out yet. Since it's the default example, I'm really lost as to what to do next...
Thanks in advanced.
The missing symbols are in the CoreFoundation framework - you need to add:
-framework CoreFoundation
to your command line.

NPAPI XCode linker

I'm trying to compile basic plugin for firefox and linker reports following problem:
Undefined symbols for architecture i386:
"_NPN_GetValue", referenced from:
_PluginLog in main.o
"_NPN_GetStringIdentifier", referenced from:
_PluginLog in main.o
"_NPN_GetProperty", referenced from:
_PluginLog in main.o
"_NPN_Invoke", referenced from:
_PluginLog in main.o
"_NPN_ReleaseObject", referenced from:
_PluginLog in main.o
"_NPN_ReleaseVariantValue", referenced from:
_PluginLog in main.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
have I missed to add some linked libraries?
You can't just call those functions like you would a normal function (they aren't exported by a browser, nor are you linking against a browser); you need to use the function pointers from the NPNetscapeFuncs struct passed to you by the browser.

Compiling C/C++ application using SDL in OS X, linking problem

I'm trying to compile a C/C++ program that uses SDL on a OS X 10.6.8 but I'm having some errors on the linking stage, the code compiles but fails to like due to some missing symbols. The error is:
Undefined symbols for architecture x86_64:
"_CFBundleGetMainBundle", referenced from:
-[SDLMain setupWorkingDirectory:] in libSDLmain.a(SDLMain.o)
_main in libSDLmain.a(SDLMain.o)
"_CFBundleCopyBundleURL", referenced from:
-[SDLMain setupWorkingDirectory:] in libSDLmain.a(SDLMain.o)
"_CFURLCreateCopyDeletingLastPathComponent", referenced from:
-[SDLMain setupWorkingDirectory:] in libSDLmain.a(SDLMain.o)
"_CFURLGetFileSystemRepresentation", referenced from:
-[SDLMain setupWorkingDirectory:] in libSDLmain.a(SDLMain.o)
"_CFRelease", referenced from:
-[SDLMain setupWorkingDirectory:] in libSDLmain.a(SDLMain.o)
...
"_OBJC_CLASS_$_NSAutoreleasePool", referenced from:
objc-class-ref in libSDLmain.a(SDLMain.o)
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [dist/linwarrior] Error 1
I checked with the file command and the libraries are either x86_64 only or universal with both i386 and x86_64 versions.
Is there a way for me to determine what exactly is causing this error? A way to check the libs that are being included or any way to help debug the problem?
I don't know if it helps but this is what my Makefile creates, I removed file names to make it short, and the KNT flag is just something I'm using for preprocessor conditions:
/opt/local/bin/g++-mp-4.5 -DKNT=1 -Wp,-M,-MP,-MT,-MF, -std=c++0x -Wall -I source -O1 -funroll-loops -c -o
Thanks.

Resources