Re: gdk-pixbuf and g++ linking problem



Thanks Harring.

I've reduced the problem down to its component parts in a small test suite (see attached files).

MyMain_c.c: shows the functions successfully linked in C.
MyMain_C1.C: shows the xlib function not linking properly in C++
MyMain_C2.C: shows the problem fixed using your extern "C" declaration
MyMain_C3.C: shows the problem fixed using a revised gdk-pixbuf-xlib.h header file, hacked with a similar extern "C" declaration

I hope this helps and I'd be grateful if you could circulate your .h file patches when you've made them, so I don't have to wait for a new .deb to come out.

Struan

Harring Figueiredo wrote:

Struan,
This could be caused by the fact that the __cplusplus guard is not in the
header file ./gdk-pixbuf-xlib.h, and the c++ compiler is mangling the fuction
name.

try adding this to the top of the fule

#ifdef __cplusplus
extern "C"
#endif



at this to the end of the file - then recompile it.

#ifdef __cplusplus
}
#endif.


If it fix, file a bug or tell me so I can file the bug.

thanks,

Harring.



--- Struan Bartlett <struan kula newsnow net> wrote:
Hi,

Thanks for checking this point.

But I have lines in my Makefile like this:

GFLAGS := $(shell gdk-pixbuf-config --cflags)
GLIBS := $(shell gdk-pixbuf-config --libs)

It produces a result like this:

gcc -o wm2 Border.o Buttons.o Client.o Events.o Main.o Manager.o Rotated.o
-L/usr/X11R6/lib -lXext -lX11 -lXt -lXmu -lSM -lICE -lm -L/usr/lib
-lgdk_pixbuf -L/usr/lib -L/usr/X11R6/lib -lgtk -lgdk -rdynamic -lgmodule
-lglib -ldl -lXi -lXext -lX11 -lm
Border.o: In function `Border::drawLabel(void)':
Border.o(.text+0x661): undefined reference to `background'
Border.o(.text+0x666): undefined reference to
`gdk_pixbuf_xlib_render_to_drawable(_GdkPixbuf *, unsigned long, _XGC *,
int, int, int, int, int, int, XlibRgbDither, int, int)'
collect2: ld returned 1 exit status

As I said, I have taken these Makefile lines right out of another C
program that calls the same gdk_pixbuf_xlib_render_to_drawable function.

Struan

On Fri, 3 Oct 2003, Harring Figueiredo wrote:

You are probably not passing the libs to the linker.

Are you using pkg-config to supply the cflags and libs to the
compiler/linker
?

Harring.

--- Struan Bartlett <struan praguespringpeople org> wrote:
I'm trying to write a pure X application in C++ that uses the gdk-pixbuf
image composition and scaling routines.

I'm using compiler/linker flags and library arguments that are known to
work with a C program functionally similar to my C++ program.

But when compiling my C++ program, the linker says:

Border.o(.text+0x666): undefined reference to
`gdk_pixbuf_xlib_render_to_drawable(_GdkPixbuf *, unsigned long, _XGC *,
int, int, int, int, int, int, XlibRgbDither, int, int)'

Please can you explain what I need to do to fix this?

Struan Bartlett.

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com



=====
==================================================================
Plese, don't send me any attachment in Micro$oft (.DOC, .PPT) format.
Read http://www.fsf.org/philosophy/no-word-attachments.html
Preferable attachments: .PDF, .HTML, .TXT
Please, consider adding this text to Your email signature.

Harring Figueiredo

__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

--
In 1946, the Nuremberg Tribunal judged that "To initiate war of
aggression is not only an international crime; it is the supreme
international crime differing only from other war crimes in that it
contains within itself the accumulated evil of the whole."

/* GdkPixbuf library - Xlib header file
 *
 * Authors: John Harper <john dcs warwick ac uk>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#ifndef GDK_PIXBUF_XLIB_H
#define GDK_PIXBUF_XLIB_H

#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk-pixbuf/gdk-pixbuf-xlibrgb.h>
#include <X11/Xlib.h>



#ifdef __cplusplus
extern "C" {
#endif
/* init */

void gdk_pixbuf_xlib_init (Display *display, int screen_num);

void gdk_pixbuf_xlib_init_with_depth (Display *display, int screen_num,
                                      int prefDepth);



/* render */

void gdk_pixbuf_xlib_render_threshold_alpha (GdkPixbuf *pixbuf, Pixmap bitmap,
                                             int src_x, int src_y,
                                             int dest_x, int dest_y,
                                             int width, int height,
                                             int alpha_threshold);

void gdk_pixbuf_xlib_render_to_drawable (GdkPixbuf *pixbuf,
                                         Drawable drawable, GC gc,
                                         int src_x, int src_y,
                                         int dest_x, int dest_y,
                                         int width, int height,
                                         XlibRgbDither dither,
                                         int x_dither, int y_dither);


void gdk_pixbuf_xlib_render_to_drawable_alpha (GdkPixbuf *pixbuf,
                                               Drawable drawable,
                                               int src_x, int src_y,
                                               int dest_x, int dest_y,
                                               int width, int height,
                                               GdkPixbufAlphaMode alpha_mode,
                                               int alpha_threshold,
                                               XlibRgbDither dither,
                                               int x_dither, int y_dither);

void gdk_pixbuf_xlib_render_pixmap_and_mask (GdkPixbuf *pixbuf,
                                             Pixmap *pixmap_return,
                                             Pixmap *mask_return,
                                             int alpha_threshold);



/* drawable */

GdkPixbuf *gdk_pixbuf_xlib_get_from_drawable (GdkPixbuf *dest,
                                              Drawable src,
                                              Colormap cmap, Visual *visual,
                                              int src_x, int src_y,
                                              int dest_x, int dest_y,
                                              int width, int height);

#ifdef __cplusplus
}
#endif

#endif /* GDK_PIXBUF_XLIB_H */
CFLAGS = -g -O2 -Wall -DVERSION='"$(VERSION)"' -I/usr/X11R6/include
GFLAGS := $(shell gdk-pixbuf-config --cflags)

XLIBS := $(shell gdk-pixbuf-config --libs) -lgdk_pixbuf_xlib
LIBS    =  -L/usr/X11R6/lib -lXext -lX11 -lXt -lXmu -lSM -lICE -lm

CFLAGS  = -O2 -I/usr/X11R6/include $(GFLAGS)
CCC     = gcc

MY_c = MyMain_c.o
MY_C1 = MyMain_C1.o
MY_C2 = MyMain_C2.o
MY_C3 = MyMain_C3.o

.c.o:
        $(CC) -c $(CFLAGS) $<

.C.o:
        $(CCC) -c $(CFLAGS) $<

my_c:   $(MY_c)
        rm -f my_c >& /dev/null || true
        $(CCC) -o my_c $(MY_c) $(LIBS) $(XLIBS)

my_C1:  $(MY_C1)
        rm -f my_C1 >& /dev/null || true
        $(CCC) -o my_C1 $(MY_C1) $(LIBS) $(XLIBS)

my_C2:  $(MY_C2)
        rm -f my_C2 >& /dev/null || true
        $(CCC) -o my_C2 $(MY_C2) $(LIBS) $(XLIBS)

my_C3:  $(MY_C3)
        rm -f my_C3 >& /dev/null || true
        $(CCC) -o my_C3 $(MY_C3) $(LIBS) $(XLIBS)
#include <stdio.h>
#include <signal.h>
#include <errno.h>
#include <stdlib.h>

#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xos.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>

#include <X11/extensions/shape.h>

#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk-pixbuf/gdk-pixbuf-xlib.h>

static Display *m_display;
static GdkPixbuf *background;

#define BACKGROUND_NAME "background.jpg"
  
int main(int argc, char **argv)
{
    gdk_pixbuf_xlib_init (m_display, 1);
    background = gdk_pixbuf_new_from_file (BACKGROUND_NAME);
    return 0;
}
#include <stdio.h>
#include <signal.h>
#include <errno.h>
#include <stdlib.h>

#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xos.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>

#include <X11/extensions/shape.h>

extern "C" 
{

#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk-pixbuf/gdk-pixbuf-xlib.h>

static Display *m_display;
static GdkPixbuf *background;

#define BACKGROUND_NAME "background.jpg"
  
int main2(int argc, char **argv)
{
    gdk_pixbuf_xlib_init (m_display, 1);
    background = gdk_pixbuf_new_from_file (BACKGROUND_NAME);
    return 0;
}

}

int main(int argc, char **argv) 
{
   main2(argc, argv);
}

#include <stdio.h>
#include <signal.h>
#include <errno.h>
#include <stdlib.h>

#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xos.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>

#include <X11/extensions/shape.h>

#include <gdk-pixbuf/gdk-pixbuf.h>
#include "gdk-pixbuf-xlib.h"

static Display *m_display;
static GdkPixbuf *background;

#define BACKGROUND_NAME "background.jpg"
  
int main(int argc, char **argv)
{
    gdk_pixbuf_xlib_init (m_display, 1);
    background = gdk_pixbuf_new_from_file (BACKGROUND_NAME);
    return 0;
}

#include <stdio.h>
#include <signal.h>
#include <errno.h>
#include <stdlib.h>

#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xos.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>

#include <X11/extensions/shape.h>

#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk-pixbuf/gdk-pixbuf-xlib.h>

static Display *m_display;
static GdkPixbuf *background;

#define BACKGROUND_NAME "background.jpg"
  
int main(int argc, char **argv)
{
    gdk_pixbuf_xlib_init (m_display, 1);
    background = gdk_pixbuf_new_from_file (BACKGROUND_NAME);
    return 0;
}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]