From: "René Berber" <rene.berber@gmail.com>
To: cygwin@cygwin.com
Subject: Re: library compilation undefined reference to extern function
Date: Sun, 06 Mar 2016 23:27:00 -0000 [thread overview]
Message-ID: <nbied2$hns$1@ger.gmane.org> (raw)
In-Reply-To: <1129585202.10528386.1457303233509.JavaMail.zimbra@desy.de>
On 3/6/2016 4:27 PM, Azatyan, Anushavan wrote:
[snip]
> #include <iostream>
> using namespace std;
> extern void foo(void);
> int main()
> {
> cout<<" Print ";
> foo();
> return 0;
> }
>
> a very simple example I can compile in linux (Ubuntu) without any
problem, but in cygwin it goes with linker errors - undefined reference,
in both systems I use
>
> $ gcc -c -Wall -fpic filename.cc
> $ gcc -shared -o libfoo.so filename.o
Besides the obvious (dynamic libraries in Windows do not have a .so
extension, but a .dll ext.) the linker in Windows does not allow
undefined references, so your second command should look like:
$ gcc -shared -o libfoo.dll filename.o -lstdc++
filename.o:filename.cc:(.text+0x23): undefined reference to `foo()'
collect2: error: ld returned 1 exit status
obviously you still have an undefined foo(). You have to provide it,
wherever it may be.
--
René Berber
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
prev parent reply other threads:[~2016-03-06 23:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-06 22:27 Azatyan, Anushavan
2016-03-06 23:27 ` René Berber [this message]
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='nbied2$hns$1@ger.gmane.org' \
--to=rene.berber@gmail.com \
--cc=cygwin@cygwin.com \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).