Troubles compiling in GPS (Ada IDE) with glib.h

2019-02-26 21:47发布

问题:

i'm having some troubles when trying to compile Ada code in GPS. GPS says is missing when I include it on a package. I tried installing with apt-get, and it does, but the error is still there. What can I do next? I'm running GPS on a x64 Ubuntu 12.04.

Here's the error message I got:

gprbuild -d -P/media/LUISMUNYOZ/QUINTO/str/pendulum/pendulum_portatil/pendulum.gpr
 -XEXTRA=True -XOPENGL=True -XGNOME=True -XBUILD=Production
 print_barrier_sync.adb contrib.gpr:1:09: warning: no compiler specified for language "Xml",
 ignoring all its sources x86_64-pc-linux-gnu-gcc -c lw.c In file included from
 /media/LUISMUNYOZ/QUINTO/str/pendulum/pendulum_portatil/gtkada/testgtk/opengl/lw.c:20:0:
 /media/LUISMUNYOZ/QUINTO/str/pendulum/pendulum_portatil/gtkada/testgtk/opengl/lw.h:23:18:
 fatal error: glib.h: No such file or directory compilation terminated.
 gprbuild:* compilation phase failed

[2012-11-21 13:24:47] process exited with status 4 (elapsed time: 02.06s) [2012-11-21 13:24:56]
    Could not locate executable on path: svn SVN error:
[…]

The error triggers at this point:

#ifndef LW_H
#define LW_H

#include <glib.h>           <------------------------------------------
#include <GL/gl.h>

#define LW_MAX_POINTS   200
#define LW_MAX_NAME_LEN 500

The file is lw.h, which is defined in the package GtkAda. I downloaded it from GPS page.

回答1:

I'd pursue @Simon's approach, but a work-around based on 2.4.2. Using the command line might be a temporary alternative while you sort out the underlying problem.

As you are using linux, here's a Makefile for the basic Interaction demo.

# Make shared, static or debug targets.
OS := $(shell uname)
OBJ = obj
TARGET = interaction
GNATMAKE = gnatmake -D $(OBJ)
CARGS = -cargs -O3 -gnatp -gnatwu -gnatf
BARGS = -bargs
LARGS = -largs
.PHONEY: clean cleaner cleanest

all:
    @echo ""
    @echo "Build targets:"
    @echo ""
    @echo "    shared     Use the shared Ada libraries."
    @echo "    static     Link the Ada libraries statically."
    @echo "    debug      Enable debugging."
    @echo ""
    @echo "Support targets:"
    @echo ""
    @echo "    clean      Remove *.ali *.o b~.*"
    @echo "    cleaner    Remove target, too."
    @echo "    cleanest   Remove build directory, too."
    @echo ""

shared: $(OBJ)
shared: INCLUDE = $(shell gtkada-config --cflags)
shared: BARGS += -shared
shared: LARGS += $(shell gtkada-config --libs)
shared: LARGS += -dead_strip
shared: *.ad[sb]
    @echo "building with shared libraries:"
    $(GNATMAKE) $(TARGET) $(INCLUDE) $(CARGS) $(BARGS) $(LARGS)

static: $(OBJ)
static: INCLUDE = $(shell gtkada-config --static --cflags)
static: BARGS += -static
static: LARGS += $(shell gtkada-config --static --libs)
static: LARGS += -dead_strip
static: *.ad[sb]
    $(GNATMAKE) $(TARGET) $(INCLUDE) $(CARGS) $(BARGS) $(LARGS)

debug: $(OBJ)
debug: INCLUDE = $(shell gtkada-config --static --cflags)
debug: BARGS += -static
debug: LARGS += $(shell gtkada-config --static --libs)
debug: *.ad[sb]
    $(GNATMAKE) -g $(TARGET) $(INCLUDE) $(LARGS)

$(OBJ):
    mkdir $(OBJ)

clean:
    ${RM} $(OBJ)/* b~*

cleaner: clean
    ${RM} $(TARGET)

cleanest: cleaner
    ${RM} -r $(OBJ) 

For reference, these packages were installed on Ubuntu 12.04:

$ dpkg --get-selections | egrep "gnat|gtkada"
gnat                        install
gnat-4.6                    install
gnat-4.6-base               install
gnat-gps                    install
gnat-gps-common             install
gnat-gps-doc                install
libgnat-4.6                 install
libgnatprj4.6               install
libgnatvsn4.6               install
libgtkada-bin               install
libgtkada2.24.1             install
libgtkada2.24.1-dev         install


回答2:

I've never used GtkAda. However ... I googled glib.h and got many hits, suggesting that for plain C builds one should use - for example, from this StackOverflow question -

# Sample Makefile
CFLAGS := $(shell pkg-config --cflags glib-2.0 gtk+-2.0)
LDFLAGS := $(shell pkg-config --libs glib-2.0 gtk+-2.0)

foo: foo.c
        $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)

However, we're talking gprbuild here, so perhaps the GtkAda documentation is relevant? It says you need to include with "gtkada"; in your GNAT Project file, and include the location of gtkada.gpr on your ADA_PROJECT_PATH if it isn't there already (see the output of gnatls -v).

If you've already done that, please show us the GPR file.



标签: ada glib