Issue 124712

Summary: Build broken on Linux Ubuntu 14.04 (undefined reference to __cxa_atexit)
Product: General Reporter: Andrea Pescetti <pescetti>
Component: codeAssignee: AOO issues mailing list <issues>
Status: CLOSED FIXED QA Contact:
Severity: Normal    
Priority: P3 CC: hrin, klemen.zivkovic, lukebenes, os_ooo, samalipraveena
Version: 4.1.0-devFlags: pescetti: 4.1.2_release_blocker+
Target Milestone: ---   
Hardware: All   
OS: All   
Issue Type: PATCH Latest Confirmation in: ---
Developer Difficulty: ---
Description Flags
patch to fix this issue
[PATCH] issue 124712 none

Description Andrea Pescetti 2014-04-19 19:21:50 UTC
As discussed on the dev list, the build is broken on Ubuntu 14.04. This might well be an environment problem since a quick Internet search returns many hits.

Still, with the default Ubuntu tools, installed exactly as in
I get:

undefined reference to `__cxa_atexit'

Here's the context:

Building module svl
[ build DEP ] SRS:svl/res
[ build DEP ] LNK:Library/
[ build DEP ] LNK:Library/
[ info  ALL ] LinkTarget Library/ not defined: Assuming headers to be there!
[ info  ALL ] LinkTarget Library/ not defined: Assuming headers to be there!
[ build PKG ] svl_inc
[ build DEP ] LNK:Library/
[ build DEP ] SRS:svl/res
[ build SRS ] svl/res
[ build RES ] svlen-US
[ build CXX ] svl/source/fsstor/fsfactory
[ build CXX ] svl/source/fsstor/fsstorage
[ build CXX ] svl/source/fsstor/oinputstreamcontainer
[ build CXX ] svl/source/fsstor/ostreamcontainer
[ build LNK ] Library/
/usr/lib/x86_64-linux-gnu/libc_nonshared.a(atexit.oS): In function `atexit':
(.text+0x12): undefined reference to `__cxa_atexit'
collect2: error: ld returned 1 exit status
make: *** [/.../main/solver/410/] Error 1
dmake:  Error code 2, while making 'all'

1 module(s): 
need(s) to be rebuilt


ERROR: error 65280 occurred while making .../main/svl/prj

When you have fixed the errors in that module you can resume the build by running:

	build --all:svl
Comment 1 zhivko 2014-07-02 09:44:25 UTC
Is there workaround for this?
Comment 2 zhivko 2014-07-02 09:45:50 UTC
I am also on 14.04 and I am getting:

Building module sdext

Entering .../apacheopenoffice/AOO410/main/sdext/inc

Entering .../apacheopenoffice/AOO410/main/sdext/source/minimizer

Making:    minimizer.srs
/bin/bash: /home/klemen/apacheopenoffice/AOO410/main/solver/411/ No such file or directory
dmake:  Error code 127, while making '../../'

1 module(s): 
need(s) to be rebuilt


ERROR: error 65280 occurred while making .../apacheopenoffice/AOO410/main/sdext/source/minimizer

When you have fixed the errors in that module you can resume the build by running:

	build --all:sdext
Comment 3 Andrea Pescetti 2014-07-02 16:09:15 UTC
@zhivko: your problem is different from the one described in this issue.

Please write an e-mail to the dev mailing list
and provide: error message (as below), the options you give to ./configure and the URL you used to get the sources (run "svn info" if you used an SVN checkout, or give the URL if you downloaded a source package). Then we will verify it and we'll discuss opening a separate issue for your problem.
Comment 4 samalipraveena 2014-07-22 01:48:30 UTC
Hi ,
I downloaded the source and did a build and am getting exactly the same build error. Is there any other way to obtain a build? I don't know what to do after this. I'm a new volunteer. I thought of starting to have a look at the source. Just a question : How do milestone builds happen? Doesn't this error a problem for them?
Comment 5 Andrea Pescetti 2014-07-22 06:43:15 UTC
Our dev builds are done using older Linux systems, like Ubuntu 12.04; the build succeeds with no problem in that case. Also, other distributions (like Fedora) don't show the problem in their current version (Fedora 20).

If you have time to look around and see how to fix the issue (there are several similar reports if you do an Internet search, but nothing that I found was immediately helpful) we can surely work together in implementing a workaround/solution.
Comment 6 samalipraveena 2014-07-29 04:07:35 UTC
Hi Andrea,
I'm still trying to find the source of this bug in Ubuntu Linux 14.04;
couldn't find anything yet even after searching a lot about this from the Internet.
GLIBC library version in my system Ubuntu 14.04: 2.2.5
GLIBCXX Library version in my system Ubuntu 14.04: 3.4
g++, gcc version in my system : 4.8.2
I tried to downgrade g++ to 4.6, which didn't work.
Can you let me know glibc and glibcxx versions in the build machine- ubuntu 12.04, where it links successfully.
I created a hello,world cpp file, and then g++ test.cpp -o test
objdump -T test - this will give you a set of undefined symbols and glibc,glibcxx versions.
Please let me know the output of this nm command as well:
nm -o /usr/lib/x86_64-linux-gnu/libc_nonshared.a | grep " U "
Comment 7 samalipraveena 2014-07-29 04:47:52 UTC
Hi Andrea,
can you let me know g++ version as well, please?
Comment 8 Andrea Pescetti 2014-07-29 21:58:21 UTC
I don't have access to the buildbot. But the setup is standard, or at least we are able to build on a standard 12.04 LTS with the package versions as listed in

I don't currently have access to any Ubuntu machines, but a standard virtual machine based on Ubuntu 12.04 should be easy to setup if you already have experience with that. Otherwise I can test it on Ubuntu machines but it will take several days before I have one available. I'll keep you posted here.

This is the nm test made on another machine (a Fedora 20 machine where I build OpenOffice regularly without problems), in case it helps. I adapted the lib path.

$ nm -o /usr/lib64/libc_nonshared.a | grep " U "
/usr/lib64/libc_nonshared.a:elf-init.oS:                 U _GLOBAL_OFFSET_TABLE_
/usr/lib64/libc_nonshared.a:elf-init.oS:                 U _init
/usr/lib64/libc_nonshared.a:elf-init.oS:                 U __init_array_end
/usr/lib64/libc_nonshared.a:elf-init.oS:                 U __init_array_start
/usr/lib64/libc_nonshared.a:atexit.oS:                 U __cxa_atexit
/usr/lib64/libc_nonshared.a:atexit.oS:                 U _GLOBAL_OFFSET_TABLE_
/usr/lib64/libc_nonshared.a:at_quick_exit.oS:                 U __cxa_at_quick_exit
/usr/lib64/libc_nonshared.a:at_quick_exit.oS:                 U _GLOBAL_OFFSET_TABLE_
/usr/lib64/libc_nonshared.a:stat.oS:                 U _GLOBAL_OFFSET_TABLE_
/usr/lib64/libc_nonshared.a:stat.oS:                 U __xstat
/usr/lib64/libc_nonshared.a:fstat.oS:                 U __fxstat
/usr/lib64/libc_nonshared.a:fstat.oS:                 U _GLOBAL_OFFSET_TABLE_
/usr/lib64/libc_nonshared.a:lstat.oS:                 U _GLOBAL_OFFSET_TABLE_
/usr/lib64/libc_nonshared.a:lstat.oS:                 U __lxstat
/usr/lib64/libc_nonshared.a:stat64.oS:                 U _GLOBAL_OFFSET_TABLE_
/usr/lib64/libc_nonshared.a:stat64.oS:                 U __xstat64
/usr/lib64/libc_nonshared.a:fstat64.oS:                 U __fxstat64
/usr/lib64/libc_nonshared.a:fstat64.oS:                 U _GLOBAL_OFFSET_TABLE_
/usr/lib64/libc_nonshared.a:lstat64.oS:                 U _GLOBAL_OFFSET_TABLE_
/usr/lib64/libc_nonshared.a:lstat64.oS:                 U __lxstat64
/usr/lib64/libc_nonshared.a:fstatat.oS:                 U __fxstatat
/usr/lib64/libc_nonshared.a:fstatat.oS:                 U _GLOBAL_OFFSET_TABLE_
/usr/lib64/libc_nonshared.a:fstatat64.oS:                 U __fxstatat64
/usr/lib64/libc_nonshared.a:fstatat64.oS:                 U _GLOBAL_OFFSET_TABLE_
/usr/lib64/libc_nonshared.a:mknod.oS:                 U _GLOBAL_OFFSET_TABLE_
/usr/lib64/libc_nonshared.a:mknod.oS:                 U __xmknod
/usr/lib64/libc_nonshared.a:mknodat.oS:                 U _GLOBAL_OFFSET_TABLE_
/usr/lib64/libc_nonshared.a:mknodat.oS:                 U __xmknodat
/usr/lib64/libc_nonshared.a:stack_chk_fail_local.oS:                 U _GLOBAL_OFFSET_TABLE_
/usr/lib64/libc_nonshared.a:stack_chk_fail_local.oS:                 U __stack_chk_fail
Comment 9 samalipraveena 2014-07-30 01:41:06 UTC
Hi Andrea,
Thanks for the link. I could find the glibc, glibc++, and g++ versions.

I myself have a Ubuntu 12.04 in my virtual box, but since I installed it very recently, the glibc and glibc++ are the most recent versions in 12.04 as well.

I searched for the symbol __cxa_atexit in my system; the undefined reference __cxa_atexit is actually defined in libc.a; the problem is link order. libc_nonshared.a is dependent on libc.a for the symbol, but libc.a gets linked first. Though these two static libraries are grouped together using special group options, the linker is not able to find the symbol.
I'm trying with different options like -lc, -Wl,--undefined=__cxa_atexit; however, none of them has worked so far.
Comment 10 samalipraveena 2014-08-22 05:29:01 UTC
The solution for this build error is:
GLIBC2.2.5 has the function __cxa_atexit actually defined in libc.a and it is called from libc_nonshared.a __atexit function.
g++4.8 or g++4.9 don't have the compiler option -fuse-cxa-atexit by default. So we have to add it.
Go into the file ./solenv/gbuild/platform/, and add -fuse-cxa-atexit to gb_CXXFLAGS. 
gb_CXXFLAGS := \
        -Wall \
        -Wendif-labels \
        -Wextra \
        -Wno-ctor-dtor-privacy \
        -Wno-non-virtual-dtor \
        -Wshadow \
        -fPIC \
        -fmessage-length=0 \
        -fno-common \
        -fno-strict-aliasing \
        -fuse-cxa-atexit \
Now g++ will use this symbol defined in libc.a.
Comment 11 samalipraveena 2014-08-22 05:38:19 UTC
I suppose maybe i can make this change permanently in ./solenv/gbuild/platform/ file and upload to svn, because i think this change will be required for any GLIBC versions > 2.2.5 and unless g++ has -fuse_cxa_atexit by default.
Comment 12 samalipraveena 2014-08-22 21:46:07 UTC
Created attachment 83876 [details]
patch to fix this issue

This patch adds option -fuse-cxa-atexit to gb_CXXFLAGS in file.
Comment 13 slacka 2014-08-22 22:18:48 UTC
Thanks to samalipraveena, I was able to successfully build AOO. In ./solenv/gbuild/platform/, I had to replace
 -fnouse-cxa-atexit \
 -fuse-cxa-atexit \
$ cd svl/
$ make clean
$ cd ../instsetoo_native
$ build --from svl

Can you please upload your patch to the svn, so that everyone with newer systems can benefit from this fix?
Comment 14 samalipraveena 2014-08-22 23:58:57 UTC
Created attachment 83878 [details]
[PATCH] issue 124712

Modified the option -fno-use-cxa-atexit to -fuse-cxa-atexit.
Comment 15 samalipraveena 2014-08-23 00:01:29 UTC
I'm sorry, initially, i didn't know how to generate a patch. After reading, i came to know the commands. So i generated the patch accordingly and have attached it.
Comment 16 slacka 2014-08-23 00:49:52 UTC
Thanks for fixing this issue. Attaching a patch to a bug report, doesn't actually fix the issue for everyone else. Do you have commit access to the main trunk? If not, could you set this bug report back to CONFIRMED until this patch is merged into the codebase.
Comment 17 samalipraveena 2014-08-23 03:10:46 UTC
Actually, i was searching for ways to update this code into svn because this is the first patch i've made. I don't think i'll have commit access; and i've not tried before because this is the first patch. I wrongly attached the file before, so to correct it, i generated the patch and attached it correctly after that.
Comment 18 samalipraveena 2014-08-23 05:15:11 UTC
I tried to commit my changes to svn, but i don't have access to; my commit failed.
svn commit ./solenv/gbuild/platform/

Log message unchanged or not specified
(a)bort, (c)ontinue, (e)dit:
Authentication realm: <> ASF Committers
Password for 'amali': ********

Authentication realm: <> ASF Committers
Username: amali
Password for 'amali': ********

Authentication realm: <> ASF Committers
Username: ^Csvn: E200015: Commit failed (details follow):
svn: E200015: The operation was interrupted
svn: E200015: Your commit message was left in a temporary file:
svn: E200015:    '/media/amali/source/aoo-trunk/main/solenv/gbuild/platform/svn-commit.2.tmp'
but i couldn't change the status back to confirmed, as Luke says.
Comment 19 Andrea Pescetti 2014-08-23 06:46:50 UTC
Thanks for the patch! I'll test this as soon as I can build on an Ubuntu 14.04 machine and commit it for you, with attribution to you.

Changing the issue status is not strictly needed. It's better (more visible) to change the "Issue Type" to PATCH, which is what I'm doing now. has the full details, but in case you have doubts just send a mail to the dev list.
Comment 20 Michal Hriƈ 2014-08-24 17:34:15 UTC
I tested patch, and build passed with parameters --with-dmake-url= --with-epm-url= --disable-odk --without-junit --without-stlport --with-lang="sk".

I tried to build with parametres --with-dmake-url= --with-epm-url= --disable-odk --enable-category-b --enable-bundled-dictionaries --without-junit --without-stlport --with-system-stdlibs --with-lang="sk" and there were problems in some modules. Maybe patch breaks building of external packages, please look at it.
Comment 21 samalipraveena 2014-08-24 20:14:30 UTC
Hi Michael,
This patch is to fix only the error in this issue. I don't know what errors you get when you add additional options in configure. Are they related to this error, or different which need separate fixes? Are you doing the build in Ubuntu Linux 14.04? However, I'll do the build with these parameters --with-dmake-url= --with-epm-url= --disable-odk --enable-category-b --enable-bundled-dictionaries --without-junit --without-stlport --with-system-stdlibs --with-lang="sk" in my system and find out.
Comment 22 Andrea Pescetti 2014-08-24 20:42:19 UTC
Standard build with reelase options on Linux (Fedora 19) passed with patch applied.

Build of SVX passed on Ubuntu 14.04 with patch applied.

I'm about to commit the patch after a couple additional tests, commit will be automatically be notified to this issue page.

Keep an eye on our buildbots: to spot possible side effects.
Comment 23 Andrea Pescetti 2014-08-24 21:12:20 UTC
(In reply to Andrea Pescetti from comment #22)
> Build of SVX passed on Ubuntu 14.04 with patch applied.

I meant: Build of svl passed on Ubuntu 14.04 with patch applied and the "minimal" configuration options (basically, the ones in Michal's successful build above).
Comment 24 Andrea Pescetti 2014-08-25 07:01:10 UTC
For the record: the automated notification did not arrive yet, but this was committed in

Any other build problems on 14.04 should be reported in other issues.
Comment 25 samalipraveena 2014-08-26 02:00:19 UTC
Hi Michal,
I did a build with the following parameters, except for one small change --with-lang="en",in my Ubuntu Linux 14.04, g++=4.8 and the build was successful.

 --with-dmake-url= --with-epm-url= --disable-odk --enable-category-b --enable-bundled-dictionaries --without-junit --without-stlport --with-system-stdlibs --with-lang="sk"

If there are any other errors related to this issue, report it here. I'll look into it and fix it.
If there are errors unrelated to this issue, as andrea said, report them separately.

Thanks for committing the fix.
Comment 26 SVN Robot 2014-10-07 09:47:03 UTC
"pescetti" committed SVN revision 1620195 into trunk:
#i124712# Use -fuse-cxa-atexit (to build svl on, e.g., Ubuntu 14.04)
Comment 27 Andrea Pescetti 2015-09-30 08:43:56 UTC
As discussed: this is needed for a clean build on Ubuntu 14.04.
Comment 28 Andrea Pescetti 2015-10-07 21:39:58 UTC
Now committed to AOO410 for OpenOffice 4.1.2.
Comment 29 Andrea Pescetti 2015-10-17 22:09:38 UTC
This should be verified by simply trying to build on Ubuntu 14.04; if anyone has an Ubuntu 14.04 machine available, it is enough to build this tree:
and check that the build succeeds.
Comment 30 Andrea Pescetti 2015-10-18 23:32:45 UTC
Build is successful on Ubuntu 14.04 (64 bit), closing directly since this doesn't need manual verification.