(clang++) Symbol not found from libstdc++.6.0.9.dylib - xcode

I meet an error called "Symbol not found" on matlab. The error message is in below.
Symbol not found: __ZNKSt5ctypeIcE13_M_widen_initEv
Referenced from: blabla/lib/buildW.mexmaci64
Expected in: /usr/lib/libstdc++.6.0.9.dylib
There are quite bunch of questions like me, but I never found the solution of this problem. The former threads mentioned conflicts between the updated clang and the clang used.
Here are exmaples of questions on the similar question.
Need help finding Undefined Symbols
Handling "dyld: lazy symbol binding failed: Symbol not found" error when nm does not find symbol
https://github.com/Homebrew/homebrew-core/issues/4902
I currently installed Xcode 9.2.
And in matlab, I use MacOSX10.13.sdk like below.
>> edit ([matlabroot '/bin/maci64/mexopts/clang++_maci64.xml'])
...
...
<dirExists name="$$/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk" />
<cmdReturns name="find $$ -name MacOSX10.13.sdk" />
Also, I found that there are three files in "/usr/lib"
/usr/lib/libstdc++.6.0.9.dylib
/usr/lib/libstdc++.6.dylib
/usr/lib/libstdc++.dylib
Can anyone help me?

The symbol __ZNKSt5ctypeIcE13_M_widen_initEv (demangled std::ctype<char>::_M_widen_init() const) is defined in libstdc++.dylib but if you execute
nm /usr/lib/libstdc++.dylib | fgrep __ZNKSt5ctypeIcE13_M_widen_initEv
you will get
0000000000006a14 t __ZNKSt5ctypeIcE13_M_widen_initEv
as result. The t means that it's defined in the TEXT section but it's a local symbol which cannot referenced from outside the library.
Clang in Xcode uses
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/lib/libstdc++.tbd
for linking instead of /usr/lib/libstdc++.dylib. This is a human readable file which contains only the name of the public symbols in libstdc++.dylib. Since the symbol above is private it is not listed in the .tbd file.

Related

NativeScript "File Not Found With angled Include; use 'quote' instead"

I'm trying to add the VKVideoPlayer CocoaPod to a NativeScript app, but the build fails with 'DDLog.h' file not found with <angled> include; use "quotes" instead.
This include is in a library (VKFoundation) that is referenced by the VKVideoPlayer. This VKFoundation.h file in turn references the DDLog.h (from CocoaLumberjack) and DTCoreText.h (from DTCoreText).
All of these libraries are pulled in by the VKVideoPlayer Pod.
Here is the relevant error from the command line...
/Users/burkeholland/dev/burkeholland/nativescript-video-player/demo/platforms/ios/Pods/VKFoundation/Classes/ios/VKFoundation.h:6:9: error:
'DDLog.h' file not found with <angled> include; use "quotes" instead
#import <DDLog.h>
^~~~~~~~~
"DDLog.h"
/Users/burkeholland/dev/burkeholland/nativescript-video-player/demo/platforms/ios/Pods/VKFoundation/Classes/ios/VKFoundation.h:7:9: error:
'DTCoreText.h' file not found with <angled> include; use "quotes" instead
#import <DTCoreText.h>
^~~~~~~~~~~~~~
"DTCoreText.h"
2 errors generated.
The error can be reproduced from this GitHub project.
The error itself indicates that one of the referenced headers (DDLog.h) is referenced with <, but the compiler cannot find it. So it suggests you to try using " quotes instead of angles (<). This is a common error raised by XCode when it's unable to find referenced header.
As per your problem, I believe the problem is with VKFoundation Cocoapod, which is a dependency of VKVideoPlayer Pod. Here's a related issue:
https://github.com/viki-org/VKFoundation/issues/5
You can try using the suggested Podfile and see if it works on your side.

osx - WebRTC linkage issue

I'm trying to integrate WebRTC in one OSX Desktop application and I'm getting some errors when I try to link with webRTC library. The issue is:
Undefined symbols for architecture x86_64:
"_AVMediaTypeMuxed", referenced from:
cricket::GetAVFoundationVideoDevices(std::vector<cricket::Device, std::allocator<cricket::Device> >*) in libWebRTC-arm64-debug.a(libjingle_media.macdevicemanagermm.o)
This tell me that I have not defined this symbol in my libjingle_media.a, wich is true according with it:
$ nm libjingle_media.a | grep _AVMediaTypeMuxed
warning: /Applications/Xcode64.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm: no name list
U _AVMediaTypeMuxed
I have built WebRTC using this flags:
GYP_DEFINES="build_with_libjingle=1 build_with_chromium=0 libjingle_objc=1 OS=mac target_arch=x64"
GYP_GENERATORS="ninja"
GYP_GENERATOR_FLAGS="$GYP_GENERATOR_FLAGS output_dir=out_mac"
and of course with ninja, running previously gclient runhooks. Any idea about what is happening with this?
To solve this issue, you need to use a particular framework that implements the function, in this case a framework called AVFoundation

Symbol not found: _SSLv2_client_method

I was trying to update openssl so that it could use libssl.1.0.0 instead of libssl.0.9.8.dylib
So I moved the two files
/usr/lib/libssl.0.9.8.dylib
/usr/lib/libssl.0.9.7.dylib
into my home and I copied libssl.1.0.0.dylib inside /usr/lib. That didn't worked too so I re-moved the two original files to their location but now Apache (and other app using ssl) don't start anymore. Apache says:
Syntax error on line 111 of /Applications/MAMP/conf/apache/httpd.conf: Cannot load /Applications/MAMP/Library/modules/mod_ssl.so into server: dlopen(/Applications/MAMP/Library/modules/mod_ssl.so, 10): Symbol not found: _SSLv2_client_method\n Referenced from: /Applications/MAMP/Library/modules/mod_ssl.so\n Expected in: /usr/lib/libssl.0.9.8.dylib\n in /Applications/MAMP/Library/modules/mod_ssl.so`
and libssl.0.9.8.dylib is present inside usr/lib so I don't know why/what it does not find. Is it possibile to fix?

Link Error 2001 when linking to User32.dll

I'm trying to link an object file that uses two methods declared in winuser.h and defined in User32.dll: GetMonitorInfo and WindowFromMonitor. The source compiles to an object file just fine, but when I try to link, I get the following error output:
D3dCtx.obj : error LNK2001: unresolved external symbol xGetMonitorInfo
D3dCtx.obj : error LNK2001: unresolved external symbol xMonitorFromWindow
The thing is, I don't call "xGetMonitorInfo" or "xMonitorFromWindow". Running grep on all source files shows that only "GetMonitorInfo" and "WindowFromMonitor" are being called. I'm properly including windows.h, which includes winuser.h. I'm also properly setting my LIBPATH in the linker options, which is confirmed by verbose link output.
The following also appears in my verbose link output:
Found __imp_GetMonitorInfoA
Referenced in nafxcw.lib(afxribboncategory.obj)
Referenced in nafxcw.lib(afxtooltipctrl.obj)
Referenced in nafxcw.lib(afxribbonkeytip.obj)
Referenced in nafxcw.lib(afxfullscreenimpl.obj)
Referenced in nafxcw.lib(afxframeimpl.obj)
Referenced in nafxcw.lib(afxglobalutils.obj)
Referenced in nafxcw.lib(afxdropdowntoolbar.obj)
Referenced in nafxcw.lib(wincore.obj)
Referenced in nafxcw.lib(afxglobals.obj)
Referenced in nafxcw.lib(afxpopupmenu.obj)
Referenced in nafxcw.lib(afxpropertygridtooltipctrl.obj)
Loaded User32.lib(USER32.dll)
Found __imp_MonitorFromWindow
Referenced in nafxcw.lib(wincore.obj)
Loaded User32.lib(USER32.dll)
Furthermore, GetMonitorInfo is defined in winuser.h as:
WINUSERAPI
BOOL
WINAPI
GetMonitorInfoA(
__in HMONITOR hMonitor,
__inout LPMONITORINFO lpmi);
WINUSERAPI
BOOL
WINAPI
GetMonitorInfoW(
__in HMONITOR hMonitor,
__inout LPMONITORINFO lpmi);
#ifdef UNICODE
#define GetMonitorInfo GetMonitorInfoW
#else
#define GetMonitorInfo GetMonitorInfoA
#endif // !UNICODE
When I change all reference to "GetMonitorInfo" to "GetMonitorInfoA", I only get
D3dCtx.obj : error LNK2001: unresolved external symbol xMonitorFromWindow
as my linker error output. Unfortunately, MonitorFromWindow doesn't seem to have multiple versions available.
I should note that I am using the 64bit versions of the libraries, link, and cl.
What's going on here, and how can I successfully link my program?
I don't know whether you were able to find solution to this or not But I had the same problem and the reason this was happening was that I had a file included named multimon.h
Looks like in case of 64 bit compilation, due to Macro definitions, the definitions of these functions are coming from two sources and probably one from multimon.h is overriding and is wrong.
I solved it by just commenting out this include and it has started to link fine.
//#include <multimon.h>

Xcode linker and blocks: Undefined symbol "___block_global_1"

I am trying to build an application in Xcode 3.2.4 and am getting the following linker error:
Undefined symbols:
"___block_global_1", referenced from:
___block_holder_tmp_1.120 in foobarbaz.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
I'm at a loss to explain what I've done in my source file that might be causing the error. I do have a block that I am defining as a global variable, like so:
typedef void(^error_block_t)(NSError* error);
error_block_t error_handler_s = ^void(NSError* error)
{
//...
}
This block is defined in an empty namespace in the source (I'm compiling Objective-C++.) Everything compiles without error.
Update: Moving the block to be a local variable for the routine that references it is a viable (though not preferred) workaround.
What gives?
If the error_handler_s is not intended to be exported, you could make it static as another workaround.
namespace {
...
static error_block_t error_handler_s = ^void(NSError* error) { ... };
...
}
Otherwise, I believe this is a bug in gcc.
At this point I believe this issue to be a bug.

Resources