make is truncating some compile commands under cygwin - c++

I'm working on an electricity meter with a large existing code base and trying to introduce some automated testing. I've written a python script that decodes a Keil project file for ARM and generates a makefile. So most of the defines and include paths are actually defined in the keil project file. Well actually quite a few defines are added by me.
Said makefile is wonderful except it strips the first few characters from some compile commands. The two lines below are examples of a good compile command, and a bad one. It's easy to see "g++ -" has been stripped from the beginning of the compile command.
It's always those 5 characters. The one hint I have is that the files that fail have relatively long paths.
Defining SHELL=/bin/bash changes nothing.
g++ -c ../Project/External/HAL/src/HWRNG.cpp -o obj/HWRNG.o -D IO="" -D __I="" -D __packed="" -D ubyte8="unsigned long long" -std=c++11 -w -fpermissive -D __GNUC -D __USE_C99_MATH -D LOGICAL_NAME_REFERENCING -D EOSAL_NAMESPACE=CosemMeter -D USE_RTX -D STM32F412xG -D USE_STDPERIPH_DRIVER -D HSE_VALUE=24000000 -D DEBUG_UART -D OLD_MCOR -D ENABLE_LTE_MODEM -I ../trace -I ../trace/EOSAL/src -I patch/include -I ../Project -I ../Project/Hardware -I ../Project/External/CosemServerLib -I ../Project/External/CosemServerLib/Project -I ../Project/External/CosemServerLib/External -I ../Project/External/HAL/inc -I ../Project/External/HAL/STM/32F4xx/drivers/inc -I ../Project/External/STM32F4xx/CMSIS/Device/ST/STM32F4xx/Include -I ../Project/External/STM32F4xx/CMSIS/Include -I ../Project/External/STM32F4xx/STM32F4xx_StdPeriph_Driver/inc -I ../Project/lib -I ../Project/lib/RTX/inc -I ../Project/lib/RTX/inc/RTL -I ../Project/lib/Mocana/src -I ../Project/Middlewares/Segger/USBH -I ../Project/Middlewares/Segger/Inc -I ../Project/SeggerCfg -I ../Project/LTE/inc
c ../Project/External/HAL/STM/32F4xx/drivers/src/EXTI_Driver.c -o obj/EXTI_Driver.o -D __IO="" -D __I="" -D __packed="" -D ubyte8="unsigned long long" -D __USE_C99_MATH -D LOGICAL_NAME_REFERENCING -D EOSAL_NAMESPACE=CosemMeter -D USE_RTX -D STM32F412xG -D USE_STDPERIPH_DRIVER -D HSE_VALUE=24000000 -D DEBUG_UART -D OLD_MCOR -D ENABLE_LTE_MODEM -I ../trace -I ../trace/EOSAL/src -I patch/include -I ../Project -I ../Project/Hardware -I ../Project/External/CosemServerLib -I ../Project/External/CosemServerLib/Project -I ../Project/External/CosemServerLib/External -I ../Project/External/HAL/inc -I ../Project/External/HAL/STM/32F4xx/drivers/inc -I ../Project/External/STM32F4xx/CMSIS/Device/ST/STM32F4xx/Include -I ../Project/External/STM32F4xx/CMSIS/Include -I ../Project/External/STM32F4xx/STM32F4xx_StdPeriph_Driver/inc -I ../Project/lib -I ../Project/lib/RTX/inc -I ../Project/lib/RTX/inc/RTL -I ../Project/lib/Mocana/src -I ../Project/Middlewares/Segger/USBH -I ../Project/Middlewares/Segger/Inc -I ../Project/SeggerCfg -I ../Project/LTE/inc
/bin/sh: c: command not found
make: [Makefile:167: obj/EXTI_Driver.o] Error 127 (ignored)

I was on the road for the last few weeks and showed my problem to a colleague yesterday. He immediately noticed it was the C compiles so behaving and the C++ were behaving properly. I had misdefined the CC symbol for C comiles.

Related

How to stream screen recording with mjpg-streamer?

How to stream screen recording with mjpg-streamer which specified in below
https://github.com/jacksonliam/mjpg-streamer
In examples shows recording webcam or file, but I want to record current desktop to stream
./mjpg_streamer -i "./input_uvc.so -f -1 -r 320x240 -d /dev/video0 -n" -o "./output_http.so -w ./www -p 8080"
./mjpg_streamer -i "./input_opencv_file.so -f 60 -d cam0_0001.m4v" -o "./output_http.so -w ./www -p 8080"

Trouble building GLEW on Windows using MinGW

I'm trying to build GLEW 2.1.0 on Windows (8.1) using MinGW and have been struggling for a while now.
I tried to follow the instructions for "MSYS/Mingw" on the GLEW GitHub page but when running mingw32-make, I only got a couple errors about missing commands (test and config) as well as the following: Makefile:40: *** "Platform '' not supported". Stop.
Under "Requirements" it says that bash is needed, so I installed git, because that apparently comes with a version of bash. Running mingw32-make (in the directory that all the GLEW files and folders are in) using Git Bash results in a long list of warnings and "undefined reference"s. The latter come from the linker as far as I know, but I have no idea what could cause them. As it's so much text, I'll only include the last few lines here:
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: tmp/mingw/default/shared/glewinfo.o:glewinfo.c:(.text.startup+0x181b): undefined reference to `_imp___iob'
collect2.exe: error: ld returned 1 exit status
Makefile:181: recipe for target 'bin/glewinfo.exe' failed
mingw32-make: *** [bin/glewinfo.exe] Error 1
mingw32-make install has the following output:
$ mingw32-make install
install -d -m 0755 "/usr/include/GL"
install -m 0644 include/GL/wglew.h "/usr/include/GL/"
install -m 0644 include/GL/glew.h "/usr/include/GL/"
install -m 0644 include/GL/glxew.h "/usr/include/GL/"
sed \
-e "s|#prefix#|/usr|g" \
-e "s|#libdir#|/usr/lib|g" \
-e "s|#exec_prefix#|/usr/bin|g" \
-e "s|#includedir#|/usr/include/GL|g" \
-e "s|#version#|2.1.0|g" \
-e "s|#cflags#||g" \
-e "s|#libname#|glew32|g" \
-e "s|#requireslib#|glu|g" \
< glew.pc.in > glew.pc
install -d -m 0755 "/usr/lib"
install -d -m 0755 "/usr/bin"
install -m 0755 lib/glew32.dll "/usr/bin/"
install -m 0644 lib/libglew32.dll.a "/usr/lib/"
install -m 0644 lib/libglew32.a "/usr/lib/"
install -d -m 0755 "/usr/lib/pkgconfig"
install -d -m 0755 "/usr/lib/pkgconfig"
install -m 0644 glew.pc "/usr/lib/pkgconfig/"
And mingw32-make install.all produces another long list of undefined references and the same error that came from running mingw32-make. The first lines however are (about) the same as the result of running mingw32-make install.
As expected with all of the errors, running these commands didn't produce a binary file. I guess it could have something to do with me not having make, which is one of the requirements listed on the GitHub page. However I don't understand how I should install make on Windows and why it is even needed when the instructions say to use mingw32-make.
I've also tried some of the suggestions made in this thread, but that doesn't seem to have worked either.
What could be the problem and what can I do to successfully compile GLEW?
I could never build it with the instructions I found around the internet, so here's how I build glew (using https://downloads.sourceforge.net/project/glew/glew/2.2.0/glew-2.2.0.tgz) under MSYS2 with MinGW-w64:
# change the line below to your desired install path
INSTALLPREFIX=/usr/local
VERSION=2.2.0
gcc -O2 -Wall -W -Iinclude -DGLEW_BUILD -o src/glew.o -c src/glew.c &&
gcc -fno-builtin -fno-stack-protector -shared -s -Wl,-soname,libglew32.dll -Wl,--out-implib,lib/libglew32.dll.a -o lib/glew32.dll src/glew.o -Wl,--as-needed -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32 -nostdlib &&
ar cr lib/libglew32.a src/glew.o &&
gcc -DGLEW_MX -O2 -Wall -W -Iinclude -DGLEW_BUILD -o src/glew.mx.o -c src/glew.c &&
gcc -fno-builtin -fno-stack-protector -shared -s -Wl,-soname,libglew32mx.dll -Wl,--out-implib,lib/libglew32mx.dll.a -o lib/glew32mx.dll src/glew.mx.o -Wl,--as-needed -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32 -nostdlib &&
ar cr lib/libglew32mx.a src/glew.mx.o &&
gcc -O2 -c -Iinclude -o src/glewinfo.o src/glewinfo.c &&
gcc -s -o src/glewinfo.exe src/glewinfo.o lib/libglew32.dll.a -Wl,--as-needed -lgdi32 -lopengl32 &&
gcc -O2 -c -Iinclude -o src/visualinfo.o src/visualinfo.c &&
gcc -s -o src/visualinfo.exe src/visualinfo.o lib/libglew32.dll.a -Wl,--as-needed -lgdi32 -lopengl32 -lglu32 &&
sed -e "s?#prefix#?$INSTALLPREFIX?; s?#libdir#?\$\{prefix\}/lib?; s?#version#?$VERSION?; s?#requireslib#?glu?; s?#cflags#??; s?#libname#?glew32?" glew.pc.in > glew.pc &&
sed -e "s?#prefix#?$INSTALLPREFIX?; s?#libdir#?\$\{prefix\}/lib?; s?#version#?$VERSION?; s?#requireslib#?glu?; s?#cflags#?-DGLEW_MX?; s?#libname#?glew32mx?" glew.pc.in > glewmx.pc &&
echo Installing... &&
mkdir -p $INSTALLPREFIX/include $INSTALLPREFIX/lib/pkgconfig $INSTALLPREFIX/bin $INSTALLPREFIX/cmake &&
cp -rf include/GL $INSTALLPREFIX/include/ &&
cp -f lib/*.a $INSTALLPREFIX/lib/ &&
cp -f *.pc $INSTALLPREFIX/lib/pkgconfig/ &&
cp -f lib/*.dll src/*.exe $INSTALLPREFIX/bin/ &&
cp -f build/cmake/*.cmake $INSTALLPREFIX/cmake/ &&
echo Success

How can I use mingw to build mkspiffs?

I'm trying to build mkspiffs for windows. It's a c/c++ project. I installed mingw, and added it to my path.
The README.md says to run
$ git submodule update --init
$ make dist
The make dist command gives me the following output:
File not found - *.c
cc -std=gnu99 -Os -Wall -mno-ms-bitfields -Itclap -Iinclude -Ispiffs/src -I. -D VERSION=\"0.2.3-6-g983970e\" -D SPIFFS_VERSION=\"0.3.7-5-gf5e26c4\" -D BUILD_CONFIG=\"\" -D BUILD_CONFIG_NAME=\"-generic\" -D __NO_INLINE__ -c -o spiffs/src/spiffs_cache.o spiffs/src/spiffs_cache.c
process_begin: CreateProcess(NULL, cc -std=gnu99 -Os -Wall -mno-ms-bitfields -Itclap -Iinclude -Ispiffs/src -I. -D VERSION=\"0.2.3-6-g983970e\" -D SPIFFS_VERSION=\"0.3.7-5-gf5e26c4\" -D BUILD_CONFIG=\"\" -D BUILD_CONFIG_NAME=\"-generic\" -D __NO_INLINE__ -c -o spiffs/src/spiffs_cache.o spiffs/src/spiffs_cache.c, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [spiffs/src/spiffs_cache.o] Error 2
I'm using mingw64.
C:\Users\peterkapteyn>where gcc
C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\gcc.exe
I am a novice when it comes to building things from source/using makefiles and that sort of thing. Can anyone offer some insight into what's going on?

Why is grep unable to match on string "-n" and "-e" in bash?

Long story short, narrowed my problem down to a one-liner:
for a in {a..z}; do echo "-$a" | grep "\-$a"; done
This prints all letters but -e and -n.
Looks like Linux version, bash version, flags to grep (-P, -E) etc do not matter!
Tested environments:
GNU bash, version 3.2.57(2)-release (x86_64-suse-linux-gnu) on SUSE Linux Enterprise Server 11 SP4
GNU bash, version 4.4.12(3)-release (x86_64-unknown-cygwin) on Cygwin (base-cygwin 3.8-1; cygwin32 2.10.0-1)
rextester (bash online compiler; GNU bash 4.3.46)
Why are not -e and -n printed?
(Removing the dashes in the code also removes the problem)
Problem is that -e, -n are valid echo options and echo is not printing them.
Moreover you should use -- in grep to separate options and pattern. Suggest you to use -F option in grep as well for fixed string search.
You may use:
for a in {a..z}; do grep -F -- "-$a" <<< "-$a"; done
-a
-b
-c
-d
-e
-f
-g
-h
-i
-j
-k
-l
-m
-n
-o
-p
-q
-r
-s
-t
-u
-v
-w
-x
-y
-z
Note that you may also use printf instead of echo:
for a in {a..z}; do printf -- '-%s\n' "$a" | grep -F -- "-$a"; done

"ifort: no match" error in csh script

I'm trying to compile a program called ZEUS and I am following the included instructions exactly but I came across the following error.
The instructions asked me to type csh -v namelist.s in the folder containing namelist.s. This is a fairly large assembly file which invokes another file given in the source files called bldlibo which is the csh file mentioned in the title. The contents of this file are:
#==== SCRIPT TO BUILD AN OBJECT LIBRARY FROM A FORTRAN SOURCE FILE====#
#
# Syntax: bldlibo <library name> <source code>
# eg: bldlibo namelist.a namelist.f
#
rm -rf bldlibo.dir
mkdir bldlibo.dir
cp $2 bldlibo.dir
cd bldlibo.dir
fsplit $2 >& /dev/null
rm $2
#
# When -fast option is used, this leads to the __vsincos_ unsatisfied
# external errors when zeus is compiled with -g option. Thus, use -O4
# instead.
#
ifort -c -O4 *.f
#f77 -c -g -C -ftrap=common *.f
ar rv $1 *.o >& /dev/null
ranlib $1
cd ..
mv bldlibo.dir/$1 .
rm -r bldlibo.dir
When I run csh -v namelist.s it begins to run bldlibo and works fine up until ifort is invoked at which point it says ifort: no match. I have tried adding #!/bin/csh at the start and also source .../ifortvars.csh but that didn't work.
Can anybody help me, sorry if I haven't explained it well enough.