Project Home
Project Home
Source Code
Source Code
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
BroadcastCommunity.qnx.com will be offline from May 31 6:00pm until June 2 12:00AM for upcoming system upgrades. For more information please go to https://community.qnx.com/sf/discussion/do/listPosts/projects.bazaar/discussion.bazaar.topc28418
Forum Topic - Some compile errors moving from gcc 3.3.5 to 4.2.1: (4 Items)
   
Some compile errors moving from gcc 3.3.5 to 4.2.1  
I am trying out the ported gcc 4.2, and while compiling our project I noticed some issues which I believe are compiler-
related:

1. Trouble with copy constructors:

/usr/qnx630/host/qnx6/x86/usr/bin/QCC -Wp,-MD,x86/ServerSocket.dep -V4.2.1,gcc_ntox86 -I/trunk -g -Wno-uninitialized -o 
x86/ServerSocket.o -c ServerSocket.cpp
In file included from /usr/qnx630/target/qnx6/usr/include/cpp/xiosbase:7,
                 from /usr/qnx630/target/qnx6/usr/include/cpp/streambuf:7,
                 from /usr/qnx630/target/qnx6/usr/include/cpp/xlocnum:10,
                 from /usr/qnx630/target/qnx6/usr/include/cpp/ios:7,
                 from /usr/qnx630/target/qnx6/usr/include/cpp/ostream:7,
                 from /usr/qnx630/target/qnx6/usr/include/cpp/istream:7,
                 from /usr/qnx630/target/qnx6/usr/include/cpp/string:7,
                 from /usr/qnx630/target/qnx6/usr/include/boost/function/function_base.hpp:14,
                 from /usr/qnx630/target/qnx6/usr/include/boost/function/detail/prologue.hpp:16,
                 from /usr/qnx630/target/qnx6/usr/include/boost/function.hpp:22,
                 from ServerSocket.h:15,
                 from ServerSocket.cpp:15:
/usr/qnx630/target/qnx6/usr/include/yvals.h: In copy constructor 'std::_Locinfo::_Locinfo(const std::_Locinfo&)':
/usr/qnx630/target/qnx6/usr/include/yvals.h:301: error: 'std::_Lockit::_Lockit(const std::_Lockit&)' is private
/usr/qnx630/target/qnx6/usr/include/cpp/xlocinfo:49: error: within this context
/usr/qnx630/target/qnx6/usr/include/cpp/xlocale: In constructor 'std::codecvt<wchar_t, 
char, _Mbstatet>::codecvt(std::size_t)':
/usr/qnx630/target/qnx6/usr/include/cpp/xlocale:683: note: synthesized method 'std::_Locinfo::_Locinfo(const std::
_Locinfo&)' first required here 
cc: /usr/qnx630/host/qnx6/x86/usr/lib/gcc/i386-pc-nto-qnx6.3.0/4.2.1/cc1plus error 1

Class _Locinfo contains a _Lockit member, which has a private, undefined copy constructor, but _Locinfo does not. Then 
when the compiler tries to generate the copy constructor for _Locinfo, it fails. I'm not sure why the compiler is 
generating a copy constructor; perhaps that is the problem. The code in xlocale is similar to the following:

class codecvt
{
void _Init(const _Locinfo &)
{
}

codecvt()
{
  _Init(_Locinfo()); // copy constructor is generated due to this line (why?)
}
}

I solved this problem by altering _Locinfo to have a private copy constructor, and modifying the files that reference it
 so that the copy constructor is not called (changed _Init(_Locinfo()) to _Locinfo info; _Init(info);)

2. Problems linking:

/usr/qnx630/host/qnx6/x86/usr/bin/QCC -V4.2.1,gcc_ntox86 -o x86/select x86/select.o -Lx86 -Wl,-rpath,x86 -lsocket -
lcppunit
x86/select.o: In function `void boost::function1<void, ClientSocket*, std::allocator<void> >::assign_to<void (*
)(ClientSocket*)>(void (*)(ClientSocket*))':
/usr/qnx630/target/qnx6/usr/include/boost/function/function_template.hpp:645: undefined reference to `
__cxa_guard_acquire'
/usr/qnx630/target/qnx6/usr/include/boost/function/function_template.hpp:645: undefined reference to `
__cxa_guard_release'
cc: /usr/qnx630/host/qnx6/x86/usr/bin/ntox86-ld-2.17 error 1

You can see that the problem involves the Boost library. I am using the latest version of Boost (1.34.1). The problem 
seems to be due to a static variable declaration in a function. I solved this problem by adding -fno-threadsafe-statics 
to the compile flags.

3. Problems with exceptions:

Example code:
----- ex.cpp -----
#include <string>

class MyClass
{
public:
        MyClass(std::string in) {} // no error if the parameter is an int
};

class MyException
{
        MyException() {} // no error if there is no constructor defined
};

int main()
{
        try
        {
                MyClass test("asdf"); // no error if this line is commented out
        }
        catch(MyException e) // no error if the...
View Full Message
Re: Some compile errors moving from gcc 3.3.5 to 4.2.1  
Ken MacKay wrote:
> I am trying out the ported gcc 4.2, and while compiling our project I 
> noticed some issues which I believe are compiler-related:
> 
> 1. Trouble with copy constructors:
> /usr/qnx630/target/qnx6/usr/include/yvals.h: In copy constructor 
> 'std::_Locinfo::_Locinfo(const std::_Locinfo&)':
> /usr/qnx630/target/qnx6/usr/include/yvals.h:301: error: 
> 'std::_Lockit::_Lockit(const std::_Lockit&)' is private

Line 300 in yvals.h should be public and not private. This change has 
already been made on our lib/c/public/yvals.h

http://community.qnx.com/integration/viewcvs/viewcvs.cgi/*checkout*/trunk/lib/c/public/yvals.h?root=coreos_pub&rev=153052&system=exsy1001

> 2. Problems linking:

> /usr/qnx630/target/qnx6/usr/include/boost/function/function_template.hpp:645: 
> undefined reference to `__cxa_guard_acquire'
> 
> /usr/qnx630/target/qnx6/usr/include/boost/function/function_template.hpp:645: 
> undefined reference to `__cxa_guard_release'
> 
> cc: /usr/qnx630/host/qnx6/x86/usr/bin/ntox86-ld-2.17 error 1

> 3. Problems with exceptions:
> /trunk/DIOS/Testing/C++/test/ex.cpp:20: undefined reference to 
> `__cxa_get_exception_ptr'
> cc: /usr/qnx630/host/qnx6/x86/usr/bin/ntox86-ld-2.17 error 1
> 
> I solved this problem by catching the exception by reference.
> 
> Any ideas on better ways to solve these issues?

These two problems are a packaging error on my part. All of these 
symbols are defined in libsupc++. For the Dinkumware variants, we 
objcopy the support lib to be libcxa. It looks like the 3.3.5 libcxa 
made it into the 4.2.1 tarball. I'll repost fixed target balls tomorrow 
but in the meantime, you can run:

ntox86-objcopy-2.17 --weaken $QNX_TARGET/x86/lib/gcc/4.2.1/libsupc++.a 
$QNX_TARGET/x86/lib/gcc/4.2.1/libcxa.a

Thank you for the feedback! Please do not hesitate to let us know if you 
have any other problems or questions.

Regards,

Ryan Mansfield
Re: Some compile errors moving from gcc 3.3.5 to 4.2.1  
Thank you for the fast response; everything works now!

-Ken
Re: Some compile errors moving from gcc 3.3.5 to 4.2.1  
> Thank you for the fast response; everything works now!
> 
> -Ken

Now that reminds me of something I haven't seen since the old quics days.  Perhaps not quite true but I think I had some
 kind of flashback. ;=)

Rick..