NX NXString std::string constructor causes linker error on Linux with NX 1926 Batch

2021-10-06T23:27:49Z
NX Open NX System Administration

Summary


Details

In NXOpen Linux batch, the following C++ code is causing a linker error:


std::string string = "test"; 
NXOpen::NXString nxstring = NXOpen::NXString(string);


nxstring_linux.cxx:(.text+0x81): undefined reference to `NXOpen::NXString::NXString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, NXOpen::NXString::NXStringMode)'


Or any other similar code that assigns a std::string to a NXOpen::NXString.



Solution

Set: #define _GLIBCXX_USE_CXX11_ABI 0 at the top of your code or as compiler define option.


This will disable specialized C++11 namespace: 'std::_cxx11'


This will resolve the linker error which is using, 'std' namespace



Notes and References


Hardware/Software Configuration

Platform: all
OS: n/a
OS Version: n/a
Product: NX
Application: SYSENG
Version: V1899
Function: NXOPEN

Ref: 001-9930365

KB Article ID# PL8519819

Contents

SummaryDetails

Associated Components

Block/UI Interface Stylers Knowledge Fusion Menuscript NX Open - All Languages NX Open Python Open for C/C++ Open for CAE Open for GRIP Open for Java Pre-NX6 UI Styler SNAP UDO