From kdrake3 at oswego.edu Wed Feb 5 12:30:45 2014 From: kdrake3 at oswego.edu (Kevin Drake) Date: Wed Feb 5 22:52:11 2014 Subject: [xsde-users] libxsde.a - undefined reference to 'std::ios_base::Init::Init() Message-ID: I am new to codesynthesis xsde and have an issue when compiling/linking my test application with the runtime libxsde.a library that I built. I get the following errors during the link stage. 'Building target: cpac_message_test.elf' 'Executing target #164 cpac_message_test.elf' 'Invoking: ARM Ltd Windows GCC C++ Linker' "C:/Freescale/CW MCU v10.5/Cross_Tools/arm-none-eabi-gcc-4_7_3/bin/arm-none-eabi-g++" @"cpac_message_test.args" -o"cpac_message_test.elf" C:/xsde/xsde-3.2.0/libxsde/xsde/libxsde.a(ro-string.o): In function `_GLOBAL__sub_I__ZN4xsde3cxx9ro_string4nposE': ro-string.cxx:(.text.startup+0xc): undefined reference to `std::ios_base::Init::Init()' ro-string.cxx:(.text.startup+0x2c): undefined reference to `std::ios_base::Init::~Init()' C:/xsde/xsde-3.2.0/libxsde/xsde/libxsde.a(exceptions.o): In function `_GLOBAL__sub_I__ZN4xsde3cxx10serializerlsERSoRKNS1_9exceptionE': exceptions.cxx:(.text.startup+0xc): undefined reference to `std::ios_base::Init::Init()' exceptions.cxx:(.text.startup+0x2c): undefined reference to `std::ios_base::Init::~Init()' collect2.exe: error: ld returned 1 exit status I have researched the problem and have ruled out the usual mistakes like using gcc instead of g++ or not using g++ linker. Below are the steps and background of how I proceeded to this point. Any direction or advice that can be provide to give me additional things to try would be most appreciated. 1. I am using an ARM cross compiler with a Linux target and modified the xsde "config.make" file as the snippet below shows. Note, I did a "make clean" after updating config.make and then proceeded with issuing a "make" to rebuild all files. CC := arm-none-eabi-gcc CFLAGS := -W -Wall -O3 CPPFLAGS := CXX := arm-none-eabi-g++ CXXFLAGS := -W -Wall -O3 LD := $(CXX) LDFLAGS := $(CXXFLAGS) LIBS := # Optional post-link command. The first argument to this command is # the executable name and the rest of the arguments are the object # files and libraries that were used to link this executable. # POSTLD := # Set RANLIB to empty if your system does not need ranlib. # AR := ar ARFLAGS := rc RANLIB := ranlib # Common XSD/e flags. # XSDFLAGS := --generate-inline # Platform. Valid values are: # # 'wince' - Windows CE # 'win32' - Windows 2000, XP, etc. # 'posix' - POSIX OS, including UNIX/Linux, VxWorks, etc. # XSDE_PLATFORM := posix 2. I generated my parser/serializer code from my schema using the following command xsde cxx-hybrid --no-long-long --generate-aggregate --generate-parser --generate-serializer -output-dir ..\..\Binding ..\..\XmlSchema\*.xsd 3. I'm using codewarrior as an Eclipse IDE and imported the include and source files into my project 4. Added the include path for my imported files, the xsde library path, and the libxsde.a to the list of libraries 5. Ensured that I included libstdc++ in my linker arguments. The full list of libraries is listed below. -lgcc -lc -lrt -lm -lc++ -lsupc++ -lstdc++ -lhosted -lxsde 6. Within the codewarrior IDE I performed a "Clean Project" followed by a "Build Project" to ensure a full rebuild and link. The errors listed above containing the undefined references were the result. Again, any advice that can be provided to help me past this issue would be much appreciated. Regards, Kevin Drake From boris at codesynthesis.com Wed Feb 5 23:29:02 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Feb 5 23:26:58 2014 Subject: [xsde-users] libxsde.a - undefined reference to 'std::ios_base::Init::Init() In-Reply-To: References: Message-ID: Hi Kevin, Thanks for provided a detailed description of your setup. It makes figuring out what's wrong so much easier and I wish everyone would send reports like this. Kevin Drake writes: > -lgcc -lc -lrt -lm -lc++ -lsupc++ -lstdc++ -lhosted -lxsde Try to put -lxsde before all the system libraries (especially lstdc++). When using static libraries this order becomes important and generally you should try ti list them in the most specific (e.g., user libraries) to most generic (e.g., system libraries) order. In fact, your list looks like it needs to be reversed. Boris From kdrake3 at oswego.edu Thu Feb 6 11:47:12 2014 From: kdrake3 at oswego.edu (Kevin Drake) Date: Thu Feb 6 11:54:27 2014 Subject: [xsde-users] libxsde.a - undefined reference to 'std::ios_base::Init::Init() In-Reply-To: References: Message-ID: Hi Boris, Glad to provide you as much detail as possible. Thank you for the quick response and the advice you provided. I modified the linker portion of my project's build settings, but still get the same results. I tried to correct the problem in two different ways. Below are the details. 1. I modified the linker flags and placed libxsde.a at the front of the system library list. --start-group "C:/xsde/xsde-3.2.0/libxsde/xsde/libxsde.a" -Xlinker --end-group --start-group "C:/xsde/xsde-3.2.0/libxsde/xsde/libxsde.a" -Xlinker --end-group --start-group "${MQX_ROOT_DIR}/lib/twrk70f120m.cw10gcc/release/psp/psp.a" -Xlinker --end-group --start-group "${MQX_ROOT_DIR}/lib/twrk70f120m.cw10gcc/release/bsp/bsp.a" -Xlinker --end-group --undefined=__pformatterFP --defsym=__pformatter=__pformatterFP --start-group -lxsde -lgcc -lc -lrt -lm -lc++ -lsupc++ -lstdc++ -lhosted -lshell-cpp-dbg -lmfs-cpp-dbg -lrtcs-cpp-dbg --end-group I did a clean and re-build of the project but got the same results. I also tried to modify the order of the system libraries as you suggested, but ended up with other errors from dependent code provided by others working on the project. I then went back to original order and moved on to trying option 2. 2. I thought more about what was trying to do and decided to take the libxsde.a library out of the system library list and added xsde to the list of "other objects" that get placed before the system libraries when the link command is issued. "${MCU_TOOLS_HOME}/../MCU/ARM_GCC_Support/ewl/lib/armv7e-m/softfp/__arm_start.o" "${MCU_TOOLS_HOME}/../MCU/ARM_GCC_Support/ewl/lib/armv7e-m/softfp/__arm_end.o" "C:/xsde/xsde-3.2.0/libxsde/xsde/libxsde.a" "${MQX_ROOT_DIR}/lib/twrk70f120m.cw10gcc/release/psp/psp.a" "${MQX_ROOT_DIR}/lib/twrk70f120m.cw10gcc/release/bsp/bsp.a" Again, I did a clean and re-build of the project. Unfortunately, I got the same errors. Do you have any other suggestions I can try? Are there any additional options to try with how I built the runtime libxsde.a library? Kevin On Wed, Feb 5, 2014 at 11:29 PM, Boris Kolpackov wrote: > Hi Kevin, > > Thanks for provided a detailed description of your setup. It makes > figuring out what's wrong so much easier and I wish everyone would > send reports like this. > > Kevin Drake writes: > > > -lgcc -lc -lrt -lm -lc++ -lsupc++ -lstdc++ -lhosted -lxsde > > Try to put -lxsde before all the system libraries (especially > lstdc++). When using static libraries this order becomes > important and generally you should try ti list them in the > most specific (e.g., user libraries) to most generic (e.g., > system libraries) order. In fact, your list looks like it > needs to be reversed. > > Boris > From boris at codesynthesis.com Thu Feb 6 12:11:35 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Feb 6 12:09:30 2014 Subject: [xsde-users] libxsde.a - undefined reference to 'std::ios_base::Init::Init() In-Reply-To: References: Message-ID: Hi Kevin, Kevin Drake writes: > Do you have any other suggestions I can try? Are there any additional > options to try with how I built the runtime libxsde.a library? There are two things that you can try: 1. Try to compile and link a hello world application (that uses iostream) manually by invoking your g++ cross-compiler. If that works, then add the -v option to the linker step and see what libraries are being linked and in what order (libxsde.a should come right after your object files). 2. If #1 doesn't work (i.e., you get the same link errors), then it most likely means that libstdc++ for your target were built with iostream support disabled. In this case, you will also need to disable it in XSD/e (see the XSDE_IOSTREAM config.make variable and the --no-iostream compiler option). Boris From kdrake3 at oswego.edu Thu Feb 6 13:29:49 2014 From: kdrake3 at oswego.edu (Kevin Drake) Date: Thu Feb 6 22:18:49 2014 Subject: [xsde-users] libxsde.a - undefined reference to 'std::ios_base::Init::Init() In-Reply-To: References: Message-ID: Hi Boris, You were spot on with your advice. I tried the hello world example using the ARM g++ cross compiler that I'm using with my application. It failed with several undefined references. I then went back and cleaned / rebuilt the xsde runtime library with the "XSDE_IOSTREAM" variable disabled in the config.make file. Next, I regenerated my binding source and include files using the "-no-iostream" compiler option. Finally, I imported the new binding files into my project and cleaned / rebuilt the application. Sure enough, that resolved my issues and I got a clean executable. Whew, thanks! -Kevin On Thu, Feb 6, 2014 at 12:11 PM, Boris Kolpackov wrote: > Hi Kevin, > > Kevin Drake writes: > > > Do you have any other suggestions I can try? Are there any additional > > options to try with how I built the runtime libxsde.a library? > > There are two things that you can try: > > 1. Try to compile and link a hello world application (that uses iostream) > manually by invoking your g++ cross-compiler. If that works, then > add the -v option to the linker step and see what libraries are > being linked and in what order (libxsde.a should come right after > your object files). > > 2. If #1 doesn't work (i.e., you get the same link errors), then it > most likely means that libstdc++ for your target were built with > iostream support disabled. In this case, you will also need to > disable it in XSD/e (see the XSDE_IOSTREAM config.make variable > and the --no-iostream compiler option). > > Boris > From vladimir.zykov at doctormobile.us Tue Feb 11 06:29:46 2014 From: vladimir.zykov at doctormobile.us (Vladimir Zykov) Date: Tue Feb 11 10:01:59 2014 Subject: [xsde-users] bad_cast when generating from schemas having element and attribute with same name Message-ID: <83379D35-7C8F-4983-BDE8-FFF2007A2773@doctormofile.us> Hello, We found recently a problem in XSD/e. If we run the following command on the attached schemas we get bad_cast exception. ./xsde cxx-hybrid --file-per-type s1.xsd warning D001: --extern-xml-schema is recommended when --file-per-type is specified to reduce generated code size terminate called after throwing an instance of 'std::bad_cast' what(): std::bad_cast Abort trap: 6 We fixed this by changing line 490 in xsde-3.2.0-1+dep/libxsd-frontend/xsd-frontend/parser.cxx to if (ref.is_a () && m.is_a ()) However, it's not clear whether code generation goes as intended in this case. Thanks -------------- next part -------------- A non-text attachment was scrubbed... Name: bad_cast.tar.gz Type: application/x-gzip Size: 493 bytes Desc: bad_cast.tar.gz Url : http://codesynthesis.com/pipermail/xsde-users/attachments/20140211/244a000b/bad_cast.tar.bin -------------- next part -------------- Vladimir Zykov Software Engineer Doctor Mobile, LLC From boris at codesynthesis.com Wed Feb 12 00:01:04 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Feb 11 23:58:58 2014 Subject: [xsde-users] bad_cast when generating from schemas having element and attribute with same name In-Reply-To: <83379D35-7C8F-4983-BDE8-FFF2007A2773@doctormofile.us> References: <83379D35-7C8F-4983-BDE8-FFF2007A2773@doctormofile.us> Message-ID: Hi Vladimir, Vladimir Zykov writes: > We fixed this by changing line 490 in parser.cxx to > > if (ref.is_a () && m.is_a ()) This bug has already been fixed and the correct fix is to change this line (478): Member& ref (resolve (ns_name, uq_name, s_, cache_)); To read: // Resolve the name to the same type. It is legal to have // an element and an attribute with the same name. // Member& ref ( m.is_a () ? static_cast ( resolve (ns_name, uq_name, s_, cache_)) : static_cast ( resolve (ns_name, uq_name, s_, cache_))); Thanks for the report and let me know if you run into any other problems. Boris From vladimir.zykov at doctormobile.us Wed Feb 12 06:16:16 2014 From: vladimir.zykov at doctormobile.us (Vladimir Zykov) Date: Wed Feb 12 09:13:53 2014 Subject: [xsde-users] bad_cast when generating from schemas having element and attribute with same name In-Reply-To: References: <83379D35-7C8F-4983-BDE8-FFF2007A2773@doctormofile.us> Message-ID: Hi Boris, Where can we obtain the latest source code for XSD/e? We have xsde-3.2.0-1 and we thought this is the latest. Thanks On Feb 12, 2014, at 7:01 AM, Boris Kolpackov wrote: > Hi Vladimir, > > Vladimir Zykov writes: > >> We fixed this by changing line 490 in parser.cxx to >> >> if (ref.is_a () && m.is_a ()) > > This bug has already been fixed and the correct fix is to change > this line (478): > > Member& ref (resolve (ns_name, uq_name, s_, cache_)); > > To read: > > // Resolve the name to the same type. It is legal to have > // an element and an attribute with the same name. > // > Member& ref ( > m.is_a () > ? static_cast ( > resolve (ns_name, uq_name, s_, cache_)) > : static_cast ( > resolve (ns_name, uq_name, s_, cache_))); > > Thanks for the report and let me know if you run into any other > problems. > > Boris Vladimir Zykov Software Engineer Doctor Mobile, LLC From boris at codesynthesis.com Wed Feb 12 09:38:34 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Feb 12 09:36:29 2014 Subject: [xsde-users] bad_cast when generating from schemas having element and attribute with same name In-Reply-To: References: <83379D35-7C8F-4983-BDE8-FFF2007A2773@doctormofile.us> Message-ID: Hi Vladimir, Vladimir Zykov writes: > Where can we obtain the latest source code for XSD/e? We have > xsde-3.2.0-1 and we thought this is the latest. XSD/e 3.2.0 is the latest released version of XSD/e. The fix is in the repository for the next release. If you would like, I can package you a pre-release xsde+dep source code from the repository. Boris From vladimir.zykov at doctormobile.us Wed Feb 12 10:29:06 2014 From: vladimir.zykov at doctormobile.us (Vladimir Zykov) Date: Wed Feb 12 10:45:24 2014 Subject: [xsde-users] bad_cast when generating from schemas having element and attribute with same name In-Reply-To: References: <83379D35-7C8F-4983-BDE8-FFF2007A2773@doctormofile.us> Message-ID: <11340EC4-39FE-4376-B61D-848A560EBE08@doctormofile.us> Please package the latest sources for me. I found web interface to your repositories at http://scm.codesynthesis.com/ but it's not absolutely obvious how to build it. It looks like you changed a lot since XSD/e 3.2.0. Thanks On Feb 12, 2014, at 4:38 PM, Boris Kolpackov wrote: > Hi Vladimir, > > Vladimir Zykov writes: > >> Where can we obtain the latest source code for XSD/e? We have >> xsde-3.2.0-1 and we thought this is the latest. > > XSD/e 3.2.0 is the latest released version of XSD/e. The fix is > in the repository for the next release. If you would like, I can > package you a pre-release xsde+dep source code from the repository. > > Boris Vladimir Zykov Software Engineer Doctor Mobile, LLC From boris at codesynthesis.com Thu Feb 13 22:57:38 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Feb 13 22:55:32 2014 Subject: [xsde-users] bad_cast when generating from schemas having element and attribute with same name In-Reply-To: <11340EC4-39FE-4376-B61D-848A560EBE08@doctormofile.us> References: <83379D35-7C8F-4983-BDE8-FFF2007A2773@doctormofile.us> <11340EC4-39FE-4376-B61D-848A560EBE08@doctormofile.us> Message-ID: Hi Vladimir, Vladimir Zykov writes: > Please package the latest sources for me. Ok, I will package one for you in the next couple of days. Boris From Jonathan.Haws at sdl.usu.edu Thu Feb 20 14:02:10 2014 From: Jonathan.Haws at sdl.usu.edu (Jonathan Haws) Date: Thu Feb 20 14:02:19 2014 Subject: [xsde-users] Stream oriented parsing Message-ID: I kind of asked this question a while ago, but was doing some more searching online and came across a feature of the XSD/e C++ parser - "perform stream-oriented processing". What exactly does that mean? Can I feed partial XML documents into the parser? What I have is the XML documents I am receiving are coming over TCP sockets, so I am not guaranteed that I will receive an entire document on a socket read. I was hoping I could use this stream-oriented feature to handle the TCP stream as its feed. Does that paradigm work? Thanks! Jonathan From boris at codesynthesis.com Fri Feb 21 01:15:32 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Feb 21 01:13:21 2014 Subject: [xsde-users] Stream oriented parsing In-Reply-To: References: Message-ID: Hi Jonathan, Jonathan Haws writes: > I kind of asked this question a while ago, but was doing some more > searching online and came across a feature of the XSD/e C++ parser > - "perform stream-oriented processing". What exactly does that mean? That means that you can start processing the data extracted from the document as it becomes available/being parsed. > What I have is the XML documents I am receiving are coming over TCP > sockets, so I am not guaranteed that I will receive an entire document > on a socket read. I was hoping I could use this stream-oriented feature > to handle the TCP stream as its feed. Does that paradigm work? Yes. Think of this functionality as having two levels: 1. The first level is where you can feed the parser the document in chunks (i.e., memory buffers) until everything is parsed (you still need to tell the parser where the document ends thought). After the last call to parse() you call post() and get the complete in-memory object model for the entire document (for C++/Hybrid). To implement this approach, check the overloaded parse() function that takes the memory buffer (the guide has an example that shows how to use it). 2. The second level is based on the first in that you can still feed the parser chunks of your document but now, instead of waiting for the entire object model being assembled, the parser feeds you chunks of the object model to process. This approach is shown in the 'streaming' example for C++/Hybrid. Boris