Undefined symbols for architecture x86_64: "_SSLv2_ ..." - c++

I am trying to build a small example for a Telegram Bot library in C++ (https://github.com/reo7sp/tgbot-cpp#samples) but when linking I get this output:
Undefined symbols for architecture x86_64:
"_SSLv2_client_method", referenced from:
boost::asio::ssl::context::context(boost::asio::ssl::context_base::method) in libTgBot.a(HttpClient.cpp.o)
"_SSLv2_method", referenced from:
boost::asio::ssl::context::context(boost::asio::ssl::context_base::method) in libTgBot.a(HttpClient.cpp.o)
"_SSLv2_server_method", referenced from:
boost::asio::ssl::context::context(boost::asio::ssl::context_base::method) in libTgBot.a(HttpClient.cpp.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
using this command:
g++ -std=c++11 main.cpp -l boost_system -l boost_iostreams -l boost_unit_test_framework -l boost_exception -l TgBot -l pthread -l ssl -l crypto -L/usr/local/opt/openssl/lib -I/usr/local/opt/openssl/include
I have openssl 1.0.2 installed: do I have to get a 2.x version? I can't find it with homebrew (my system is OSX 10.9.5)... sorry for the newbie question.

brew install openssl
open ~/.bash_profile
add
export PATH="/usr/local/opt/openssl/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
source ~/.bash_profile

Related

How use dlib in Xcode C++?

I have installed dlib using Homebrew.
brew install dlib
Did this:
Add /usr/local/Cellar/dlib/19.16/include to Header Search Paths
Add /usr/local/Cellar/dlib/19.16/lib to Library Search Paths
Add -ldlib to Other Linker Flags
Add Accelerate.framework and change status to "Required" in Link Binary With Libraries
But when I include dlib's .h files have error:
Undefined symbols for architecture x86_64:
"_USER_ERROR__missing_dlib_all_source_cpp_file__OR__inconsistent_use_of_DEBUG_or_ENABLE_ASSERTS_preprocessor_directives_", referenced from:
_dlib_check_consistent_assert_usage 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)
P.S. Yes, i used -v, but it's no effects

Problems compiling Halide's camera_pipe application on Mac OS

I'm new to Halide and just successfully compiled Halide from source. I wanted to try out the camera_pipe application from the source code (https://github.com/halide/Halide/tree/master/apps/camera_pipe), but I'm getting the following error, and I'm not sure how to debug / fix it. Thank you in advance for any suggestions or help!
My system is running Mac OS Sierrar (10.12.3)
This is command that the Makefile ran:
c++ -std=c++11 -I ../../include/ -I ../../tools/ -I ../../apps/support/ -g -fno-rtti camera_pipe_generator.cpp ../../lib/libHalide.a ../../tools/GenGen.cpp -o bin/camera_pipe_exec -L/usr/local/lib -ldl -lpthread -lz
And this is the error output that I got:
Undefined symbols for architecture x86_64:
"_del_curterm", referenced from:
llvm::sys::Process::FileDescriptorHasColors(int) in libHalide.a(llvm_460_Process.cpp.o)
"_set_curterm", referenced from:
llvm::sys::Process::FileDescriptorHasColors(int) in libHalide.a(llvm_460_Process.cpp.o)
"_setupterm", referenced from:
llvm::sys::Process::FileDescriptorHasColors(int) in libHalide.a(llvm_460_Process.cpp.o)
"_tigetnum", referenced from:
llvm::sys::Process::FileDescriptorHasColors(int) in libHalide.a(llvm_460_Process.cpp.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [bin/camera_pipe_exec] Error 1
Looks like your llvm depends on terminfo, but the camera pipe doesn't link it by default. Try adding a -ltinfo into the makefile along with -lpthread -lz, etc.

Undefined symbols for architecture armv7 but lipo -info shows ok

I think you guys have seen this kind of errors before, but mine is special.
I have a few static libs in my Xcode project, when I tried to build it I got this error. But I have checked all my libs with command xcrun -sdk iphoneos lipo -info $libname, it gave me Architectures in the fat file: /Users/kiwi/Documents/Development/SourceCode/prj/lib.a are: armv7 i386 x86_64 arm64.
Undefined symbols for architecture armv7: "_SSLv2_server_method",
referenced from:
CSSLctx::Create(bool, CSSLctx::sslProtocol) in libudp.a(SSLStream.o) "_SSLv2_client_method", referenced from:
CSSLctx::Create(bool, CSSLctx::sslProtocol) in libudp.a(SSLStream.o) ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see
invocation)

Linking OpenCV to XCode

I'm following this:
http://sadeepj.blogspot.com.br/2012/03/installing-and-configuring-opencv-to.html
I had a problem, compiling. But I already fixed it, modifying 2 files...
Now I'm trying to run that example.
And I get this error message:
Ld
/Users/eduardoreis/Library/Developer/Xcode/DerivedData/DemoOpenCV2-cqudsdzwopsadacnkbwrsxuncofg/Build/Products/Debug/DemoOpenCV2
normal x86_64
cd /Users/eduardoreis/Documents/XCodeDevelopment/DemoOpenCV2
setenv MACOSX_DEPLOYMENT_TARGET 10.8
/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.8.sdk
-L/Users/eduardoreis/Library/Developer/Xcode/DerivedData/DemoOpenCV2-cqudsdzwopsadacnkbwrsxuncofg/Build/Products/Debug
-F/Users/eduardoreis/Library/Developer/Xcode/DerivedData/DemoOpenCV2-cqudsdzwopsadacnkbwrsxuncofg/Build/Products/Debug
-filelist /Users/eduardoreis/Library/Developer/Xcode/DerivedData/DemoOpenCV2-cqudsdzwopsadacnkbwrsxuncofg/Build/Intermediates/DemoOpenCV2.build/Debug/DemoOpenCV2.build/Objects-normal/x86_64/DemoOpenCV2.LinkFileList
-mmacosx-version-min=10.8 -stdlib=libc++ -lopencv_core.2.4.6 -lopencv_highgui.2.4.6 -Xlinker -dependency_info -Xlinker /Users/eduardoreis/Library/Developer/Xcode/DerivedData/DemoOpenCV2-cqudsdzwopsadacnkbwrsxuncofg/Build/Intermediates/DemoOpenCV2.build/Debug/DemoOpenCV2.build/Objects-normal/x86_64/DemoOpenCV2_dependency_info.dat
-o /Users/eduardoreis/Library/Developer/Xcode/DerivedData/DemoOpenCV2-cqudsdzwopsadacnkbwrsxuncofg/Build/Products/Debug/DemoOpenCV2
ld: library not found for -lopencv_core.2.4.6 clang: error: linker
command failed with exit code 1 (use -v to see invocation)
I follows all steps already. And I can't even build it.
Please, help me.
[Before someone says that it is a duplicated post, I know it, here is the original one:
C++ linker errors with OpenCV.
I'm sorry. But I can't even comment on that one :/ ]
Wow, Finally solved:
Some considerations:
Realize that even it is looking for -l opencv_core.2.4.6, the
compiler will get the right file, if it is added correctly with other
name, in this case libopencv_core.2.4.dylib
I was adding the files with Project>Add files to... and then creating a group and dragging the files into the group. This was messing up the linkings in Project>Link Binary with Libraries. So I had to do it again by dragging the files in the group into that spot.
After theses things I had the situation where I had the two files (core and highgui) and 4 errors:
Ld
/Users/eduardoreis/Library/Developer/Xcode/DerivedData/DemoOpenCV2-cqudsdzwopsadacnkbwrsxuncofg/Build/Products/Debug/DemoOpenCV2
normal x86_64
cd /Users/eduardoreis/Documents/XCodeDevelopment/DemoOpenCV2
setenv MACOSX_DEPLOYMENT_TARGET 10.8
/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.8.sdk
-L/Users/eduardoreis/Library/Developer/Xcode/DerivedData/DemoOpenCV2-cqudsdzwopsadacnkbwrsxuncofg/Build/Products/Debug
-L/Users/eduardoreis/Downloads/opencv-2.4.6.1/build/lib/Debug -L/usr/local/lib/python2.7/site-packages -L/usr/local/lib/python2.7/site-packages/PyQt4 -L/usr/local/lib/wine -L/usr/local/Cellar/wine/1.4.1/lib -L/usr/local/Cellar/qt/4.8.5/lib -L/usr/local/Cellar/qscintilla2/2.7.1/lib -L/usr/local/Cellar/libicns/0.8.1/lib -L/usr/local/Cellar/jasper/1.900.1/lib -L/usr/local/Cellar/jpeg/8d/lib -L/usr/local/Cellar/little-cms/1.19/lib -L/usr/local/Cellar/libpng/1.5.14/lib -L/usr/local/Cellar/libtiff/4.0.3/lib -F/Users/eduardoreis/Library/Developer/Xcode/DerivedData/DemoOpenCV2-cqudsdzwopsadacnkbwrsxuncofg/Build/Products/Debug
-F/usr/local/lib -filelist /Users/eduardoreis/Library/Developer/Xcode/DerivedData/DemoOpenCV2-cqudsdzwopsadacnkbwrsxuncofg/Build/Intermediates/DemoOpenCV2.build/Debug/DemoOpenCV2.build/Objects-normal/x86_64/DemoOpenCV2.LinkFileList
-mmacosx-version-min=10.8 -stdlib=libc++ -lopencv_core.2.4 -lopencv_highgui.2.4 -Xlinker -dependency_info -Xlinker /Users/eduardoreis/Library/Developer/Xcode/DerivedData/DemoOpenCV2-cqudsdzwopsadacnkbwrsxuncofg/Build/Intermediates/DemoOpenCV2.build/Debug/DemoOpenCV2.build/Objects-normal/x86_64/DemoOpenCV2_dependency_info.dat
-o /Users/eduardoreis/Library/Developer/Xcode/DerivedData/DemoOpenCV2-cqudsdzwopsadacnkbwrsxuncofg/Build/Products/Debug/DemoOpenCV2
Undefined symbols for architecture x86_64:
"cv::namedWindow(std::__1::basic_string, std::__1::allocator > const&,
int)", referenced from:
_main in main.o "cv::imread(std::__1::basic_string, std::__1::allocator > const&,
int)", referenced from:
_main in main.o "cv::imshow(std::__1::basic_string, std::__1::allocator > const&,
cv::_InputArray const&)", 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)
Then (thanks God and some days of googling) I got this:
Select your project, go to the Build Settings tab, filter by c++
standard library, and set this parameter to libstdc++ (GNU C++
standard library).
from: Undefined symbols for architecture x86_64 error when linking OpenCV in Xcode
And finally it was sunny again in my code environment...

Apple Mach-O linker (ld) error using freenect library

When trying to compile the following file in xcode:
http://openkinect.org/wiki/C%2B%2BOpenCvExample
I get these errors:
Ld build/Debug/KinectOpenCV normal x86_64
cd "/Users/Scott/Dropbox/Project/KinectOpenCV/KinectOpenCV"
setenv MACOSX_DEPLOYMENT_TARGET 10.7
/Developer/usr/bin/clang++ -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.7.sdk "-L/Users/Scott/Dropbox/Project/KinectOpenCV/KinectOpenCV/build/Debug" "-F/Users/Scott/Dropbox/Project/KinectOpenCV/KinectOpenCV/build/Debug" -filelist "/Users/Scott/Dropbox/Project/KinectOpenCV/KinectOpenCV/build/KinectOpenCV.build/Debug/KinectOpenCV.build/Objects-normal/x86_64/KinectOpenCV.LinkFileList" -mmacosx-version-min=10.7 -lopencv_core.2.3.2 -lopencv_highgui.2.3.2 -lfreenect.0.0.1 -framework GLUT -framework OpenGL -o "/Users/Scott/Dropbox/Project/KinectOpenCV/KinectOpenCV/build/Debug/KinectOpenCV"
Undefined symbols for architecture x86_64:
"_freenect_find_video_mode", referenced from:
freenect_threadfunc(void*) in main.o
"_freenect_set_video_mode", referenced from:
freenect_threadfunc(void*) in main.o
"_freenect_find_depth_mode", referenced from:
freenect_threadfunc(void*) in main.o
"_freenect_set_depth_mode", referenced from:
freenect_threadfunc(void*) in main.o
"_freenect_select_subdevices", 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)
I've been trying everything I can think off to resolve the issue but no joy. I've tried compiling for specific architectures (32 bit or 64), I've tried relinking all the libraries and other such measures like starting a new project and importing everything again.
Sounds like you need to rebuild libfreenect.
I'd suggest following the directions on this tutorial and once you have everything re-installed, run that nm test again and see if the symbols finally appear.
If they don't, grep through the library source and see if they are defined and simply conditionalized out for some reason.