Can someone help me out with a makefile for raspbian gcc ?

Page 3 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.

sdifox

No Lifer
Sep 30, 2005
99,364
17,548
126
Ivona on Android is great. Look into availability for raspbian.
 
May 11, 2008
22,223
1,411
126
Aha, I will have to look into that. Found something :
When i search about ivona and android, google blocks the playstore links due to not being available yet in my country. Interesting.

At the moment i am having a speed and refresh course linux.
I am still gathering information about how and where all the header files and libraries are stored.
My guess is that once i got it all installed on the raspberry pi, i can just copy it to my pc and compile on my pc.
There is a lot of cross compiling support for the raspberry pi on ubuntu. Once i have read about that, i hope i have enough information to get it all to compile (under windows as well).
 
Last edited:
May 11, 2008
22,223
1,411
126
I can already write/compile and execute standard c programs. But now the challenge comes to get opencv up and running.
Maybe i will start with something simpler like getting the bcm2835 header and see if i can get some data in en out. I read it is now natively supported in the latest raspbian. That should be easy in theory.

http://www.airspayce.com/mikem/bcm2835/
 
May 11, 2008
22,223
1,411
126
Ivona sure sounds natural. I tried the website.
The funny part is that if you let it say for example an English sentence : "Hi, mi name is ivona" and choose another language,
it will still sound like English only spoken with a very heavy accent.
Lot of fun.:laughing:

Well, it works very good when using Dutch and selecting voices from different countries. :grin:
 

sdifox

No Lifer
Sep 30, 2005
99,364
17,548
126
Aha, I will have to look into that. Found something :
When i search about ivona and android, google blocks the playstore links due to not being available yet in my country. Interesting.

At the moment i am having a speed and refresh course linux.
I am still gathering information about how and where all the header files and libraries are stored.
My guess is that once i got it all installed on the raspberry pi, i can just copy it to my pc and compile on my pc.
There is a lot of cross compiling support for the raspberry pi on ubuntu. Once i have read about that, i hope i have enough information to get it all to compile (under windows as well).

There are alternative stores like appslib. users upload apks and they get vetted against source. They don't do region lock
 
May 11, 2008
22,223
1,411
126
Made some small enhancements. Since linux does not have the .exe file extension, i decided for a small modification that W-ARM no longer generates a makefile that creates an output file with the .exe extension. :)

As always, the output file is named : " RPITEST", similar to the project name. Of course for this particular project.

Code:
# Automatically generated by W-ARM for RPI !
# Do not edit this file with an editor that replaces tabs with spaces !
################################################################################

ECHO = echo.exe
CP = cp.exe
CC = arm-linux-gnueabihf-g++.exe
AS = arm-linux-gnueabihf-g++.exe -x assembler-with-cpp
CREATE_OUTPUT_FILE = arm-linux-gnueabihf-g++ -o RPITEST

SRC = ./src/file2.c ./src/main.c
ASRC =

USR_INC_DIR = ./inc
USR_LIB_DIR = ./lib
################################################################################

# These are the object files of external libraries.
LIBOBJS =
# Library directory with LD switches.
LIBDIR = -L USR_LIB_DIR

# substitution reference OBJS = every module name, replace s with o and every c with o.
OBJS = $(ASRC:.s=.o) $(SRC:.c=.o)

### compiler flags.
# architecture optimizations
MCU_FLAGS = -mcpu=cortex-a53
# compiler optimisation level
OPT =-O1

# debugger
DBGGR =
# floating point unit
FLPU =-mfpu=vfpv4
# compiler flags combined into a single variable.
CP_FLAGS = $(DBGGR) $(FLPU) $(OPT) $(MCU_FLAGS) -Wall -g -Wa,-adhln=$(<:.c=.lst)

# assembler flags combined into a single variable.
AS_FLAGS = $(OPT) $(MCU_FLAGS) -Wa

# linker flags.
LD_FLAGS = $(MCU_FLAGS) -lgcc -lrt -Wl,-Map=./output/RPITEST.map,--cref $(LIB_DIR)

# Eye candy.
begin:
    @$(ECHO)
    @$(ECHO) ---------------- begin ----------------
    @$(ECHO)

finished:
    @$(ECHO)
    @$(ECHO) Errors none.
    @$(ECHO)
    @$(ECHO) Output format = Raspbian executable
    @$(ECHO)
    @$(ECHO) Project name = RPITEST
    @$(ECHO)

end:
    @$(ECHO)
    @$(ECHO) ---------------- end ----------------
    @$(ECHO)

clean_message:
    @$(ECHO)
    @$(ECHO) Cleaning directories of current project : RPITEST
    @$(ECHO)

# Display compiler version information.
gccversion:
    @$(CC) --version

#Execute from here.
all: begin gccversion create move_files finished end

#copy files to new destination.
move_files:
    @$(CP) ./src/*.lst ./list/
    @$(CP) ./src/*.o  ./object/
    @$(CP) RPITEST ./output/
    @-rm -f ./src/*.lst
    @-rm -f ./src/*.o
    @-rm -f RPITEST

# create output file.
#Make searches for pattern rules first.
create: $(OBJS)
    $(CREATE_OUTPUT_FILE) $(LD_FLAGS) $(OBJS) $(LIBOBJS)

# This pattern rule is performed for every single c module. One object file for every c module.
%.o : %.c
    $(CC) -c $(CP_FLAGS) -I $(USR_INC_DIR) $< -o $@

# This pattern rule is performed for every single assembly module. One object file for every assembly module.
%.o : %.s
    $(AS) -c $(AS_FLAGS) -I $(USR_INC_DIR) $< -o $@

clean: begin gccversion deletefiles clean_message end

deletefiles:
    @-rm -f $(OBJS)
    @-rm -f $(SRC:.c=.c.bak)
    @-rm -f $(SRC:.c=.lst)
    @-rm -f $(ASRC:.s=.s.bak)
    @-rm -f $(ASRC:.s=.lst)
    @-rm -fR .dep
    @-rm -f ./output/*.map
    @-rm -f ./output/RPITEST
    @-rm -f ./list/*.lst
    @-rm -f ./object/*.o


# Listing of phony targets.
.PHONY : all begin finish end move_files clean_message sizebefore sizeafter gccversion build elf hex lss sym clean clean_list program

# *** EOF ***

Removed an error in the code.
 
Last edited:
May 11, 2008
22,223
1,411
126
Yahoo. I took the bcm2835 library 1.50 and after removing some cast errors by adding explicit casts in the bcm2835.c file...

before :
bcm2835_peripherals = mapmem("gpio", bcm2835_peripherals_size, memfd, (uint32_t)bcm2835_peripherals_base);
after :
bcm2835_peripherals = (uint32_t*)mapmem("gpio", bcm2835_peripherals_size, memfd, (uint32_t)bcm2835_peripherals_base);

There are like 12 of these errors in the bcm2835.c file.


I do not want to use the -fpermissive flag for the compiler . That allows for errors to be made.
I rather have a compiler that is very strict.
I successfully compiled the blinking led test in my example program.
And i have a blinking led.
icon_e_biggrin.gif


I also have now setup the I2C communication. That works as well. My great little Saleae Logic analyzer proved once more how happy i am with it.
 
Last edited:
May 11, 2008
22,223
1,411
126
I am creating a little booklet from information gathered from the internet.
This booklet has some basic explanation about the raspberry pi gpio pins and some handy linux commands.
It is not finished yet, but when it is, i will add the pdf to the dropbox account i have.
This seems to be handy to get the same packages installed on another system.

To make a backup of what packages are currently installed :

dpkg --get-selections > ~/Desktop/list.txt

To get another system to install the same packages, type :

dpkg –clear-selections

and

sudo dpkg --set-selections < ~/Desktop/list.txt
 
May 11, 2008
22,223
1,411
126
I just installed synaptic which is a GTK+ based GUI for apt. It sure helps me to get a better understanding how debian (and linux in general) functions. :)
 
May 11, 2008
22,223
1,411
126
Well, i just bought this lego brick case for my RBPI B+.
I installed the latest jessie on the B+ as well by copying the image to the sd card with winflashtool and it works fine. I did notice that after enabling the vnc server and restarting and after that another reboot without monitor and keyboard, that the vnc client could not connect, the connection was refused. I was not sure if this was because i had no longer an keyboard and hdmi monitor attached. To be on the safe side, i edited the config.txt textfile to force the hdmi output on (hdmi_force_hotplug=1) and to output in hdmimode 85 , hdmigroup 2 (720p@60Hz). And now i can connect fine. Without the need for an external keyboard or monitor. Now, i can test all the linux commands on the B+ and use the B3 for programming stuff.

http://www.newark.com/multicomp/cbpiblox-red/raspberry-pi-enclosure-abs-red/dp/77Y6511?ost=2524082&selectedCategoryId=&categoryNameResp=All+Categories&searchView=table&iscrfnonsku=false

77Y6511-40.jpg
 
May 11, 2008
22,223
1,411
126
Forgot, i also bought this expansion board to play around with the gpio port and other peripherals by making use of a breadboard.

RPI-B+TCOB-KIT-1-600x315.jpg




RPI-B+TCOB-ASS-4-1000x667.jpg



EDIT:
Forgot to mention that sparkfun also sells these GPIO extension boards.
 
Last edited:
May 11, 2008
22,223
1,411
126
While reading about gtk, i learned of this gem : pkg-config.

When you need to find out what depdencies exist for a given package, the command tool
pkg-config is very handy. With the proper flags, it will put out text that is useful information for the
compiler and the linker to know where to find the header files and libraries.
Pkg-config is a helper tool used when compiling applications and libraries. It helps you insert the
correct compiler options on the command line so an application can use gcc. For instance, rather
than hard-coding values on where to find glib (or other libraries).
For example : pkg-config --cflags --libs gtk+-2.0
When typed in at bash, this command will produce all information about the header files and the
libraries used for GTK+-2.0
 
May 11, 2008
22,223
1,411
126
Hey sdifox, I am trying to write a gtk example program.
I am chewing through the dependencies, fixing them as i go but there is one file that does not exist in my ./usr directory and yet it is mentioned often.
In the pango directory there is a pango-font.h missing. the other *.h files in the pango directory include it but it is not present. A search command for the file also gives 0 result. I did install all developer files as needed.
Have you ever encountered such an error ?
I googled for it and there does seem to exist such a file at red hat. Maybe i should just copy that file ?
 
May 11, 2008
22,223
1,411
126
I downloaded the pango from the github and copied the pango-font.h file. At least the compilation gets a bit further.

Have you any idea why some files have this appended to them (in bold) :
atk-enum-types.h.dpkg-new

I have the idea that during installation something went wrong or that there is an issue at the repository.
Some files that i miss have that dpkg-new
 

sdifox

No Lifer
Sep 30, 2005
99,364
17,548
126
Hey sdifox, I am trying to write a gtk example program.
I am chewing through the dependencies, fixing them as i go but there is one file that does not exist in my ./usr directory and yet it is mentioned often.
In the pango directory there is a pango-font.h missing. the other *.h files in the pango directory include it but it is not present. A search command for the file also gives 0 result. I did install all developer files as needed.
Have you ever encountered such an error ?
I googled for it and there does seem to exist such a file at red hat. Maybe i should just copy that file ?
No clue sorry.
 
May 11, 2008
22,223
1,411
126
That is interesting, after an apt-get update, i seem to have lost the dpkg-new additions and i also noticed the missing files.

Now the pango-font.h file for example is also present and it was not before.
(I should clarify that i previously copied the entire usr directory to my windows system for easy searching, good for comparing).
I never had any errors or y/n messages during apt-get usage. I do not understand why, but it seems good practice to do apt-get update often.
 
May 11, 2008
22,223
1,411
126
I do not understand it anymore. When i start up the rbpi3 and look into the include folder of /usr i see the files. When i shutdown raspbian and read the files again by use of my card reader, they have the dpkg-new extension again.
I have not written 2 lines of code because of all these issues. :(
 
May 11, 2008
22,223
1,411
126
Well, i made an elaborate post at the raspberry pi forum.
Learned some new tricks to check for files by use of the commands : readlink, ls, file, stat.
Added everything i learned so far into my linux lookup booklet.
Now it is waiting for help.
 
May 11, 2008
22,223
1,411
126
Well, i almost forgot that the raspberry pi has usb ports(always facing away from me), so i just used an usb stick to copy the files. I no longer have any need for ubuntu or linuxreader. Either something went wrong during the installation of ubuntu or it is just that bad. Ubuntu had from the beginning a single desktop and every program was full screen, no multiple windows. And every example i found on the internet gave me the error that i have no permission even with sudo and after changing myself to root(which it seems did not work). I deleted the vmware image. Maybe if i feel like it i will try it again in the future. Ubunut was like a electric typewriter. Good for browsing and typing a letter and that is it.
Raspbian is miles ahead in being user friendly and more like a modern os like windows and apple.

For some reason, the linuxreader program found other header files with dpkg-new appended. Maybe it is a bug. At least i can now just use the usbstick instead.
For security and safety reasons i have no samba server installed on the raspberry pi and just use the usb stick for now.


I still get symbolic link errors while copying files to the usb stick. :|
But at least with raspbian i can easily copy all errors to a text file in geany and examine it later, try to understand it and find a solution.

After a sudo umount /media/pi/USBSTICK, i disconnected the usb stick.
I checked in windows, and all files are there without the dpkg-new.

Now, i can at least continue with trying to make a GTK+ program.

edit:
Also removed linuxreader from diskinternals.
 
Last edited:
May 11, 2008
22,223
1,411
126
After a bunch of household chores, a movie, diner and just some relaxing :
Yahoo. I do not have any errors while compiling but i have them during the linking stage.

the linker ld cannot find the needed gtk libraries.
And i did a search for those libraries in the usr/include and usr/lib that i copied to my pc and of course they are missing.
This afternoon, i made a log of all error messages produced while trying to copy the library files, into a text file.
Raspbian and the bash terminal work so great. It just works. :)
And with real vnc, it is just another window in windows 10. Just copying and pasting away.

I looked for the missing libraries in the text file and there they are : Could not be copied.
For example :
libgtk-x11-2.0.so: Filesystem does not support symbolic links

ld message :
e:/rbpi/sysgcc/bin/../lib/gcc/arm-linux-gnueabihf/4.9/../../../../arm-linux-gnueabihf/bin/ld.exe: cannot find -l./lib/gtk-x11-2.0

If i can solve that issue, i should be able to finally get a gtk window displayed.
I am still augmenting on my booklet with handy dandy linux tips and tricks.
 
May 11, 2008
22,223
1,411
126
Yahoo.

I had an issue, how to find files in linux.
I installed locate :

sudo apt-get update
sudo apt-get install mlocate

Update the database of locate with :
sudo updatedb

And searched for libgtk-x11-2.0.so:
locate libgtk-x11-2.0.so
After that, i knew where to find it.
Used ls -l libgtk-x11-2.0.so to find out if it is a real file or a symlink :
And as expected it is a symlink pointing to a file called : libgtk-x11-2.0.so.0.2400.25

from ls : libgtk-x11-2.0.so -> libgtk-x11-2.0.so.0.2400.25
I understand why this is done, to keep the name functional but also keep a unique version number, a symlink is created.
And this is almost the end of my quest.
Because with locate i can find the location of any file in linux.

:)
 
May 11, 2008
22,223
1,411
126
Yahoo. I can finally link in libraries. I created my own library and from then on step by step try to solve what is going wrong. And i finally succeeded (with a bit of help , pointing me in the right direction).