0

I have included a .h file and I seem to get an "undefined reference to error" I have added the appropriate flags so for example I added -lm for the flags for math.h but it still keeps on giving me this error when trying to compile. If anyone could help this would be great!

Using -lm and flags related to the file, changing the position of the flag

//In my makefile

GPPPARAMS =-lm -m32 -Iinclude -fno-use-cxa-atexit -nostdlib -fno-builtin -fno-rtti -fno-exceptions -fno-leading-underscore -Wno-write-strings -Wno-overflow -fpermissive -lncurses ASPARAMS = --32 LDPARAMS = -melf_i386

//In the terminal

ld -melf_i386 -T linker.ld -o mykernel.bin obj/loader.o obj/gdt.o obj/drivers/driver.o obj/hardwarecommunication/port.o obj/hardwarecommunication/interruptstubs.o obj/hardwarecommunication/interrupts.o obj/hardwarecommunication/pci.o obj/drivers/game.o obj/drivers/mouse.o obj/drivers/controller.o obj/drivers/vga.o obj/drivers/ata.o obj/drivers/pit.o obj/drivers/speaker.o obj/gui/widget.o obj/gui/window.o obj/gui/desktop.o obj/gui/3d_enviroment.o obj/models/models.o obj/kernel.o obj/drivers/game.o: In function gathrillo::drivers::GameDriver::HandleInterrupt(unsigned int)': game.cpp:(.text+0xf38): undefined reference tobeep' Makefile:38: recipe for target 'mykernel.bin' failed make: *** [mykernel.bin] Error 1

I expected to compile the external libraries fine but the compiler does not seem to cooperate

  • That's not the way it works. If you're using code in an external library, you need to tell the LINKER where the libraries are, and specify what libraries get linked in. A compiler (or an IDE) doesn't magically go away to find and then build all external libraries your code needs. You have to do the work of ensuring those libraries are available, ensure they are built, and point the linker at them – Peter Jun 09 '19 at 02:14
  • ok thank you I will figure out how to add it to the linker – Geekume Jun 09 '19 at 14:46

0 Answers0