undefined reference when linking against glib-2.0
C.J. Wagenius
cjw@voidptr.se
Sun Feb 10 10:28:00 GMT 2019
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
More information about the Cygwin
mailing list