Makefile:2: *** missing separator. Stop. How can i fix this I am new to Raylib for C++ - raylib

This is my code in Makefile
default:
g++ ../main.cpp -o test.exe -O2 -Wall -Wno-missing-braces -I ../include/ -L ../lib/
-
lraylib -lopengl32 -lgdi32 -lwinmm.
This is my source tree
C:.
│ main.cpp
│
└───build
| Makefile
│
├───include
│ raylib.h
│
└───lib
libraylib.a
I did cd build and mingw32-make but i get
Makefile:2: *** missing separator. Stop.

It looks like you've wrote your Makefile with spaces instead of tabs. Tabs are mandatory for makefile.
Take a look at this tutorial: https://makefiletutorial.com/

Related

Can't get -P and -O flags working together for wget command

System Information
wget version: 1.21.2
OS: Ubuntu 22.04.1 LTS (WSL 2)
Directory Structure:
home/
├─ test/
The Issue
I have encountered a specific issue with the -P and -O flags, where the -P flag argument is completely ignored when used with the -O flag. For example, I have the following wget command:
wget -P test/ -O test.doc https://file-examples.com/wp-content/uploads/2017/02/file-sample_100kB.doc
I am running this command from the home directory. Here are the expected & actual outcomes:
Expected Outcome:
home/
├─ test/
│ ├─ test.doc
Actual Outcome:
home/
├─ test/
test.doc
However, if I remove the -O flag from the command, I get the expected outcome, but of course, it won't be renamed.
wget -P test/ https://file-examples.com/wp-content/uploads/2017/02/file-sample_100kB.doc
Outcome:
home/
├─ test/
│ ├─ file-sample_100kB.doc
Conclusion
It seems like there is clearly something happening between the -P and -O flags, where I can't use both of them simultaneously for some reason.
I have also tried absolute paths, and that has not worked for me either.
You might use -O - to instruct wget to get file emitted to standard output and then redirect to file inside catalog consider following simple example
mkdir -p test # create test catalog if it does not exist
wget -O - https://www.example.com > test/example.html
ls test/*.html # shows test/example.html
However be warned that this will always download and overwrite target file.

How do you build a Linux Kernel for Android from the AOSP?

I've found that AOSP build.sh dist creates:
XML files:
./out/soong/.intermediates/kernel/configs/q/android-4.19/kernel_config_q_4.19/gen/conditional.xml
./out/soong/.intermediates/kernel/configs/q/android-4.19/kernel_config_q_4.19/matrix.xml
from the kernel config files:
kernel/configs/q/
├── android-4.14
│ ├── android-base-conditional.xml
│ ├── android-base.config
│ ├── Android.bp
│ ├── android-recommended-arm64.config
│ ├── android-recommended-arm.config
│ ├── android-recommended.config
│ └── android-recommended-x86.config
├── android-4.19
│ ├── android-base-conditional.xml
... ...
A whole copy of the Linux kernel directory in:
out/target/product/sdm660_64/obj/kernel/msm-4.14
This newly-created msm-4.14 includes a .config file which looks like normal kernel configuration.
How can I compile this kernel for aarch64?
When I use make it prompts to regenerate an x86_64 config file, as .config correctly contains Aarch64 settings.
Perhaps I'm trying the wrong thing, but mm in kernel/msm-4.14 ignored changes to kernel configs, and build.sh dist took hours.
I want to be able to change kernel configuration and source code, and build new kernels in just a few minutes, as I can for desktop machines.
How should I do this for Android?
This is the way to compile the kernel for your hardware and create the boot image :
$ cd <aosp_root_dir>
$ source ./build/envsetup.sh
$ lunch <product_name>-<build_variant>
# Example: lunch sdm660_64-userdebug
$ make bootimage -j4
# This compiles the kernel and copies it to
# <aosp_root_dir>/out/target/product/<product_name>/kernel,
# and creates boot image at
# <aosp_root_dir>/out/target/product/<product_name>/boot.img
If you still need to reduce the time it takes, then you have to find the individual commands that AOSP build system executes to compile the kernel and create the boot image.
You can find the commands from <aosp_root_dir>/out/verbose.log.gz. It is the compressed package that contains the verbose log of your last build.
So, build the boot image using make bootimage command first, then extract the verbose.log.gz package and you will get verbose.log file.
Inside that file, find a log line that contains the text : defconfig, and that would most probably be the command that AOSP build system executes to compile the kernel.
In my case, these 2 are the commands I found from verbose log, which is used to compile the kernel :
# make sdm660_defconfig
${ANDROID_BUILD_TOP}/prebuilts/build-tools/linux-x86/bin/make -j1 \
-C kernel/msm-4.4 \
O=${ANDROID_PRODUCT_OUT}/obj/kernel/msm-4.4 \
HOSTCC=${ANDROID_BUILD_TOP}/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/bin/x86_64-linux-gcc \
HOSTAR=${ANDROID_BUILD_TOP}/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/bin/x86_64-linux-ar \
HOSTLD=${ANDROID_BUILD_TOP}/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/bin/x86_64-linux-ld \
HOSTCFLAGS="-I/usr/include -I/usr/include/x86_64-linux-gnu -L/usr/lib -L/usr/lib/x86_64-linux-gnu" \
HOSTLDFLAGS="-L/usr/lib -L/usr/lib/x86_64-linux-gnu" \
ARCH=arm64 \
CROSS_COMPILE=${ANDROID_BUILD_TOP}/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android- \
sdm660_defconfig
# make
${ANDROID_BUILD_TOP}/prebuilts/build-tools/linux-x86/bin/make -j4 \
-C kernel/msm-4.4 \
O=${ANDROID_PRODUCT_OUT}/obj/kernel/msm-4.4 \
HOSTCC=${ANDROID_BUILD_TOP}/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/bin/x86_64-linux-gcc \
HOSTAR=${ANDROID_BUILD_TOP}/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/bin/x86_64-linux-ar \
HOSTLD=${ANDROID_BUILD_TOP}/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/bin/x86_64-linux-ld \
HOSTCFLAGS="-I/usr/include -I/usr/include/x86_64-linux-gnu -L/usr/lib -L/usr/lib/x86_64-linux-gnu" \
HOSTLDFLAGS="-L/usr/lib -L/usr/lib/x86_64-linux-gnu" \
ARCH=arm64 \
CROSS_COMPILE=${ANDROID_BUILD_TOP}/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-
After compiling the kernel using above commands, according to verbose log it copies the compile output to <aosp_root_dir>/out/target/product/<product_name>/kernel. That is the kernel files used to create the boot image.
cp "${ANDROID_PRODUCT_OUT}/obj/kernel/msm-4.4/arch/arm64/boot/Image.gz" \
"${ANDROID_PRODUCT_OUT}/kernel"
Finally, you can find the command that creates the boot image. According to my verbose log, following was the command :
${ANDROID_BUILD_TOP}/out/host/linux-x86/bin/mkbootimg \
--kernel ${ANDROID_PRODUCT_OUT}/kernel \
--ramdisk ${ANDROID_PRODUCT_OUT}/ramdisk-recovery.img \
--cmdline "console=ttyMSM0,115200,n8 androidboot.console=ttyMSM0 earlycon=msm_serial_dm,0xc170000 androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x37 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 sched_enable_hmp=1 sched_enable_power_aware=1 service_locator.enable=1 swiotlb=1 loop.max_part=7 buildvariant=eng veritykeyid=id:`openssl x509 -in build/target/product/security/verity.x509.pem -text | grep keyid | sed 's/://g' | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]' | sed 's/keyid//g'`" \
--base 0x00000000 \
--pagesize 4096 \
--os_version 10 \
--os_patch_level yyyy-mm-dd \
--header_version 1 \
--output ${ANDROID_PRODUCT_OUT}/boot.img
Like this, you can find the commands to compile the kernel for your hardware and create the boot image.

Cross compiling portAudio for Intel Edison

I am using the cross compile environemt from the Intel Site and have successfully compiled several other libraries using it (libsndfile, alsa, fftw) but when I try to compile portaudio it refuses to link to the proper directories. Here is the error I get:
if test -n " bindings/cpp" ; then for dir in " bindings/cpp"; do make -C $dir all; done ; fi
make[1]: Entering directory '/home/theslat/Downloads/portaudio/bindings/cpp'
Making all in lib
make[2]: Entering directory '/home/theslat/Downloads/portaudio/bindings/cpp/lib'
/bin/sh ../libtool --tag=CXX --mode=link i586-poky-linux-g++ -m32 -march=core2 -mtune=core2 -msse3 -mfpmath=sse -mstackrealign -fno-omit-frame-pointer --sysroot=/usr/edison/sysroots/core2-32-poky-linux -O2 -pipe -g -feliminate-unused-debug-types -version-info 0:12:0 -no-undefined -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -o libportaudiocpp.la -rpath /usr/local/lib BlockingStream.lo CallbackInterface.lo CallbackStream.lo CFunCallbackStream.lo CppFunCallbackStream.lo Device.lo DirectionSpecificStreamParameters.lo Exception.lo HostApi.lo InterfaceCallbackStream.lo MemFunCallbackStream.lo Stream.lo StreamParameters.lo System.lo SystemDeviceIterator.lo SystemHostApiIterator.lo ../../../lib/libportaudio.la
libtool: link: i586-poky-linux-g++ -m32 -march=core2 -mtune=core2 -msse3 -mfpmath=sse -mstackrealign -fno-omit-frame-pointer --sysroot=/usr/edison/sysroots/core2-32-poky-linux -fPIC -DPIC -shared -nostdlib /usr/edison/sysroots/core2-32-poky-linux/usr/lib/crti.o /usr/edison/sysroots/core2-32-poky-linux/usr/lib/i586-poky-linux/4.9.1/crtbeginS.o .libs/BlockingStream.o .libs/CallbackInterface.o .libs/CallbackStream.o .libs/CFunCallbackStream.o .libs/CppFunCallbackStream.o .libs/Device.o .libs/DirectionSpecificStreamParameters.o .libs/Exception.o .libs/HostApi.o .libs/InterfaceCallbackStream.o .libs/MemFunCallbackStream.o .libs/Stream.o .libs/StreamParameters.o .libs/System.o .libs/SystemDeviceIterator.o .libs/SystemHostApiIterator.o -Wl,-rpath -Wl,/home/theslat/Downloads/portaudio/lib/.libs -Wl,-rpath -Wl,/usr/local/lib ../../../lib/.libs/libportaudio.so -L/usr/edison/sysroots/x86_64-pokysdk-linux/usr/bin/i586-poky-linux/../../lib/i586-poky-linux/gcc/i586-poky-linux/4.9.1 -L/usr/edison/sysroots/x86_64-pokysdk-linux/usr/bin/i586-poky-linux/../../lib/i586-poky-linux/gcc -L/usr/edison/sysroots/core2-32-poky-linux/lib -L/usr/edison/sysroots/core2-32-poky-linux/usr/lib/i586-poky-linux/4.9.1 -L/usr/edison/sysroots/core2-32-poky-linux/usr/lib /usr/lib/libstdc++.so -lm -lc -lgcc_s /usr/edison/sysroots/core2-32-poky-linux/usr/lib/i586-poky-linux/4.9.1/crtendS.o /usr/edison/sysroots/core2-32-poky-linux/usr/lib/crtn.o -m32 -march=core2 -mtune=core2 -msse3 -mfpmath=sse -mstackrealign --sysroot=/usr/edison/sysroots/core2-32-poky-linux -O2 -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-soname -Wl,libportaudiocpp.so.0 -o .libs/libportaudiocpp.so.0.0.12
/usr/lib/libstdc++.so: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:311: libportaudiocpp.la] Error 1
make[2]: Leaving directory '/home/theslat/Downloads/portaudio/bindings/cpp/lib'
make[1]: *** [Makefile:333: all-recursive] Error 1
make[1]: Leaving directory '/home/theslat/Downloads/portaudio/bindings/cpp'
make: *** [Makefile:251: all-recursive] Error 2
It seems like it is trying to link against my computers normal libstdc++ and I don't know why. I have tried feedin configure a variaty of LDFLAG with the right directories and have reinstalled the toolchain and all my multilibs but no luck.
I also ran into this issue and the easiest way is to source the environment file again after doing a sudo su on the same command line and then do a make install.
Here are the steps I followed to cross compile portaudio for intel edison:
Download the cross compiler edison-toolchain-20150120-linux64.tar.bz2 and the script toolchain-20140724-linux64.sh from this link
Extract the toolchain, run the script (you can put it in your home directory somewhere if you wish) and set up the cross-compile environment
$ tar -xvf edison-toolchain-20150120-linux64.tar.bz2
$ chmod +x toolchain-20140724-linux64.sh
$ ./toolchain-20140724-linux64.sh
$ source /opt/poky-edison/1.6/environment-setup-core2-32-poky-linux
Check the environment on your shell:
$ echo $CC
$ i586-poky-linux-gcc -m32 -march=core2 -mtune=core2 -msse3 -mfpmath=sse -mstackrealign -fno-omit-frame-pointer --sysroot=/opt/poky-edison/1.6/sysroots/core2-32-poky-linux
Configure, compile and install portaudio:
$ ./configure
$ make
$ sudo su
# source /opt/poky-edison/1.6/environment-setup-core2-32-poky-linux
# make install
I am suprised that nobody grabbed this but also that it was difficult to find the proper answer anywhere else despite seeing many other people with similar (unresolved issues). The answer is frankly so simple I am embarrased that I overlooked it, but here it is so maybe someone else can find it.
make install required root privilages if the cross-compile SDK is in /opt or somewhere else you do not own. But... sudo does not preserve the environmental variable I had set up for the toolchain! Very simple, also su -m does not work the way I thought it did. Working solutions as follows:
Just install the SDK somewhere in your home directory. you now have write permissions, problem solved.
Run a single command as root while preserving the environment: su -m <yourUserName> -c '$CC main.cpp -lfoo -lbar ...'
The key in numer 2 is the username after -m, at least on my system leaving out the username there produced no errors but failed to preserve my environment.

Dependencies not being made in makefile

I've been trying to get the following makefile to work.
INCLUDE=Include/
LIBRARY=Lib/
CC=g++
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
LIBRARIES=-lGLEW -framework OpenGL -framework GLUT
else
LIBRARIES=-lGL -lglut -lGLEW
endif
SRC := $(shell find -name *.cpp | tr '\n' ' ')
all: release debug
.PHONY: init
init:
#mkdir -p build/release/object
#mkdir -p build/debug/object
debug: init
debug: CC = g++ -g
debug: BUILD_DIR = build/debug
debug: makegeneral
release: init
release: CC = g++
release: BUILD_DIR = build/release
release: makegeneral
makegeneral: OBJ = $(SRC:./src/%.cpp=$(BUILD_DIR)/object/%.o)
makegeneral: $(OBJ)
$(CC) -I$(INCLUDE) -L$(LIBRARY) $(OBJ) $(LIBRARIES) -o VoxPop
#rm -rf $(BUILD_DIR)/shaders
#mkdir -p $(BUILD_DIR)/shaders
#cp -r src/shaders/* $(BUILD_DIR)/shaders
$(BUILD_DIR)/object/%.o: src/%.cpp
$(CC) -I$(INCLUDE) -L$(LIBRARY) -o $# -c $<
.PHONY: clean
clean:
#rm build/debug/object/* build/release/object/*
Essentially, it sets a few variables specific to a debug build and a release build and then calls a common target, makegeneral. When I run make, I get the following output:
g++ -IInclude/ -LLib/ build/release/object/VoxPop.o build/release/object/Utils.o -lGL -lglut -lGLEW -o VoxPop
g++: error: build/release/object/VoxPop.o: No such file or directory
g++: error: build/release/object/Utils.o: No such file or directory
make: *** [makegeneral] Error 1
When I echo out SRC and OBJ at the beginning of makegeneral, they appear to be correct. It seems that the problem is with the dependencies for makegeneral, since the rule for compiling object files is never invoked and no there is no "No rule to make target..." message spit out.
For reference, this is what I get when I echo out SRC and OBJ at the beginning of makegeneral.
SRC: ./src/VoxPop.cpp ./src/Utils.cpp
OBJ: build/release/object/VoxPop.o build/release/object/Utils.o
BUILD_DIR is not set at the top level so expands to the empty string in the pattern rule. This is also the reason (I believe) for why make isn't failing on unbuildable prereqs. There aren't even any rules for how to do so (beyond the built-in rules). (Though I don't have access to a machine with make at the moment to test my theories.)
I'm also don't believe (though I can't test at the moment) that make will run your makegeneral target twice in this configuration to get you what you want. I believe you will only get it run once with whichever target make chooses to build first (the first listed I believe so in this case release).

Makefile warning: Warning: File `main.cpp' has modification time 2.1e+04 s in the future

I have a working Makefile, but there is a warning that I couldn't fix.
#Use the g++ compiler
CC = g++
# Compiler flags:
# -Wall (most warnings enabled)
# -g (for debugging with gdb)
CFLAGS = -Wall
# Executable name:
TARGET = deque_adt
all: main.o deque_adt.o deque_adt
$(TARGET): main.o deque_adt.o
$(CC) $(CFLAGS) main.o deque_adt.o -o $(TARGET)
main.o: main.cpp deque_adt.h
$(CC) $(CFLAGS) main.cpp -c
deque_adt.o: deque_adt.cpp deque_adt.h
$(CC) $(CFLAGS) deque_adt.cpp -c
clean:
rm *.o *~ $(TARGET)
error:
make: Warning: File `main.cpp' has modification time 2.1e+04 s in the future
g++ -Wall main.cpp -c
g++ -Wall deque_adt.cpp -c
g++ -Wall main.o deque_adt.o -o deque_adt
make: warning: Clock skew detected. Your build may be incomplete.
Can someone help me out to figure out the problem? I have tried to switch between the elements but it still gives the same warning.
To expand on Ben Voigt's answer:
find /your/dir -type f -exec touch {} +
will update the timestamp on all files in the directory. You can then make clean && make again.
check your computer time. I had the same problem and the root cause was my computer time was in the past - when I update it, it was work perfectly.
That message is usually an indication that some of your files have modification times later than the current system time.
Chech if your system time is in the past. Example:
$ date
If so You have several ways to fix this. the easier one is to install an ntp server:
apt install ntp
Or
yum install ntp
Or ...
Regarding of your operating system (Ubuntu, Centos, ...etc)
just set your system date:
example
date -s "2 OCT 2006 18:00:00"
I've faced the same issue, did the below approach on Ubuntu 20.04 and it worked for me.
touch main_.cpp
cp main.cpp main_.cpp
rm main.cpp
mv main_.cpp main.cpp

Resources