[SOLVED] clang attach own library
Posted: Thu Nov 10, 2022 5:20 am
Hey! I'm trying to bind a library to a program, but clang insistently does not see it or doesn't recognize it.
Can someone give me a hint?
clang-14: warning: -lfont: 'linker' input unused [-Wunused-command-line-argument]
clang-14: warning: argument unused during compilation: '-L.' [-Wunused-command-line-argument]
ld: main.o: in function `entry':
main.c:(.text+0x6): undefined reference to `font_char_length'
font.h
font.c
main.c
make.sh
Can someone give me a hint?
clang-14: warning: -lfont: 'linker' input unused [-Wunused-command-line-argument]
clang-14: warning: argument unused during compilation: '-L.' [-Wunused-command-line-argument]
ld: main.o: in function `entry':
main.c:(.text+0x6): undefined reference to `font_char_length'
font.h
Code: Select all
extern uint8_t font_char_length( uint8_t character );
Code: Select all
#include "stdint.h"
#include "stddef.h"
uint8_t font_char_length( uint8_t character ) {
return character + 1;
}
Code: Select all
#include "stdint.h"
#include "stddef.h"
#include "font.h"
void entry() {
uint8_t length = font_char_length( 0x30 );
}
Code: Select all
CFLAGS="-Ofast -march=x86-64 -nostdlib -fomit-frame-pointer -fno-builtin -fno-stack-protector -m64 -mno-red-zone -fno-asynchronous-unwind-tables"
LDFLAGS="-nostdlib -zmax-page-size=0x1000 -static -no-dynamic-linker"
clang -c -fpic font.c ${CFLAGS}
clang -shared -o libfont.so font.o ${CFLAGS}
clang -L. -c main.c -o main.o -lfont ${CFLAGS}
ld main.o -o main -T linker.software ${LDFLAGS}