public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: "C.J. Wagenius" <cjw@voidptr.se>
To: <cygwin@cygwin.com>
Subject: undefined reference when linking against glib-2.0
Date: Sun, 10 Feb 2019 10:28:00 -0000	[thread overview]
Message-ID: <LYLwuaD--3-1@voidptr.se> (raw)


 Hi.

 I'm trying to compile the following source file
---
#include <glib.h>
#include <stdio.h>

int main(int argc, char **argv)
{
  int *a;

  a = g_new(int, 1);
  g_free(a);

return 0;
}
---
... and get linking errors.

$ gcc -Wl,--verbose -o testa `pkg-config --cflags --libs glib-2.0` test.c
/tmp/ccHtEBvg.o:test.c:(.text+0x1e): undefined reference to `g_malloc_n'
/tmp/ccHtEBvg.o:test.c:(.text+0x2e): undefined reference to `g_free'
collect2: error: ld returned 1 exit status

(attempt to open /usr/lib/gcc/i686-pc-cygwin/7.4.0/../../../libglib-2.0.dll.a succeeded)

Windows 7 64-bit using 32-bin Cygwin. glib-2.0 (2.54.3-1) libraries and devel packages are installed.

What am I missing?

I've tried with 64-bin Cygwin too.

$ gcc -Wl,--verbose -o testa `pkg-config --cflags --libs glib-2.0` test.c
/tmp/ccyW0KzO.o:test.c:(.text+0x1f): undefined reference to `g_malloc_n'
/tmp/ccyW0KzO.o:test.c:(.text+0x1f): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `g_malloc_n'
/tmp/ccyW0KzO.o:test.c:(.text+0x2f): undefined reference to `g_free'
/tmp/ccyW0KzO.o:test.c:(.text+0x2f): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `g_free'

$  gcc -Wl,--verbose -o testa `pkg-config --cflags --libs glib-2.0` -m32 test.c In file included from /usr/lib/glib-2.0/include/glibconfig.h:9:0,
                 from /usr/include/glib-2.0/glib/gtypes.h:32,
                 from /usr/include/glib-2.0/glib/galloca.h:32,
                 from /usr/include/glib-2.0/glib.h:30,
                 from test.c:2:
/usr/include/glib-2.0/glib/gtypes.h: In function '_GLIB_CHECKED_ADD_U64':
/usr/include/glib-2.0/glib/gmacros.h:232:53: error: size of array '_GStaticAssertCompileTimeAssertion_0' is negative
#define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
                                                     ^
/usr/include/glib-2.0/glib/gmacros.h:229:47: note: in definition of macro 'G_PASTE_ARGS'
#define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2
                                               ^~~~~~~~~~~
/usr/include/glib-2.0/glib/gmacros.h:232:44: note: in expansion of macro 'G_PASTE'
#define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
                                            ^~~~~~~
/usr/include/glib-2.0/glib/gtypes.h:423:3: note: in expansion of macro 'G_STATIC_ASSERT'
   G_STATIC_ASSERT(sizeof (unsigned long long) == sizeof (guint64));
   ^~~~~~~~~~~~~~~

I'm obviously doing something wrong. Thanks for help.

/cjw

--
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

             reply	other threads:[~2019-02-10 10:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-10 10:28 C.J. Wagenius [this message]
2019-02-10 22:17 ` René Berber

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=LYLwuaD--3-1@voidptr.se \
    --to=cjw@voidptr.se \
    --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).