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

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.

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

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.

Related

Debian Packaging Without Build Tool

I want to create a Debian package from a C program without the use of a build tool such as autotools or CMake. My debian/rules file:
#!/usr/bin/make -f
%:
dh $#
override_dh_auto_clean:
rm -f program
override_dh_auto_build:
gcc program.c -o program
override_dh_auto_install:
cp program /usr/local/bin
Upon running dpkg-buildpackage, I get:
dh: error: Unknown sequence application (choose from: binary binary-arch binary-indep build build-arch build-indep clean install install-arch install-indep)
It seems the issue was related to the fact that I was creating the file in a shell script heredoc that was expanding the $#, e.g.
cat <<EOF > debian/rules.temp
#!/usr/bin/make -f
%:
dh $#
EOF
Which should be:
all_symbol='$#'
cat <<EOF > debian/rules.temp
#!/usr/bin/make -f
%:
dh $all_symbol
EOF
An unrelated issue is to the location of the override_dh_auto_install To manually create Debian file hierarchy it should be:
override_dh_auto_install:
mkdir -p debian/PACKAGENAME/usr/bin
cp program debian/PACKAGENAME/usr/bin
Or, to have this done automatically:
cat <<EOF > debian/PACKAGENAME.install
program usr/bin
EOF

what is wrong with my makefile code?

I have a makefile that I needed to change around, and use it to install the program. I can;t figure out why I am getting this error:
v245-2% make install
install -m 555 audit /export/home/student/scort323/bin
sh: install: not found
*** Error code 1
make: Fatal error: Command failed for target `install'
Below is my code, can somebody please give me some advice. I am not good at makefiles so trying to find this error is hard for me until I get a better understanding:
# Make file for audit
# Location to install binary. Default is /usr/local/bin. You may
# prefer to install it in /usr/bin or /sbin
BINDIR = /export/home/student/scort323/bin
#BINDIR=/usr/bin
#BINDIR=/usr/sbin
# Location to install man page. Default is /usr/local/man. You may
# prefer to install it in /usr/man
MANDIR = /export/home/student/scort323/bin
#MANDIR = /usr/man
# Compiler to use
CC = gcc
# Linker to use
LD = gcc
# Preprocessor options
CPPFLAGS = -DGETOPTLONG
# Compile and link options
# On a.out systems you might want to add -N when linking
# RPM_OPT_FLAGS can be set by rpm tool
# ...For production code
CFLAGS = -Wall -O3 $(RPM_OPT_FLAGS)
LDFLAGS = -s
# ...For debug
#CFLAGS = -Wall -g
#LDFLAGS = -g
audit: audit.o
$(LD) $(LDFLAGS) -o audit audit.o
audit.o: audit.c
$(CC) $(CPPFLAGS) $(CFLAGS) -c audit.c
install: audit
install -m 555 audit $(BINDIR)
#/audit
install -m 444 audit.1 $(MANDIR)
#/man1/audit.1
clean:
$(RM) audit audit.o core *~ results
# check in
ci: clean
-ci -l *
dist: clean
cd .. ; tar --exclude RCS -czvf audit-0.2.tar.gz audit-0.2
There is no problem with the makefile. Check if you have install utility
$~ install --help
If you dont have then you can get it from GNU coreutils. If you have install somewhere then export its path in PATH variable
export PATH=$PATH:/path/to/install-utilit

Can't program ATtiny2313a with Arduino. Is my chip bricked?

I've been trying to burn a program into ATtiny2313A-PU with my Arduino Uno R3 used as a programmer.
First I tried to program it from Arduino IDE 1.0.1 (Windows 7) and it seemed to uploade the sketch, but the blink program didn't work.
Then I found Michael Holachek's tutorial and followed his instructions:
uploaded ArduinoISP sketch to my Arduino Uno
wired the circuit on a breadboard
installed WinAVR on my Windows 7.
downloaded Michael's template files (Makefile and main.c) and edited Makefile to match my settings (external 8 MHz crystal). I used this online fuse calculator to get correct fuse parameters.
then, in cmd.exe, changed directory to the directory where I saved Makefile and main.c and ran 'make flash'
Makefile
DEVICE = attiny2313a
CLOCK = 8000000
PROGRAMMER = -c arduino -P COM5 -b 19200
OBJECTS = main.o
FUSES = -U lfuse:w:0x5e:m -U hfuse:w:0xdd:m -U efuse:w:0xff:m
######################################################################
######################################################################
# Tune the lines below only if you know what you are doing:
AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE)
COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE)
# symbolic targets:
all: main.hex
.c.o:
$(COMPILE) -c $< -o $#
.S.o:
$(COMPILE) -x assembler-with-cpp -c $< -o $#
# "-x assembler-with-cpp" should not be necessary since this is the default
# file type for the .S (with capital S) extension. However, upper case
# characters are not always preserved on Windows. To ensure WinAVR
# compatibility define the file type manually.
.c.s:
$(COMPILE) -S $< -o $#
flash: all
$(AVRDUDE) -U flash:w:main.hex:i
fuse:
$(AVRDUDE) $(FUSES)
install: flash fuse
# if you use a bootloader, change the command below appropriately:
load: all
bootloadHID main.hex
clean:
rm -f main.hex main.elf $(OBJECTS)
# file targets:
main.elf: $(OBJECTS)
$(COMPILE) -o main.elf $(OBJECTS)
main.hex: main.elf
rm -f main.hex
avr-objcopy -j .text -j .data -O ihex main.elf main.hex
# If you have an EEPROM section, you must also create a hex file for the
# EEPROM and add it to the "flash" target.
# Targets for code debugging and analysis:
disasm: main.elf
avr-objdump -d main.elf
cpp:
$(COMPILE) -E main.c
main.c
Below is the output I got:
C:\Users>cd /D D:\electronics
D:\electronics>cd nikon/mi
D:\electronics\nikon\mi>make flash
avr-gcc -Wall -Os -DF_CPU=8000000 -mmcu=attiny2313a -c main.c -o main.o
main.c:6: error: stray '\342' in program
main.c:6: error: stray '\200' in program
main.c:6: error: stray '\250' in program
main.c: In function 'main':
main.c:9: error: stray '\342' in program
main.c:9: error: stray '\200' in program
main.c:9: error: stray '\250' in program
make: *** [main.o] Error 1
I suspect that I might brick the fuses on Attiny 2313a. If that is the case, I think I will have to build this AVR rescue shield.
Maybe the Makefile was configured incorrectly?
How can I identify the problem? How can I check whether the chip is still alive?
You are getting compile errors there. I would check the contents of main.c for what the compiler is telling you to check. It looks like in the copy and paste of the code, something was lost. Also
PORTD ^= (1 << PD6); // toggle PD6
can be replaced with
PIND = (1 << PD6); // or _BV(PD6), since you should be using avr-libc anyway.
as per Atmel's datasheets.
well, I googled a little bit more and found that the most common solution, when chips are identical, but have different suffixes (like attiny2313 and attiny2313a) is to use -F key for overriding the signature check.
So, I added the key in Makefile DEVICE = attiny2313 -F and my attiny2313a was programmed successfully!
TRON, thanks for pointing me in the direction of main.c! Unfortunately I can't upvote your answer because my reputation is 11.
I still wonder how those square characters could get there?

GNU make dependency issue

To make it simple, say I have the following folders:
./src/ with many .c files
./obj/ with many .obj files
./output/ with my binaries I want to build
My makefile is as follows:
all: init mybin
# init commands
init:
mkdir obj
mkdir output
mybin: project1 project2 project3
$(CC) src/misc.c ... etc
$(LK) obj/first.obj obj/second.obj obj/third.obj obj/four.obj obj/five.obj obj/six.obj obj/seven.obj obj/eight.obj obj/nine.obj -o output/myapp.bin
project1: obj/first.obj obj/second.obj obj/third.obj
obj/first.obj: src/first.c
$(CC) first.c ... etc
obj/second.obj: src/second.c
$(CC) obj/second.c ... etc
obj/third.obj: src/third.c
$(CC) obj/third.c ... etc
project2: obj/four.obj obj/five.obj obj/six.obj
obj/four.obj: src/four.c
$(CC) four.c ... etc
obj/five.obj: src/five.c
$(CC) obj/five.c ... etc
obj/six.obj: src/six.c
$(CC) obj/six.c ... etc
project3: obj/seven.obj obj/eight.obj obj/nine.obj
obj/seven.obj: src/seven.c
$(CC) seven.c ... etc
obj/eight.obj: src/eight.c
$(CC) obj/eight.c ... etc
obj/nine.obj: src/nine.c
$(CC) obj/nine.c ... etc
The first time I ran make all, everything compiled find. Then I did:
$ touch src/four.c
$ make all
$
But make exits without compiling anything. I guess it did not detect that one of the .c files had changed, however I don't see what's wrong with my dependencies.
What I expected:
touching src/four.c should have marked obj/four.obj obsolete, and project2 aswell, hence marking mybin obsolete too. This chain should trigger a new compilation of src/four.c to obj/four.obj and then a new linkage of the whole project.
Did you specify the output file of compilation (likely the -o option)? By default (for most toolchains), compiling a .c file produces an .o file, not an .obj one.
UPD.
To get Make updating targets when some prerequisites change you have to provide an exact dependencies between files as far as Make use timestamps to determine whether a file has been changed.
That is, all and init could remain as so-called .PHONY targets, but it is a good practice to make the rest targets to be files.
OUT_DIR := ./output
SRC_DIR := ./src
OBJ_DIR := ./obj
MYBIN := $(OUT_DIR)/myapp.bin
OBJS := $(addprefix $(OBJ_DIR)/, \
first.obj \
second.obj \
third.obj \
four.obj \
five.obj \
six.obj \
seven.obj \
eight.obj \
nine.obj)
.PHONY : all mkdir-output mkdir-obj
all : $(MYBIN)
mkdir-output :
#mkdir -p $(OUT_DIR)
mkdir-obj :
#mkdir -p $(OBJ_DIR)
$(MYBIN) : $(OBJS) | mkdir-output
$(LK) $^ -o $#
$(OBJS) : | mkdir-out
$(OBJS) : $(OBJ_DIR)/%.obj : $(SRC_DIR)/%.c
$(CC) $< -object=$# $(CC_OPT)
The last rule is GNU Make's static pattern rule. And the mkdir-xxx prerequisites after a pipe sign | are order-only ones.

make: hierarchical make file

(disclaimer: I am used to scons ... I am somewhat unexperienced with make)
Context: I am using Eclipse CDT which generates makefiles.
Let's say I have a project directory 'lib' and 2 build configurations 'Debug' and 'Release'. Eclipse CDT gracefully generates a makefile for each build configuration. The said makefiles end-up residing in 'Debug' and 'Release' folders.
Now, what I want to do is have a makefile in the folder 'lib' which calls the makefiles 'Debug/makefile' and 'Release/makefile'.
How do I do that?
I want to be able to launch 'make' in the folder 'lib' and both configurations would be called with the specified target(s).
Solution
Based on all the great input gathered here, I devised the following:
MAKE=make
BUILDS=Release Debug
TARGETS=all clean
$(TARGETS):
#for b in $(BUILDS) ; do $(MAKE) -C $$b $# ; done
$(BUILDS):
#for t in $(TARGETS) ; do $(MAKE) -C $# $$t ; done
%:
#for b in $(BUILDS) ; do $(MAKE) -C $$b $# ; done
depends on what is "calls". You want to either
include $(BUILD)/Makefile
or
$(MAKE) -C $(BUILD) $#
or some such. I'd guess you want the latter. Maybe something like
release debug:
$(MAKE) -C $#
You get the idea.
More examples:
BUILDS=release debug
TARGETS=all clean
$(TARGETS):
for b in $(BUILDS) ; do $(MAKE) -C $$b $# ; done
$(BUILDS):
for t in $(TARGETS) ; do $(MAKE) -C $# $$t ; done
Since you mention "the specified target(s)", I suggest:
%:
$(MAKE) -C Debug $#
$(MAKE) -C Release $#
If that's too general, you can replace the % with $(TARGETS), where TARGETS is something you define, a list of all the things you'd ever want to do this with.
all: release debug
release:
$(MAKE) -C ../Release
debug:
$(MAKE) -C ../Debug
I'm assuming they're all on the same level. The path must be from where you call Make.
Have different targets that invoke the makefile in the two directories.
all: debug product
debug:
$(MAKE) -f debug/Makefile
product:
$(MAKE) -f product/Makefile

Resources