embeddedartistry / libmemory

Embedded systems memory management library. Implementations for malloc(), free(), and other useful memory management functions
https://embeddedartistry.com
MIT License
216 stars 44 forks source link

"fatal error: memory.h: No such file or directory" when compiling. #90

Closed ptrk8 closed 1 year ago

ptrk8 commented 1 year ago

I was trying to cross-compile this library using the following make command:

make CROSS=arm:cortex-a53

However, I got the following compiler error:

FAILED: src/libmemory.a.p/malloc_addblock_init_assert.c.o
arm-none-eabi-gcc -Isrc/libmemory.a.p -Isrc/ -I../src -Iinclude -I../include -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Wpedantic -std=c11 -O2 -fdiagnostics-show-option -ffunction-sections -fdata-sections -fdevirtualize -Wno-unknown-pragmas -Wno-padded -Wfloat-equal -Wconversion -Wlogical-op -Wundef -Wredundant-decls -Wshadow -Wstrict-overflow=2 -Wwrite-strings -Wpointer-arith -Wcast-qual -Wformat=2 -Wmissing-include-dirs -Wcast-align -Wswitch-enum -Wsign-conversion -Wdisabled-optimization -Winvalid-pch -Wmissing-declarations -Wdouble-promotion -Wshadow -Wtrampolines -Wvector-operation-performance -Wshift-overflow=2 -Wnull-dereference -Wduplicated-cond -Wshift-overflow=2 -Wnull-dereference -Wduplicated-cond -Wno-pedantic -mcpu=cortex-a53 -mfloat-abi=hard -mabi=aapcs -fPIC -MD -MQ src/libmemory.a.p/malloc_addblock_init_assert.c.o -MF src/libmemory.a.p/malloc_addblock_init_assert.c.o.d -o src/libmemory.a.p/malloc_addblock_init_assert.c.o -c ../src/malloc_addblock_init_assert.c
../src/malloc_addblock_init_assert.c:8:20: fatal error: memory.h: No such file or directory
 #include <memory.h>

To fix this, I uncommented all instances of the following includes and compiled without errors.

 #include <memory.h>

My main question is: what is the purpose of this includes?

ptrk8 commented 1 year ago

Nvm, I think #include <memory.h> is referring to this header file in this libc implementation.

phillipjohnston commented 1 year ago

It should be a standard header. What libc are you using?

phillipjohnston commented 1 year ago

In any case it should generally work with any libc so I’ll get that include updated later today.

phillipjohnston commented 1 year ago

After review, I agree that the memory.h/string.h header is not needed and those can be safely removed. It will happen in the repo.

ptrk8 commented 1 year ago

Thanks for getting back so promptly!

It should be a standard header. What libc are you using?

After looking into it, I realised that make CROSS=arm:cortex-a53 uses arm-none-eabi-gcc, which uses Newlib as its libc and not glibc (which I assumed).

After review, I agree that the memory.h/string.h header is not needed and those can be safely removed. It will happen in the repo.

Yes, sounds good! 👍