[IPOL discuss] small compilation error in LSD code (ubuntu 11.10)
Nicolas Limare
nicolas.limare at cmla.ens-cachan.fr
Wed Nov 16 12:08:50 CET 2011
Hi,
> What is the recommended procedure to report a bug? Shall
> it be sent directly to the authors, to discuss, or to the tech list?
I would say to the authors. Anyway, not to the tech list, tech at ipol is
only for the tech management of IPOL (web, demo, servers, ...) not of
the code published in demo articles.
> One of my students found that lsd-1.5 source code does not compile in
> ubuntu 11.10 with the provided makefile. I verified that behaviour
> (gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)).
> When trying to compile, it gives a lot of undefined references to
> math functions due to the order that -lm is specified. The simple way
> to make it compile is to place the -lm at the end of the compilation
> line. However, I think the problem is related to passing from a .c
> source file directly to the executable (compiling and linking in one
> step). I'm not sure about the explanation, but I think this is not a
> good idea, at least in my experience each time I do that I end up with
> problems with the ordering of libraries. Can someone explain what is
> going on?
Yes. gcc now calls the linker with the --as-needed option. Details
here:
- https://wiki.ubuntu.com/NattyNarwhal/ToolchainTransition
- http://wiki.debian.org/ToolChain/DSOLinking
In brief, this Ubuntu modification implements a more strict and
correct behaviour of the linker. This behaviour will probably also be
adopted in Debian. When the compiler is called with source files,
object files and libraries in the command-line, such as
cc file1.c file2.c file3.o file4.o -llib5 -llib6 -llib7
then every external symbol (function or global variable) need by any
of these items will be resolved by items positioned _later_ on the
command-line. Or, said in another way, when the compilation command
specifies a library, it will only be used to resolved symbols needed
by items positioned before this library in the command-line.
Conclusion: -lm must always be after the source, objects or other
libraries using math functions. Same rule for any other library.
> On the other hand, in mac osx lion with gcc and clang works fine:
> *Apple clang version 3.0 (tags/Apple/clang-211.10.1) (based on LLVM 3.0svn)
> *gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build
> 2336.1.00)
Other compiler, more relaxed rules. I think the new Ubuntu/Debian
rules are correct, even if annoying.
> A small suggestion: for other compiler users (not gcc), I could be
> nice to have a CC variable defined in the makefile, to allow changing
> the compiler easily.
This is a requirement of the (future) policy.
--
Nicolas LIMARE - CMLA - ENS Cachan http://www.cmla.ens-cachan.fr/~limare/
IPOL - image processing on line http://www.ipol.im/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://tools.ipol.im/mailman/archive/discuss/attachments/20111116/f3a82ced/attachment.pgp>
More information about the discuss
mailing list