Frage

I know there have been a lot of such topics, but I didn't found the answer, really. There's nothing that isn't working.

I am compiling file

gcc   -std=c99 -Lmem xx.c

in the file there is

#include "include/memory.h"
#include <stdlib.h>


void main(){
    meminit(100);
}

and in memory.h

#include "private.h"
#pragma once
MEMI * memdiag();

void meminit(int block_number);

void * memalloc(int desired_size);

void memfree(void * ptr);

the folder contains libmem.a, and headers, yet I'm getting error

/tmp/ccSJ4trm.o: In function `main':
xx.c:(.text+0xa): undefined reference to `meminit'
collect2: error: ld returned 1 exit status

I would be very grateful if You helped me, tomorrow I have to hand in the project.

War es hilfreich?

Lösung

You need to read some tutorials about using GCC.

You might want to try to compile and link with with

gcc -std=c99 -Wall -g xx.c -L. -lmem

(assuming your current directory [not folder] i.e. the . in -L. contains a libmem.a or libmem.so* library)

BTW, order of program arguments to gcc matters a big lot!

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top