From: Dan <drose@dtlm.homelinux.net>
To: gentoo-user@lists.gentoo.org
Subject: [gentoo-user] OT -- gcc .o linking and undefined references
Date: Sun, 23 Oct 2005 13:20:52 +1000 [thread overview]
Message-ID: <435B0194.4090509@dtlm.homelinux.net> (raw)
Hi everyone, I'm doing something really obviously wrong, but I don't
know what.
I can gcc -c -o file.o file.c and get a binary object.
I do this for the main and two "helper" .c files
This works, then I get a bunch of .o files.
then you usually do
gcc -o <final executable name> <main.o> <myfile1.o> <myfile2.o>
and gcc does the linking.
In thsi case, myfile2.c uses ldap_init and ldap_simple_bind, and
myfile2.h inludes ldap.h.
At this point, there is no ldap.o, just the ldap.h from
/usr/include/ldap.h so compile of everything stalls, saying that there
is an undefined reference to the function ldap_init and ldap_simple_bind.
Testing indicates that you can do:
int main() {
thingy_do(123);
}
and it will happily do a gcc -c -o main main.c and create the object,
which is what it should -- it's not until we link .o's to create a real
executable that the system wants to make sure the executable code exists.
The bit that makes me think I'm stupid is that it seems that neither gcc
or I can find the source (.c) or compiled binaries (.o) which implement
the structures and functions defined in ldap.h. What am I doing wrong?
Where are the .c and .o files supposed to be on a regular linux system?
Where on gentoo? Have I missed a crucial flag?
Thanks in advance...
--
gentoo-user@gentoo.org mailing list
next reply other threads:[~2005-10-24 10:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-23 3:20 Dan [this message]
2005-10-24 8:41 ` [gentoo-user] OT -- gcc .o linking and undefined references Christoph Gysin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=435B0194.4090509@dtlm.homelinux.net \
--to=drose@dtlm.homelinux.net \
--cc=gentoo-user@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox