When I do this, I am always careful to follow the various build settings from the cefsimple Xcode project in the binary distribution, as far as possible. Usually, I experience no difficulties, and the resulting app works as expected.
However, this time I am encountering a linker error I don't understand:
- Code: Select all
Showing All Messages
Ld /cef-source-4638/xcode12.5.1/CEF3CustomSample/build/Release/CEF3CustomSample.app/Contents/MacOS/CEF3CustomSample normal (in target 'CEF3CustomSample' from project 'CEF3CustomSample')
cd /cef-source-4638/xcode12.5.1/CEF3CustomSample
/Applications/Xcode12.5.1/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -target x86_64-apple-macos10.11 -isysroot /Applications/Xcode12.5.1/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk -L/cef-source-4638/xcode12.5.1/CEF3CustomSample/build/Release -L/cef-source-4638/xcode12.5.1/CEF3CustomSample/cef/lib -F/cef-source-4638/xcode12.5.1/CEF3CustomSample/build/Release -filelist /cef-source-4638/xcode12.5.1/CEF3CustomSample/build/CEF3CustomSample.build/Release/CEF3CustomSample.build/Objects-normal/x86_64/CEF3CustomSample.LinkFileList -dead_strip -Wl,-search_paths_first -Wl,-ObjC -Wl,-pie -Wl,-dead_strip -Wl,-search_paths_first -Wl,-headerpad_max_install_names -lpthread -lcef_dll_wrapper -framework Cocoa -framework AppKit -Xlinker -dependency_info -Xlinker /cef-source-4638/xcode12.5.1/CEF3CustomSample/build/CEF3CustomSample.build/Release/CEF3CustomSample.build/Objects-normal/x86_64/CEF3CustomSample_dependency_info.dat -o /cef-source-4638/xcode12.5.1/CEF3CustomSample/build/Release/CEF3CustomSample.app/Contents/MacOS/CEF3CustomSample
Undefined symbols for architecture x86_64:
"base::cef_subtle::RefCountedThreadSafeBase::~RefCountedThreadSafeBase()", referenced from:
base::internal::BindState<void (SimpleHandler::*)(bool), scoped_refptr<SimpleHandler>, bool>::Destroy(base::internal::BindStateBase const*) in simple_handler.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This is the affected line of code (from simple_handler.cpp):
- Code: Select all
CefPostTask(TID_UI, base::BindOnce(&SimpleHandler::CloseAllBrowsers, this, force_close));
This same line of code occurs in the cefsimple demo app, but there it does not produce the linker error.
The undefined symbol "~RefCountedThreadSafeBase" is defined in the CEF wrapper library:
include/base/cef_ref_counted.h
- Code: Select all
...
namespace base {
namespace cef_subtle {
...
class RefCountedThreadSafeBase {
...
protected:
...
#if DCHECK_IS_ON()
~RefCountedThreadSafeBase();
#else
~RefCountedThreadSafeBase() = default;
#endif
...
libcef_dll/base/cef_ref_counted.cc
- Code: Select all
...
namespace base {
...
namespace cef_subtle {
...
#if DCHECK_IS_ON()
RefCountedThreadSafeBase::~RefCountedThreadSafeBase() {
DCHECK(in_dtor_) << "RefCountedThreadSafe object deleted without "
"calling Release()";
}
#endif
...
If I link with the debug version of the CEF wrapper library, the linker error does not occur.
So far, the only way I have found to address this problem is to modify the CEF include file and wrapper library as follows:
include/base/cef_ref_counted.h:
- Code: Select all
...
namespace base {
namespace cef_subtle {
...
class RefCountedThreadSafeBase {
...
protected:
...
// modified to prevent linker error
//#if DCHECK_IS_ON()
// ~RefCountedThreadSafeBase();
//#else
// ~RefCountedThreadSafeBase() = default;
//#endif
~RefCountedThreadSafeBase();
...
libcef_dll/base/cef_ref_counted.cc
- Code: Select all
...
namespace base {
...
namespace cef_subtle {
...
// modified to prevent linker error
//#if DCHECK_IS_ON()
//RefCountedThreadSafeBase::~RefCountedThreadSafeBase() {
// DCHECK(in_dtor_) << "RefCountedThreadSafe object deleted without "
// "calling Release()";
//}
//#endif
RefCountedThreadSafeBase::~RefCountedThreadSafeBase() {
#if DCHECK_IS_ON()
DCHECK(in_dtor_) << "RefCountedThreadSafe object deleted without "
"calling Release()";
#endif
}
...
These changes ensure there is at least an empty constructor in the release build, which is apparently enough to satisfy the linker.
I cannot determine why this issue occurs only for this one single symbol, nor why it does not occur in the cefsimple Xcode project in the binary distribution, when linking with the same library file. I don't even know why it does not occur when linking with the debug version of the library.
Can anyone help me to determine what the problem might be? I would greatly appreciate any assistance with identifying the cause of this error, or how to prevent it without modifying CEF code or being forced to link with the debug version of the wrapper library.