How can I use mingw to build mkspiffs? - c++

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?

Related

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

Strange libtool behaviour at link time

I'm currently trying to get Autotools to play nice with the D programming language. So far, I've had success with everything except dynamic libraries. I've written a skeleton project aiming to do this, but for some reason, after configure && make, I get the following error:
gdmd -m64 -inline -noboundscheck -g -property -w -wi -O -c -fPIC -ofsrc/foo.lo src/foo.d
/bin/sh ./libtool --tag=CC --mode=link -g -O2 -version-info 0:1:0 -o libfoo-0.1.la -rpath /usr/local/lib src/foo.lo
Usage: /home/koz/Documents/Programming/D/d-skeleton-lib/libtool [OPTION]... [MODE-ARG]...
Try 'libtool --help' for more information.
libtool: error: unrecognised option: '-g'
Makefile:435: recipe for target 'libfoo-0.1.la' failed
make: *** [libfoo-0.1.la] Error 1
I'm not sure why those flags are being passed to libtool at link time - could someone please help me understand what's going on and how to avoid this behaviour?

How to build Qt 5.1 for QNX target (arm)

new update
I think I should edit the title now.
To make sure I got a clean environment, I
download qt5.1.1 src code from qt-prject.
export QNX_TARGET, QNX_HOST, AND add QNX_HOST into PATH.
then Run the script
./configure -opensource -confirm-license -xplatform qnx-armv7le-qcc -v
so in here, -opensource -confirm-license just avoid the Q&A -v is to show full message.
a lot of error message.
Creating qmake...
make: Nothing to be done for `first'.
Running configuration tests...
Determining architecture... ()
qcc -Vgcc_ntoarmv7le -c -Wno-psabi -lang-c++ -g -Wall -W -fPIE -DQT_NO_CLIPBOARD -I../../mkspecs/qnx-armv7le-qcc -I. -I/opt/qnx650/target/qnx6/usr/include -I/opt/qnx650/target/qnx6/usr/include/freetype2 -o arch.o arch.cpp
Unable to determine architecture!
Could not determine the target architecture!
Turn on verbose messaging (-v) to see the final report.
Determining architecture... ()
g++ -c -pipe -g -Wall -W -fPIE -I../../mkspecs/linux-g++ -I. -o arch.o arch.cpp
g++ -o arch arch.o { test -n "" && DESTDIR="" || DESTDIR=.; } && test $(gdb --version | sed -e 's,[^0-9]\+\([0-9]\)\.\([0-9]\).*,\1\2,;q') -gt 72 && gdb --nx --batch --quiet -ex 'set confirm off' -ex "save gdb-index $DESTDIR" -ex quit 'arch' && test -f arch.gdb-index && objcopy --add-section '.gdb_index=arch.gdb-index' --set-section-flags '.gdb_index=readonly' 'arch' 'arch' && rm -f arch.gdb-index || true
Found architecture in binary
CFG_HOST_ARCH="x86_64"
CFG_HOST_CPUFEATURES=" mmx sse sse2"
System architecture: 'unknown'
Host architecture: 'x86_64'
C++11 auto-detection... ()
qcc -Vgcc_ntoarmv7le -c -Wno-psabi -lang-c++ -O2 -Wc,-std=gnu++0x -Wall -W -fPIE-DQT_NO_CLIPBOARD -I../../../mkspecs/qnx-armv7le-qcc -I. -I/opt/qnx650/target/qnx6/usr/include -I/opt/qnx650/target/qnx6/usr/include/freetype2 -o c++11.o c++11.cpp
C++11 disabled.
floatmath auto-detection... ()
qcc -Vgcc_ntoarmv7le -c -Wno-psabi -lang-c++ -O2 -Wall -W -fPIE -DQT_NO_CLIPBOARD-I../../../mkspecs/qnx-armv7le-qcc -I. -I/opt/qnx650/target/qnx6/usr/include -I/opt/qnx650/target/qnx6/usr/include/freetype2 -o floatmath.o floatmath.cpp
qcc -Vgcc_ntoarmv7le -c -Wno-psabi -lang-c++ -O2 -Wall -W -fPIE -DQT_NO_CLIPBOARD -I../../../mkspecs/qnx-armv7le-qcc -I. -I/opt/qnx650/target/qnx6/usr/include -I/opt/qnx650/target/qnx6/usr/include/freetype2 -o freetype.o freetype.cpp
FreeType disabled.
STL auto-detection... ()
qcc -Vgcc_ntoarmv7le -c -Wno-psabi -lang-c++ -O2 -Wall -W -fPIE -DQT_NO_CLIPBOARD -I../../../mkspecs/qnx-armv7le-qcc -I. -I/opt/qnx650/target/qnx6/usr/include -I/opt/qnx650/target/qnx6/usr/include/freetype2 -o stltest.o stltest.cpp
STL disabled.
STL functionality check failed! Cannot build Qt with this STL library.
Turn on verbose messaging (-v) to /home/pasadeveloper/qt-everywhere-opensourcesrc-5.1.1/qtbase/configure to see the final report.
UPDATE:
I am working on QNX for ARM, target is an arm platform device.
Thing is getting weird. in Env Var, I put
$QNX_CONFIGURATION=/etc/qnx
$QNX_JAVAHOME=/opt/qnx650/_jvm
$QNX_TARGET=/opt/qnx650/target/qnx6
$QNX_HOST=/opt/qnx650/host/linux/x86
but when I do qmake qmake.conf mkspecs/qnx-armv7le-qcc folder
it returns an error message Project ERROR: QNX_TARGET environment variable not set
Have no clue what is going on now.
not just qmake qmake.conf
I try to build qt 5.1.2 at another host, ubuntu 12.04-64bit.
also get the same error message. Project ERROR: QNX_TARGET environment variable not set
I was working at Qt development under linux(FYI Ubuntu 12.04 -64bits), but I need to compile this program to binary for QNX.
I install QNX MOmentics IDE which provide QNX-gcc for me.
but I can't find the qmake-qnx.
Under the QT/gcc_64/mkspecs/qnx-armv7le-qcc, there is a file call qmake.conf. I guess this is where I can generate my qmake-qnx. after I run qmake -o Makefile qmake.conf, there is a Makefile generated.
However, when I run make, error occured.
qcc -Vgcc_ntoarmv7le -lang-c++ -Wl,-rpath-link,/opt/qnx650/target/qnx6/armle-v7/lib -Wl,-rpath-link,/opt/qnx650/target/qnx6/armle-v7/usr/lib -Wl,-O1 -Wl,-O1 -Wl,-rpath,/home/pasadeveloper/Qt5.1.0/5.1.0/gcc_64 -Wl,-rpath,/home/pasadeveloper/Qt5.1.0/5.1.0/gcc_64/lib -o qmake -L/opt/qnx650/target/qnx6/armle-v7/lib -L/opt/qnx650/target/qnx6/armle-v7/usr/lib -lm -L/home/pasadeveloper/Qt5.1.0//5.1.0/gcc_64/lib -lQt5Gui -lQt5Core -lGL -lpthread
cc: no files to process
make: *** [qmake] Error 1
pasadeveloper#ubuntu:~/Qt5.1.0/5.1.0/gcc_64/mkspecs/qnx-armv7le-qcc$
You do not "generate" your qmake-qnx like that. You are supposed to use the native qmake for generating proper makefiles for your target to aid the cross-compilation. Also, running qmake qmake.conf in the relevant mkspecs folder is wrong because that is not a project file as you may think.
When building Qt itself for instance, you should be using the proper mkspecs files for the target in which case, it is the one you also mentioned above if it is built for that particular arm qnx variant, called qnx-armv7le-qcc.
Here is the exact command you need to run after downloading the relevant Qt sources, like 5.1.1:
./configure -opensource -confirm-license -xplatform qnx-armv7le-qcc -v
For this QNX version, the bottom line is, if you do not have SP1 and libscreen, it will not work. The QPA plugin would link against it. This library provides the API to the graphics server on newer QNX variants. You need to talk to your QNX representatives.
Here you can find further information about the topic.
$QNX_TARGET=/opt/qnx650/target/qnx6
is probably not doing what you want. In shell scripts, you don't put a "$" in front of a variable when you are defining the variable, only when you access the variable:
X=hello
echo $X

jenkins does not recognize the errors when building the cpp code

I am using jenkins for my CI server but i have problems when i want to build the project because jenkins does not recognize the compilation errors.This is my problem:
creating objects directory obj
g++ -I../src -I third-party/cppunit-1.12.1/include -fPIC -g -Wall -c booktest.cpp -o obj/booktest.o
g++ -I../src -I third-party/cppunit-1.12.1/include -fPIC -g -Wall -c reader/bookreadertest.cpp -o obj/reader/bookreadertest.o
g++ -I../src -I third-party/cppunit-1.12.1/include -fPIC -g -Wall -c indexer/indexertest.cpp -o obj/indexer/indexertest.o
indexer/indexertest.cpp: In constructor ‘IndexerTest::IndexerTest()’:
indexer/indexertest.cpp:17:12: error: ‘failMethod’ was not declared in this scope
make: *** [obj/indexer/indexertest.o] Error 1
creating objects directory obj
g++ -I ../src -fPIC -g -Wall -c src/main.cpp -o obj/src/main.o
g++ -o oreallybooks -fPIC -g -Wall obj/src/main.o -L/user/local/lib -L../src/lib -loreally -lm
Finished: SUCCESS
I am using bash files to build and clean the cpp project
I "execute shell" for "build steps" in jenkins and this is the command:
/var/lib/jenkins/jobs/OreallyBooks/workspace/buildProject
"buildProject" is bash file and contains:
!/bin/bash
cd src;
make;
cd ../test;
make;
cd ../ui
make;
Someone can help me please? thanks all
If anything other than the final make fails then the bash script will ignore the error.
You need to set the script to fail on first error
#!/bin/bash -e
Stop on first error

Android: Statically link against libstdc++

my program compiles nicely for Android, however when I try to copy it to the Android emulator, it gives the following error:
knight666#Katja-Linux /media/Data/Shared/Galaxians $ acpy Galaxians.android
Filename: 'Galaxians.android'
819 KB/s (420657 bytes in 0.501s)
link_image[1638]: 825 could not load needed library 'libstdc++.so.6' for '/system/sbin/Galaxians.android' (load_library[984]: Library 'libstdc++.so.6' not found)CANNOT LINK EXECUTABLE
acpy is a small script I wrote that does the following:
#!/bin/sh
FILEPATH=`dirname $1`
FILENAME=`basename $1 .c`
echo "Filename: '$FILENAME'"
adb push $FILEPATH/$FILENAME /system/sbin/$FILENAME
adb shell chmod 777 /system/sbin/$FILENAME
adb shell /system/sbin/$FILENAME
Here is how I build my application:
oem#androiddev /media/YoghurtGum/Tests/Galaxians $ sudo make
arm-none-linux-gnueabi-g++ -static-libgcc -g -Wall -Werror -O2 -w -I ../../YoghurtGum/src/GLES -I ../../YoghurtGum/src -c src/Alien.cpp -o intermediate/Alien.o
arm-none-linux-gnueabi-g++ -static-libgcc -g -Wall -Werror -O2 -w -I ../../YoghurtGum/src/GLES -I ../../YoghurtGum/src -c src/Bullet.cpp -o intermediate/Bullet.o
arm-none-linux-gnueabi-g++ -static-libgcc -g -Wall -Werror -O2 -w -I ../../YoghurtGum/src/GLES -I ../../YoghurtGum/src -c src/Game.cpp -o intermediate/Game.o
arm-none-linux-gnueabi-g++ -static-libgcc -g -Wall -Werror -O2 -w -I ../../YoghurtGum/src/GLES -I ../../YoghurtGum/src -c src/Player.cpp -o intermediate/Player.o
arm-none-linux-gnueabi-gcc
-Wl,--entry=main,
-dynamic-linker=/system/bin/linker,
-rpath-link=/home/oem/android-ndk-r3/build/platforms/android-5/arch-arm/usr/lib,
-rpath=../../YoghurtGum/lib/Android,
-L/home/oem/android-ndk-r3/build/platforms/android-5/arch-arm/usr/lib
-nostdlib
-lstdc++
intermediate/Alien.o
intermediate/Bullet.o
intermediate/Game.o
intermediate/Player.o
../../YoghurtGum/lib/Android/libstdc++.a
../../YoghurtGum/bin/YoghurtGum.a
-o bin/Galaxians.android
Line breaks are only for clarity, none exist in the actual output.
YoghurtGum is my game library that already statically and dynamically links to libstdc++.
When I remove lstdc++, the program doesn't compile because it can't find the library.
Is there a way to link to stdlibc++ statically or link the application to the correct dynamic library in the emulator?
Thanks in advance.
There is a modification of the ndk with support for exceptions, RTTI and stdlibc++.
http://www.crystax.net/android/ndk-r3.php
The other alternative involves porting just what you need, by hand... eek!