TL:DR - Build.gn文件中的正确调用是什么,以正确地将Chromium链接到第三方Mac OS X Framework(并将其包含在内容/框架/应用程序包路径中)?
请参阅下面的Build.gn和路径设置。
我通过第三方库添加对视频捕获的支持来自定义Chrome浏览器。我修改了现有的Build.gn文件来查找我的第三方deps并编译我的新源代码。我修改了现有的Chromium Build.gn以包含我的新依赖项:
媒体/捕获/视频/ MAC / DEPS:
include_rules = [
"+third_party/decklink",
"+third_party/Syphon",
哪个正确找到了我的新Build.gn for the Framework,Siphon:
我的Build.gn如下:
if (is_mac) {
loadable_module("Syphon") {
lib_dirs = ["//third_party/Syphon/mac/"]
libs = ["Syphon.framework"]
}
编译工作正常,但如果我尝试使用Framework I' m中包含的对象,则构建失败。我已经习惯了OS X / Xcode上的这些链接错误,但是对于Ninja / GN,我不清楚解决它们的正确方法。
忍者的输出:
注 - 生成的链接器参数有一个链接器标志,可以正确使用-L / path / to / third_party / Siphon / mac /来保存Syphon.framework,但是-framework命令找不到Siphon。
我试图使用不同的Build.gn命令(比如ldflags),但都会导致同样的问题。
谢谢。
ninja -C out/Default
ninja: Entering directory `out/Default'
[4/5095] SOLINK libcapture.dylib libcapture.dylib.TOC
FAILED: libcapture.dylib libcapture.dylib.TOC
if [ ! -e "./libcapture.dylib" -o ! -e "./libcapture.dylib.TOC" ] || otool -l "./libcapture.dylib" | grep -q LC_REEXPORT_DYLIB ; then TOOL_VERSION=1484604693 ../../build/toolchain/mac/linker_driver.py ../../third_party/llvm-build/Release+Asserts/bin/clang++ -shared -Wl,-install_name,@rpath/"libcapture.dylib" -stdlib=libc++ -arch x86_64 -Werror -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.9 -Wl,-ObjC -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/../../.. -o "./libcapture.dylib" -Wl,-filelist,"./libcapture.dylib.rsp" -framework AVFoundation -framework CoreFoundation -framework CoreGraphics -framework CoreMedia -framework CoreVideo -framework Foundation -framework IOKit ./libbase.dylib ./libbase_i18n.dylib ./libmedia.dylib ./libskia.dylib ./libdisplay.dylib ./libgfx.dylib ./libicui18n.dylib ./libicuuc.dylib ./libshared_memory_support.dylib ./libbindings.dylib ./libmojo_public_system_cpp.dylib ./libmojo_public_system.dylib ./libdisplay_types.dylib ./libgeometry.dylib ./librange.dylib && { otool -l "./libcapture.dylib" | grep LC_ID_DYLIB -A 5; nm -gP "./libcapture.dylib" | cut -f1-2 -d' ' | grep -v U$$; true; } > "./libcapture.dylib.TOC"; else TOOL_VERSION=1484604693 ../../build/toolchain/mac/linker_driver.py ../../third_party/llvm-build/Release+Asserts/bin/clang++ -shared -Wl,-install_name,@rpath/"libcapture.dylib" -stdlib=libc++ -arch x86_64 -Werror -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.9 -Wl,-ObjC -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/../../.. -o "./libcapture.dylib" -Wl,-filelist,"./libcapture.dylib.rsp" -framework AVFoundation -framework CoreFoundation -framework CoreGraphics -framework CoreMedia -framework CoreVideo -framework Foundation -framework IOKit ./libbase.dylib ./libbase_i18n.dylib ./libmedia.dylib ./libskia.dylib ./libdisplay.dylib ./libgfx.dylib ./libicui18n.dylib ./libicuuc.dylib ./libshared_memory_support.dylib ./libbindings.dylib ./libmojo_public_system_cpp.dylib ./libmojo_public_system.dylib ./libdisplay_types.dylib ./libgeometry.dylib ./librange.dylib && { otool -l "./libcapture.dylib" | grep LC_ID_DYLIB -A 5; nm -gP "./libcapture.dylib" | cut -f1-2 -d' ' | grep -v U$$; true; } > "./libcapture.dylib.tmp" && if ! cmp -s "./libcapture.dylib.tmp" "./libcapture.dylib.TOC"; then mv "./libcapture.dylib.tmp" "./libcapture.dylib.TOC" ; fi; fi
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_SyphonServerDirectory", referenced from:
objc-class-ref in video_capture_device_syphon_mac.o
"_SyphonServerDescriptionAppNameKey", referenced from: media::VideoCaptureDeviceSyphonMac::EnumerateDevices(std::__1::vector<media::VideoCaptureDeviceDescriptor, std::__1::allocator<media::VideoCaptureDeviceDescriptor> >*) in video_capture_device_syphon_mac.o "_SyphonServerDescriptionNameKey", referenced from:media::VideoCaptureDeviceSyphonMac::EnumerateDevices(std::__1::vector<media::VideoCaptureDeviceDescriptor, std::__1::allocator<media::VideoCaptureDeviceDescriptor> >*) in video_capture_device_syphon_mac.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Traceback (most recent call last):
File "../../build/toolchain/mac/linker_driver.py", line 229, in <module>
Main(sys.argv)
File "../../build/toolchain/mac/linker_driver.py", line 79, in Main
subprocess.check_call(compiler_driver_args)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 540, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['../../third_party/llvm-build/Release+Asserts/bin/clang++', '-shared', '-Wl,-install_name,@rpath/libcapture.dylib', '-stdlib=libc++', '-arch', 'x86_64', '-Werror', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk', '-mmacosx-version-min=10.9', '-Wl,-ObjC', '-Wl,-rpath,@loader_path/.', '-Wl,-rpath,@loader_path/../../..', '-o', './libcapture.dylib', '-Wl,-filelist,./libcapture.dylib.rsp', '-framework', 'AVFoundation', '-framework', 'CoreFoundation', '-framework', 'CoreGraphics', '-framework', 'CoreMedia', '-framework', 'CoreVideo', '-framework', 'Foundation', '-framework', 'IOKit', './libbase.dylib', './libbase_i18n.dylib', './libmedia.dylib', './libskia.dylib', './libdisplay.dylib', './libgfx.dylib', './libicui18n.dylib', './libicuuc.dylib', './libshared_memory_support.dylib', './libbindings.dylib', './libmojo_public_system_cpp.dylib', './libmojo_public_system.dylib', './libdisplay_types.dylib', './libgeometry.dylib', './librange.dylib']' returned non-zero exit status 1
[13/5095] CXX obj/third_party/WebKit/Source/wtf/wtf_unittests/ListHashSetTest.o
ninja: build stopped: subcommand failed.
答案 0 :(得分:1)
ldflags是诀窍,传递-F来更新Framework搜索路径,(不是带-L或lib_dirs命令的库路径)
if (is_mac) {
loadable_module("Syphon") {
ldflags = ["-F"+"../../third_party/Syphon/mac/"]
libs = ["Syphon.framework"]
}