C++ OSX Scons构建共享库:架构x86_64的未定义符号
字幕:架构x86_64的未定义符号:在Mac OSX El Captain x86_64上使用SCON构建OpenCV和dlib 我一直在尝试让我的应用程序跨平台构建 我有一个SCons脚本,它目前在windows上构建得很好,但在Mac上构建失败 我相信这是由于与较新版本的XCode发生冲突造成的,因为我的代码和SCON的一些早期版本工作得很好(在重构之前) 下面是错误消息,我相信这是很常见的,但我似乎没有找到一种补救方法 在OpenCV2 highgui中,cap_avfoundation.mmC++ OSX Scons构建共享库:架构x86_64的未定义符号,c++,xcode,macos,opencv,scons,C++,Xcode,Macos,Opencv,Scons,字幕:架构x86_64的未定义符号:在Mac OSX El Captain x86_64上使用SCON构建OpenCV和dlib 我一直在尝试让我的应用程序跨平台构建 我有一个SCons脚本,它目前在windows上构建得很好,但在Mac上构建失败 我相信这是由于与较新版本的XCode发生冲突造成的,因为我的代码和SCON的一些早期版本工作得很好(在重构之前) 下面是错误消息,我相信这是很常见的,但我似乎没有找到一种补救方法 在OpenCV2 highgui中,cap_avfoundation.
Undefined symbols for architecture x86_64:
"_AVCaptureSessionPresetMedium", referenced from:
CvCaptureCAM::startCaptureDevice(int) in libOpencvHighgui.a(cap_avfoundation.o)
"_AVFileTypeAppleM4V", referenced from:
CvVideoWriter_AVFoundation::CvVideoWriter_AVFoundation(char const*, int, double, CvSize, int) in libOpencvHighgui.a(cap_avfoundation.o)
"_AVFileTypeMPEG4", referenced from:
CvVideoWriter_AVFoundation::CvVideoWriter_AVFoundation(char const*, int, double, CvSize, int) in libOpencvHighgui.a(cap_avfoundation.o)
"_AVFileTypeQuickTimeMovie", referenced from:
CvVideoWriter_AVFoundation::CvVideoWriter_AVFoundation(char const*, int, double, CvSize, int) in libOpencvHighgui.a(cap_avfoundation.o)
"_AVMediaTypeVideo", referenced from:
CvCaptureCAM::startCaptureDevice(int) in libOpencvHighgui.a(cap_avfoundation.o)
CvCaptureFile::CvCaptureFile(char const*) in libOpencvHighgui.a(cap_avfoundation.o)
CvVideoWriter_AVFoundation::CvVideoWriter_AVFoundation(char const*, int, double, CvSize, int) in libOpencvHighgui.a(cap_avfoundation.o)
。。。
...
在OpenCV2 highgui中,window_.mm
"_OBJC_CLASS_$_NSSlider", referenced from:
objc-class-ref in libOpencvHighgui.a(window_cocoa.o)
"_OBJC_CLASS_$_NSString", referenced from:
objc-class-ref in libOpencvHighgui.a(window_cocoa.o)
objc-class-ref in libOpencvHighgui.a(cap_avfoundation.o)
"_OBJC_CLASS_$_NSTextField", referenced from:
objc-class-ref in libOpencvHighgui.a(window_cocoa.o)
"_OBJC_CLASS_$_NSThread", referenced from:
objc-class-ref in libOpencvHighgui.a(window_cocoa.o)
"_OBJC_CLASS_$_NSURL", referenced from:
。。。
...
除了构建OpenCV之外,dlib_18_14 source.cpp中也发生了相同的错误
"_XAllocColor", referenced from:
void nativefont::font_renderer::font_renderer::vals_internal::create<unsigned int>(unsigned int*, int, bool, bool, bool, nativefont::font_renderer::font_renderer::rgb_type, nativefont::font_renderer::font_renderer::rgb_type) in libThirdPartyDlib_18_14.a(source.o)
"_XAllocSizeHints", referenced from:
dlib::base_window::set_size(int, int) in libThirdPartyDlib_18_14.a(source.o)
dlib::base_window::base_window(bool, bool) in libThirdPartyDlib_18_14.a(source.o)
dlib::gui_core_kernel_2_globals::event_handler_thread::event_handler() in libThirdPartyDlib_18_14.a(source.o)
"_XChangeProperty", referenced from:
dlib::gui_core_kernel_2_globals::event_handler_thread::event_handler() in libThirdPartyDlib_18_14.a(source.o)
"_XCheckIfEvent", referenced from:
dlib::gui_core_kernel_2_globals::event_handler_thread::event_handler() in libThirdPartyDlib_18_14.a(source.o)
"_XClearArea", referenced from:
dlib::base_window::invalidate_rectangle(dlib::rectangle const&) in libThirdPartyDlib_18_14.a(source.o)
"_XCloseDisplay", referenced from:
nativefont::font_renderer::font_renderer::vals_internal::~vals_internal() in libThirdPartyDlib_18_14.a(source.o)
dlib::gui_core_kernel_2_globals::event_handler_thread::~event_handler_thread() in libThirdPartyDlib_18_14.a(source.o)
"_XCloseIM", referenced from:
dlib::gui_core_kernel_2_globals::event_handler_thread::~event_handler_thread() in libThirdPartyDlib_18_14.a(source.o)
"_XConvertSelection", referenced from:
dlib::get_from_clipboard(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >&) in libThirdPartyDlib_18_14.a(source.o)
"_XCreateFontSet", referenced from:
dlib::base_window::base_window(bool, bool) in libThirdPartyDlib_18_14.a(source.o)
void nativefont::font_renderer::font_renderer::vals_internal::create<unsigned int>(unsigned int*, int, bool, bool, bool, nativefont::font_renderer::font_renderer::rgb_type, nativefont::font_renderer::font_renderer::rgb_type) in libThirdPartyDlib_18_14.a(source.o)
我不能在这里公开整个源代码,也不能公开SCON构建脚本,所以请注意
这是构建共享库(构建静态库没有问题,只有共享库)时我的scons脚本的示例片段:
这是你的电话号码
以下是InstallTargetShared的外观:
def __install_shared(ienv, name, srcs):
ienv.SharedLibrary(target = os.path.join(env.get('BUILD_DIR') +'/bin/', name), source = srcs)
env.AppendUnique(TS = [name])
env.AddMethod(__install_shared, 'InstallTargetShared')
在此问题上,如有任何帮助或建议,我们将不胜感激 查看完整的构建日志,我认为您需要链接几个OSX框架来解决您的问题。我在链接命令行中没有看到任何链接:
g++ -o out/darwin/x86_64/release/1.0.0/bin/libAPI3dfi_api_v1.dylib -ldl -lpthread -mmacosx-version-min=10.11 -DWITH_OPENEXR=OFF -dynamiclib out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_Api.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_App_Manager.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_App_Params.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_App_Retry.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_Event_Device_Heartbeat.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_Event_Device_Init.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_Event_Frame_Stats.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_Event_Manager.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_Event_Session_Assign.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_Event_Session_End.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_Event_Session_Start.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/SHA1Hash.os -L/usr/local/lib -L/opt/local/lib -Ldeps/darwin/lib/x86_64 -Lout/darwin/x86_64/release/1.0.0 -L. -Lout/darwin/x86_64/release/1.0.0/bin -Lbin -Lout/darwin/x86_64/release/1.0.0/lib -Llib -L/Users/tllewellynn/Desktop/dev/build_scons/runtime/darwin/xcode/x86_64/pthread/lib -L/Users/tllewellynn/Desktop/dev/build_scons/runtime/darwin/xcode/x86_64/intraface/lib -lSDK3dfi_detect -lSDK3dfi_algo -lSDK3dfi_au -lSDK3dfi_align -lSDK3dfi_proc -lSDK3dfi_cluster -lSDK3dfi_attr -lSDK3dfi_type -lOpencvCore -lOpencvHighgui -lOpencvImgproc -lOpencvObjdetect -lOpencvFlann -lOpencvFeature2d -lOpencvVideo -lOpencvCalib3d -lOpencvMl -lFreeimage -lFreeimageOpenEXR -lFreeimageLibTIFF -lFreeimageLibPNG -lFreeimageLibOpenJPEG -lFreeimageLibJPEG -lFreeimageLibMNG -lFreeimageZLib -lFrameworkNvaam_base -lFrameworkNvaam_filter -lFrameworkNvaam -lFrameworkProtobuf -lFrameworkLibbff -lFrameworkNvclassifier -lFrameworkNvexpression -lFrameworkTrimesh2 -lFrameworkPolyfit -lFrameworkGClasses -lFrameworkFlandmark -lFrameworkAlglib -lNetMsgpack -lNetJsoncpp -lNetTinyxml2 -lNetTinyxmlparam -lCnnEblearnTools -lCnnEblearnIdx -lCnnEblearn -lThirdPartyDlib_18_14 -lSystemTinycthread -lSystemTinythread -lSystemGlobal -lSystemDebug -lpthread -lTbb -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/
你在openCV论坛或IRC频道上问过吗
您的链接行中似乎缺少几个关键框架。什么是“InstallTargetShared”@bdbaddog InstallTargetShared是一个自定义函数,用于创建共享库,在windows上运行良好。如果您无法在此处发布源代码,最简单的方法是创建一个最小工作示例(MWE)用它来问你的问题。否则,我们将无法正确调试您的问题…@dirkbaechle我认为我发现的问题是使用SCons从源代码处编译第三方库OpenCV。我能够构建所有静态库,但在使用OpenCV 2.4.6和dlib构建共享库时,它会输出上面的错误,源代码没有任何内容。您可以将源代码发布到InstallTargetShared吗?或者像德克提到的,用一个最简单的例子来说明你的问题。除非我们可能无法解决您的问题。关于你的构建的完整日志如何?我只是为了OpenCV链接问题将它链接到一些框架,如CoreMedia和CoreVideo。关于dlib,我在它的Github存储库中发布了一个问题,并发现我需要针对X11进行链接。
def __install_shared(ienv, name, srcs):
ienv.SharedLibrary(target = os.path.join(env.get('BUILD_DIR') +'/bin/', name), source = srcs)
env.AppendUnique(TS = [name])
env.AddMethod(__install_shared, 'InstallTargetShared')
g++ -o out/darwin/x86_64/release/1.0.0/bin/libAPI3dfi_api_v1.dylib -ldl -lpthread -mmacosx-version-min=10.11 -DWITH_OPENEXR=OFF -dynamiclib out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_Api.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_App_Manager.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_App_Params.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_App_Retry.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_Event_Device_Heartbeat.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_Event_Device_Init.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_Event_Frame_Stats.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_Event_Manager.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_Event_Session_Assign.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_Event_Session_End.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_Event_Session_Start.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/SHA1Hash.os -L/usr/local/lib -L/opt/local/lib -Ldeps/darwin/lib/x86_64 -Lout/darwin/x86_64/release/1.0.0 -L. -Lout/darwin/x86_64/release/1.0.0/bin -Lbin -Lout/darwin/x86_64/release/1.0.0/lib -Llib -L/Users/tllewellynn/Desktop/dev/build_scons/runtime/darwin/xcode/x86_64/pthread/lib -L/Users/tllewellynn/Desktop/dev/build_scons/runtime/darwin/xcode/x86_64/intraface/lib -lSDK3dfi_detect -lSDK3dfi_algo -lSDK3dfi_au -lSDK3dfi_align -lSDK3dfi_proc -lSDK3dfi_cluster -lSDK3dfi_attr -lSDK3dfi_type -lOpencvCore -lOpencvHighgui -lOpencvImgproc -lOpencvObjdetect -lOpencvFlann -lOpencvFeature2d -lOpencvVideo -lOpencvCalib3d -lOpencvMl -lFreeimage -lFreeimageOpenEXR -lFreeimageLibTIFF -lFreeimageLibPNG -lFreeimageLibOpenJPEG -lFreeimageLibJPEG -lFreeimageLibMNG -lFreeimageZLib -lFrameworkNvaam_base -lFrameworkNvaam_filter -lFrameworkNvaam -lFrameworkProtobuf -lFrameworkLibbff -lFrameworkNvclassifier -lFrameworkNvexpression -lFrameworkTrimesh2 -lFrameworkPolyfit -lFrameworkGClasses -lFrameworkFlandmark -lFrameworkAlglib -lNetMsgpack -lNetJsoncpp -lNetTinyxml2 -lNetTinyxmlparam -lCnnEblearnTools -lCnnEblearnIdx -lCnnEblearn -lThirdPartyDlib_18_14 -lSystemTinycthread -lSystemTinythread -lSystemGlobal -lSystemDebug -lpthread -lTbb -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/