To my personal observations many libs (e.g., openVG) use make, and IIRC I also sometimes have seen installation guides which have been using makefile.
I can't remember if I have ever seen cmake, but I'm quite sure that make and makefile have been used more often than cmake AFAIK.
Anyway, IMO it's not bad to be taught how either one would work.
But I personally also am using just Geany with all my propietary (more or less static) settings for compile and build, and I also would recommend that to every beginner to C.
As the author of the MagPi C tutorial also already shows the Geany screenshots (used as an editor), it's just a small step to explain how to set the Geany compile/build preferences, and then how to use it as a both handsome and complete and powerful IDE.
- DougieLawson
- Posts: 40512
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
- Contact: Website Twitter
Re: MagPi 47 - An Introduction to C - Page 62
Give it a go https://cmake.org/cmake-tutorial/ it's so much simpler because there's no arcane syntax requirements (like tabs).
Any language using left-hand whitespace for syntax is ridiculous
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Re: MagPi 47 - An Introduction to C - Page 62
Thanks for the link. Replacing a makefile that looks likeDougieLawson wrote:Give it a go https://cmake.org/cmake-tutorial/ it's so much simpler because there's no arcane syntax requirements (like tabs).
Code: Select all
tutorial: tutorial.cxx
g++ -o tutorial tutorial.cxx
Code: Select all
cmake_minimum_required (VERSION 2.6)
project (Tutorial)
include(CTest)
# The version number.
set (Tutorial_VERSION_MAJOR 1)
set (Tutorial_VERSION_MINOR 0)
# does this system provide the log and exp functions?
include (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)
check_function_exists (log HAVE_LOG)
check_function_exists (exp HAVE_EXP)
# should we use our own math functions
option(USE_MYMATH
"Use tutorial provided math implementation" ON)
# configure a header file to pass some of the CMake settings
# to the source code
configure_file (
"${PROJECT_SOURCE_DIR}/TutorialConfig.h.in"
"${PROJECT_BINARY_DIR}/TutorialConfig.h"
)
# add the binary tree to the search path for include files
# so that we will find TutorialConfig.h
include_directories ("${PROJECT_BINARY_DIR}")
# add the MathFunctions library?
if (USE_MYMATH)
include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions")
add_subdirectory (MathFunctions)
set (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions)
endif (USE_MYMATH)
# add the executable
add_executable (Tutorial tutorial.cxx)
target_link_libraries (Tutorial ${EXTRA_LIBS})
# add the install targets
install (TARGETS Tutorial DESTINATION bin)
install (FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h"
DESTINATION include)
# does the application run
add_test (TutorialRuns Tutorial 25)
# does the usage message work?
add_test (TutorialUsage Tutorial)
set_tests_properties (TutorialUsage
PROPERTIES
PASS_REGULAR_EXPRESSION "Usage:.*number"
)
#define a macro to simplify adding tests
macro (do_test arg result)
add_test (TutorialComp${arg} Tutorial ${arg})
set_tests_properties (TutorialComp${arg}
PROPERTIES PASS_REGULAR_EXPRESSION ${result}
)
endmacro (do_test)
# do a bunch of result based tests
do_test (4 "4 is 2")
do_test (9 "9 is 3")
do_test (5 "5 is 2.236")
do_test (7 "7 is 2.645")
do_test (25 "25 is 5")
do_test (-25 "-25 is 0")
do_test (0.0001 "0.0001 is 0.01")
On another note, in accordance with the Creative Commons (BY-SA-NC 3.0) license, the overlay feature of xournal has been used to whiteout all instances of "void main" and replace them with "int main" in MagPi Essentials: Learn to Code with C, Volume 1. The two addenda to the book have also been included.
The xournal overlay file is 17K. To view it type
Code: Select all
$ sudo apt-get xournal
$ wget https://www.raspberrypi.org/magpi-issues/Essentials_C_v1.pdf
$ wget http://fractal.math.unr.edu/~ejolson/pi/Essentials_C_Modified.xoj
$ xournal Essentials_C_Modified.xoj
Re: MagPi 47 - An Introduction to C - Page 62
isn't that all far too complicated for beginners?
Finally it IS or SHOULD BE a tutorial designed and dedicated to beginners!
Finally it IS or SHOULD BE a tutorial designed and dedicated to beginners!
- Tim
Re: MagPi 47 - An Introduction to C - Page 62
Raspbian (even Rasbian Lite) comes as standard with "make", not cmake which must be separately installed.
So I would prefer standard GNU "make" for a beginners tutorial even if its more difficult ... and its not actually hard to use IMHO, except for someone who doesn't like Python indentation either
So I would prefer standard GNU "make" for a beginners tutorial even if its more difficult ... and its not actually hard to use IMHO, except for someone who doesn't like Python indentation either

Re: MagPi 47 - An Introduction to C - Page 62
I give up with you guys... Welcome to my "foe list"....jahboater wrote:Raspbian (even Rasbian Lite) comes as standard with "make", not cmake which must be separately installed.
So I would prefer standard GNU "make" for a beginners tutorial even if its more difficult ... and its not actually hard to use IMHO, except for someone who doesn't like Python indentation either
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson
- DougieLawson
- Posts: 40512
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
- Contact: Website Twitter
Re: MagPi 47 - An Introduction to C - Page 62
Now build a project that has six header files and seven modules used to create three programs. The complexity of Makefiles vs CMakeLists.txt rapidly spirals out of control. My first cmake project is just about at the limit for a sane and usable Makefile. It was absolutely trivial to build the fourteen line CMakeLists.txt for that.jahboater wrote:Raspbian (even Rasbian Lite) comes as standard with "make", not cmake which must be separately installed.
So I would prefer standard GNU "make" for a beginners tutorial even if its more difficult ... and its not actually hard to use IMHO, except for someone who doesn't like Python indentation either
As a project gets bigger the cost of creating masses of arcane junk for make versus a simple text file for cmake makes it a simple choice.
Why else would cmake exist?
Any language using left-hand whitespace for syntax is ridiculous
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Re: MagPi 47 - An Introduction to C - Page 62
perhaps more for experts and professionals, and less for beginners and hobbyists?Now build a project that has six header files and seven modules used to create three programs. The complexity of Makefiles vs CMakeLists.txt rapidly spirals out of control. My first cmake project is just about at the limit for a sane and usable Makefile. It was absolutely trivial to build the fourteen line CMakeLists.txt for that.
As a project gets bigger the cost of creating masses of arcane junk for make versus a simple text file for cmake makes it a simple choice.
Why else would cmake exist?
- Tim
- DougieLawson
- Posts: 40512
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
- Contact: Website Twitter
Re: MagPi 47 - An Introduction to C - Page 62
What aromatic materials are you smoking? Have you even looked at cmake? Because the junk you're posting on here suggests you haven't even bothered to understand why it exists, what it does and why everyone should use it in preference to plain old arcane make.tito-t wrote:perhaps more for experts and professionals, and less for beginners and hobbyists?Now build a project that has six header files and seven modules used to create three programs. The complexity of Makefiles vs CMakeLists.txt rapidly spirals out of control. My first cmake project is just about at the limit for a sane and usable Makefile. It was absolutely trivial to build the fourteen line CMakeLists.txt for that.
As a project gets bigger the cost of creating masses of arcane junk for make versus a simple text file for cmake makes it a simple choice.
Why else would cmake exist?
Everyone, hobbyist, professional or other should use cmake and not dismiss it as "only for experts". It's clearly made for folks who don't want to be experts at crafting Makefiles. It makes the difference between a job that takes five minutes and one that makes an hour.
Any language using left-hand whitespace for syntax is ridiculous
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Re: MagPi 47 - An Introduction to C - Page 62
for a beginner, just having passed the basic MagPi tutorial, still not even able to make a LED blink by tutorial, poll a IMU sensor by I2C, or a GPS sensor by UART, why should he have to struggle with make or cmake as we have the Geany IDE?
I'm not rejecting to be told about make, makefile, or cmake, but then use Geney IDE for the next steps. Having to deal with terminals and command lines and scripts is incredibly annoying IMO.
OTOH, a "project that has six header files and seven modules used to create three program" is not supposed to be a beginner's task, or what do you think?
So keep it simple, stupid and lead the beginner to a quick sucess by handy and powerful IDEs , i.e. . Geany.
I'm not rejecting to be told about make, makefile, or cmake, but then use Geney IDE for the next steps. Having to deal with terminals and command lines and scripts is incredibly annoying IMO.
OTOH, a "project that has six header files and seven modules used to create three program" is not supposed to be a beginner's task, or what do you think?
So keep it simple, stupid and lead the beginner to a quick sucess by handy and powerful IDEs , i.e. . Geany.
Last edited by tito-t on Sat Nov 05, 2016 9:34 pm, edited 3 times in total.
- Tim
Re: MagPi 47 - An Introduction to C - Page 62
It goes with the demands for a tutorial on flashing a led in C... So I took the time to look at doing it with Gordon's wiringPi library. Clearly those demanding "we must have tutorials" have put zero effort in to finding out anything about C programming for themselves.DougieLawson wrote: What aromatic materials are you smoking? Have you even looked at cmake? Because the junk you're posting on here suggests you haven't even bothered to understand why it exists,
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson
Re: MagPi 47 - An Introduction to C - Page 62
not a knowlege about self-sufficient and aimless C code knowledge has to be the goal but being able to program applications, i.e. one would need knowlege about
Look how the Python tutorials are doing, that's exactly the way how a C tutorial should be designed.
Anything else can be read in 1 of the thousands C books which are already available, or already provided by websites like cplusplus.com
Of course you might wish to put another one on to this heap, Peter, I won't stop you.
But a Raspberry C tutorial for beginners to Raspberry and C (and perhaps if already having some experience using Python or Arduino C/C++) had to be hardware- and application-oriented. IMO people want to develop awesome things, and not do sort of abstract and aloof C masturbation.
Getting practice by programming practical useful tools and apps, one can increase the knowlege about C via lerarning by doing.C for GPIOs
C for UART, i2c and SPI, USB
C for HATs, kits, and sets
C for graphics
C for the Pi Cam or a USB cam
C for audio
C for game programming
Look how the Python tutorials are doing, that's exactly the way how a C tutorial should be designed.
Anything else can be read in 1 of the thousands C books which are already available, or already provided by websites like cplusplus.com
Of course you might wish to put another one on to this heap, Peter, I won't stop you.
But a Raspberry C tutorial for beginners to Raspberry and C (and perhaps if already having some experience using Python or Arduino C/C++) had to be hardware- and application-oriented. IMO people want to develop awesome things, and not do sort of abstract and aloof C masturbation.
- Tim
Re: MagPi 47 - An Introduction to C - Page 62
Fed up with this thread. People just getting grumpy.
So closing it.
There are thousands of C tutorials out there, some Pi related, many not. But the principles remain the same. We don't need to reinvent the wheel here. C the language and C the principles are the same whichever tutorial you use.
So closing it.
There are thousands of C tutorials out there, some Pi related, many not. But the principles remain the same. We don't need to reinvent the wheel here. C the language and C the principles are the same whichever tutorial you use.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.