Compilation Fails due to Linker Error

108 views
Skip to first unread message

rtjmay

unread,
Jan 29, 2014, 9:17:06 AM1/29/14
to ledge...@googlegroups.com
Hello,

I'm trying to build ledger 3 from git using a fresh checkout on Ubuntu 13.10. The compilation makes it about halfway along and then fails with the following linker error:

~/bin/ledger> ./acprep opt update --debug
acprep: INFO: Invoking primary phase: update
acprep: INFO: Executing phase: update
acprep: INFO: Executing phase: pull
acprep: DEBUG: Executing command: git pull
Already up-to-date.
acprep: INFO: Executing phase: submodule
acprep: DEBUG: Executing command: git submodule init
acprep: DEBUG: Executing command: git submodule update
acprep: INFO: Executing phase: make
acprep: DEBUG: Configure arguments => []
acprep: DEBUG: Makefile arguments => []
acprep: INFO: Executing phase: config
acprep: INFO: Executing phase: submodule
acprep: DEBUG: Executing command: git submodule init
acprep: DEBUG: Executing command: git submodule update
acprep: INFO: Executing phase: configure
acprep: DEBUG: Executing command: uname -s
acprep: INFO: System type is => Linux
acprep: INFO: Setting up build flavor => opt
acprep: DEBUG: configure does not need to be run
acprep: DEBUG: Changing directory to /home/ryan/bin/ledger
acprep: DEBUG: Executing command: make
[ 46%] Built target libledger
[ 48%] Built target ledger
Linking CXX shared library ../libpyledger.so
/usr/bin/ld: libledger.a(sha1.cpp.o): relocation R_X86_64_32S against `_ZTV4SHA1' can not be used when making a shared object; recompile with -fPIC
libledger.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [libpyledger.so] Error 1
make[1]: *** [src/CMakeFiles/pyledger.dir/all] Error 2
make: *** [all] Error 2
acprep: ERROR: Execution failed: make

Any suggestions on how to correct this? I've successfully built ledger 3 on this system in the past, but not for a few months.

Thanks,
Ryan

John Wiegley

unread,
Jan 29, 2014, 10:13:15 AM1/29/14
to ledge...@googlegroups.com
>>>>> rtjmay <ry...@rtjmay.ca> writes:

> I'm trying to build ledger 3 from git using a fresh checkout on Ubuntu 13.10.
> The compilation makes it about halfway along and then fails with the following
> linker error:

I assume you've tried completely nuking your build directory, or any past
build products (example: git clean -dfx)?

John

Ryan May

unread,
Jan 29, 2014, 10:49:35 AM1/29/14
to ledge...@googlegroups.com
After a `git clean -dfx` I still receive the same error.

-Ryan



--

---
You received this message because you are subscribed to a topic in the Google Groups "Ledger" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ledger-cli/70yM_r0xguY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ledger-cli+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Alexis

unread,
Jan 29, 2014, 11:03:32 AM1/29/14
to ledge...@googlegroups.com
Hi,
thanks for reporting the issue, it has also been
mentioned in https://github.com/ledger/ledger/pull/231.
I've worked a solution, with which I can compile
ledger 3.0 on Debian 7.2.

You can help verifying this potential fix by testing
the changes introduced in:
https://github.com/afh/ledger/commit/1b06465e3c9610650bf559e3ffd1df080fc3cd53


Cheers,
Alexis

Alexis

unread,
Jan 31, 2014, 5:51:41 PM1/31/14
to ledge...@googlegroups.com
Hi all,
there is a potential fix for this in pull request #232
https://github.com/ledger/ledger/pull/232.

If possible please help by checking whether these changes
fix the broken build.

Thanks to kain88-de (https://github.com/kain88-de) for
helping out to find the various oddities involved.

One thing we noticed is that
% ./acprep update -j$(nproc)

will fail to build where as
% ./acprep opt make -j$(nproc)
will succeed on Linux.

In order to prevent these types of severe errors I've
issued the pull request #233
https://github.com/ledger/ledger/pull/233
which adds continuous integration using Travis CI.

For a preview visit: https://travis-ci.org/afh/ledger


Best,
Alexis

Alexis

unread,
Feb 1, 2014, 3:54:52 PM2/1/14
to ledge...@googlegroups.com
Hi all,
the latest commits on the master branch address the build errors
and improve the python module support.

It was tested on Mac, Debian 8, and Ubuntu 12. Please test whether
the current repository state works for you and report any issues.

In order to quickly find severe issues as these Travis CI was
integrated, so that upon every commit ledger is build from scratch
and the tests are run.


Cheers,
Alexis

Ryan May

unread,
Feb 1, 2014, 4:37:42 PM2/1/14
to ledge...@googlegroups.com
I just did a clean build from master on Ubuntu 13.10 and the compilation now works.

-Ryan


Ryan May

unread,
Feb 1, 2014, 4:46:54 PM2/1/14
to ledge...@googlegroups.com
Well, I may have been a bit hasty. Compilation now works, but when I `make install` and attempt to run ledger I get the following error:

ledger: error while loading shared libraries: libledger.so.3: cannot open shared object file: No such file or directory

The output of `make install` is:

[ 88%] Built target libledger
[ 91%] Built target ledger
[ 98%] Built target MathTests
[100%] Built target UtilTests
Install the project...
-- Install configuration: "Release"
-- Up-to-date: /usr/local/lib/x86_64-linux-gnu/libledger.so.3
-- Up-to-date: /usr/local/lib/x86_64-linux-gnu/libledger.so
-- Up-to-date: /usr/local/include/ledger/account.h
-- Up-to-date: /usr/local/include/ledger/amount.h
-- Up-to-date: /usr/local/include/ledger/annotate.h
-- Up-to-date: /usr/local/include/ledger/archive.h
-- Up-to-date: /usr/local/include/ledger/balance.h
-- Up-to-date: /usr/local/include/ledger/chain.h
-- Up-to-date: /usr/local/include/ledger/commodity.h
-- Up-to-date: /usr/local/include/ledger/compare.h
-- Up-to-date: /usr/local/include/ledger/context.h
-- Up-to-date: /usr/local/include/ledger/convert.h
-- Up-to-date: /usr/local/include/ledger/csv.h
-- Up-to-date: /usr/local/include/ledger/draft.h
-- Up-to-date: /usr/local/include/ledger/emacs.h
-- Up-to-date: /usr/local/include/ledger/error.h
-- Up-to-date: /usr/local/include/ledger/expr.h
-- Up-to-date: /usr/local/include/ledger/exprbase.h
-- Up-to-date: /usr/local/include/ledger/filters.h
-- Up-to-date: /usr/local/include/ledger/flags.h
-- Up-to-date: /usr/local/include/ledger/format.h
-- Up-to-date: /usr/local/include/ledger/generate.h
-- Up-to-date: /usr/local/include/ledger/global.h
-- Up-to-date: /usr/local/include/ledger/history.h
-- Up-to-date: /usr/local/include/ledger/item.h
-- Up-to-date: /usr/local/include/ledger/iterators.h
-- Up-to-date: /usr/local/include/ledger/journal.h
-- Up-to-date: /usr/local/include/ledger/lookup.h
-- Up-to-date: /usr/local/include/ledger/mask.h
-- Up-to-date: /usr/local/include/ledger/op.h
-- Up-to-date: /usr/local/include/ledger/option.h
-- Up-to-date: /usr/local/include/ledger/org.h
-- Up-to-date: /usr/local/include/ledger/output.h
-- Up-to-date: /usr/local/include/ledger/parser.h
-- Up-to-date: /usr/local/include/ledger/pool.h
-- Up-to-date: /usr/local/include/ledger/post.h
-- Up-to-date: /usr/local/include/ledger/precmd.h
-- Up-to-date: /usr/local/include/ledger/predicate.h
-- Up-to-date: /usr/local/include/ledger/print.h
-- Up-to-date: /usr/local/include/ledger/pstream.h
-- Up-to-date: /usr/local/include/ledger/ptree.h
-- Up-to-date: /usr/local/include/ledger/pyfstream.h
-- Up-to-date: /usr/local/include/ledger/pyinterp.h
-- Up-to-date: /usr/local/include/ledger/pyutils.h
-- Up-to-date: /usr/local/include/ledger/query.h
-- Up-to-date: /usr/local/include/ledger/quotes.h
-- Up-to-date: /usr/local/include/ledger/report.h
-- Up-to-date: /usr/local/include/ledger/scope.h
-- Up-to-date: /usr/local/include/ledger/select.h
-- Up-to-date: /usr/local/include/ledger/session.h
-- Up-to-date: /usr/local/include/ledger/stats.h
-- Up-to-date: /usr/local/include/ledger/stream.h
-- Up-to-date: /usr/local/include/ledger/temps.h
-- Up-to-date: /usr/local/include/ledger/timelog.h
-- Up-to-date: /usr/local/include/ledger/times.h
-- Up-to-date: /usr/local/include/ledger/token.h
-- Up-to-date: /usr/local/include/ledger/unistring.h
-- Up-to-date: /usr/local/include/ledger/utils.h
-- Up-to-date: /usr/local/include/ledger/value.h
-- Up-to-date: /usr/local/include/ledger/views.h
-- Up-to-date: /usr/local/include/ledger/xact.h
-- Up-to-date: /usr/local/include/ledger/strptime.h
-- Up-to-date: /usr/local/include/ledger/system.hh
-- Up-to-date: /usr/local/include/ledger/sha1.h
-- Up-to-date: /usr/local/include/ledger/utf8.h
-- Installing: /usr/local/include/ledger/utf8
-- Up-to-date: /usr/local/include/ledger/utf8/checked.h
-- Up-to-date: /usr/local/include/ledger/utf8/core.h
-- Up-to-date: /usr/local/include/ledger/utf8/unchecked.h
-- Up-to-date: /usr/local/bin/ledger
-- Up-to-date: /usr/local/share/man/man1/ledger.1
-- Up-to-date: /usr/local/share/info/ledger3.texi
-- Up-to-date: /usr/local/share/info/ledger-mode.texi

Which indicates that the required file is being installed, but ledger can't find it.

Any suggestions?

-Ryan

Johann Klähn

unread,
Feb 1, 2014, 5:08:30 PM2/1/14
to ledge...@googlegroups.com
You can work around this by including /usr/local/lib/x86_64-linux-gnu
in a LD_LIBRARY_PATH environment variable or configuring the inclusion
of that directory via /etc/ld.so.conf or similar.
As a step to the correct fix of this problem:
Is the library simply installed into a wrong directory?
I.e. do other programs that use shared libraries installed in
/usr/local have an RPATH¹ set, or does it 'just work'?

1: Check via: readelf -d binary_name and report any lines mentioning RPATH.
This page may be relevant http://www.cmake.org/Wiki/CMake_RPATH_handling
> You received this message because you are subscribed to the Google Groups
> "Ledger" group.
> To unsubscribe from this group and stop receiving emails from it, send an

Ryan May

unread,
Feb 1, 2014, 7:22:41 PM2/1/14
to ledge...@googlegroups.com
Setting LD_LIBRARY_PATH does not fix the problem.

readelf shows that the ledger binary in the compilation directory does have an RPATH pointing to the compilation directory, but the installed binary does not have an RPATH. A quick look at other programs in /usr/local/bin shows that none of them have an RPATH either.

-Ryan

Alexis

unread,
Feb 2, 2014, 4:14:14 AM2/2/14
to ledge...@googlegroups.com
Hi Ryan,
I have just setup a Ubuntu 13.10 vagrant box and was able to
run ledger successfully using:
% LC_ALL=C LD_LIBRARY_PATH=/usr/local/lib/x86_64-linux-gnu ledger

I'll have a look about how the RPATH can be set correctly during
the build.


Interestingly the python demo runs just fine with:
% LC_ALL=c python ~/src/ledger/python/demo.py


For those who'd like help testing or improve the
cross-compile test setup, here's the Vagrantfile I use:
https://gist.github.com/afh/8765061


Cheers,
Alexis

Alexis

unread,
Feb 3, 2014, 6:19:31 AM2/3/14
to ledge...@googlegroups.com
Hello Ryan,
I have just issued another pull request
(https://github.com/ledger/ledger/pull/237)
that addresses this issue.

I have successfully compiled ledger on Linux
and was able to run it from anywhere in the filesystem.

The changes were tested on Debian 7, Debian 8,
Ubuntu Precise, Ubuntu Saucy, and OS X Mavericks.

Please give it a spin and let me know
whether this works for you.


Cheers,
Alexis

Ryan May

unread,
Feb 6, 2014, 4:34:04 PM2/6/14
to ledge...@googlegroups.com
A clean build after the merger of the patch now builds and installs correctly.

Thanks
Ryan




Cheers,
Alexis

Robert Eckl

unread,
Feb 4, 2014, 8:03:45 PM2/4/14
to ledge...@googlegroups.com
Thank you very much,
seems to work fine for me on Linux Mint (Debian).

Cu,
Robert
Reply all
Reply to author
Forward
0 new messages