Building from source for ubuntu

Marco Leise Marco.Leise at gmx.de
Sun Jul 7 05:45:56 PDT 2013


Am Sun, 07 Jul 2013 12:25:50 +0200
schrieb "monarch_dodra" <monarchdodra at gmail.com>:

> I'm hitting a wall at building phobos, because of curl:
> make -f posix.mak DMD=../dmd/src/dmd
> /usr/bin/ld: cannot find -lcurl
> 
> I've isntalled curl via apt-get ("sudo apt-get curl"), and it 
> seems to be installed. Just not in ld:
> which curl
> /usr/bin/curl
> cd /usr/bin/ld
> bash: cd: /usr/bin/ld: Not a directory

Hehe, /usr/bin/ld is the linker. It said that it cannot find
the curl library. E.g. when you say -lcurl, it is prefixed
with "lib" and followed by ".so" and looked up in your
system's library directory which would be usr/lib/.
Now 64-bit made it more complicated. You basically have 2
systems installed. A 32-bit one and a 64-bit one, which cannot
share any libraries of course, since 32-bit code isn't
compatible with 64-bit code.
You will thus find /usr/lib64/ (for which /usr/lib/ is an
alternative name) and /usr/lib32/.

When I type: ls /usr/lib{32,64}/libcurl.so*
I see that I have curl as 32-bit in version 4.2.0 and as
64-bit in version 4.3.0:

/usr/lib32/libcurl.so
/usr/lib32/libcurl.so.4
/usr/lib32/libcurl.so.4.2.0
/usr/lib64/libcurl.so
/usr/lib64/libcurl.so.4
/usr/lib64/libcurl.so.4.3.0

Not that the full version is the corresponding actual file,
while the others are links to it. These "so-names" are used to
link against the library in general, a specific major or even
minor version.

If you do NOT have a 32-bit installation of curl in /usr/lib32
AND compile Phobos in 32-bit, it will fail.

Ok, now you know that "ld" is the linker program and not a
directory. "which" is on the other hand a tool that looks up
the location of a program as it would be found by just typing
its name on the command-line. It doesn't list libraries, just
executables in the directories given in the $PATH environment
variable. You can quickly take a look at it by typing

echo $PATH

The curl library actually comes with a program
(/usr/bin/curl) that is both a nice demo of what the library
can do and useful to download stuff from the command line or
in a shell script.
You may have noticed that all executables are in some */bin/
and all libraries in some */lib/ directory. You can rely on
that convention.
The split between /bin, /lib and /usr/bin, /usr/lib comes from
a time when fast storage was expensive and very limited in
capacity. The fast medium was mounted in the root "/" directory
with only the most commonly used programs and libraries in /bin
and /lib (that you can still find there today) and a magnetic
tape was mounted into /usr which had abundant storage capacity
but terrible seek times.

I hope that made Linux a bit less mysterious.

-- 
Marco



More information about the Digitalmars-d-learn mailing list