Hello,

I follow along a tutorial on interpreters and have a directory structure like this:
Interpreter
--src
----segment.h
----segment.c
----main.c
----Makefile
--test
----test_segment.h
----test_segment.c
----Makefile

My segment files look like this:
Code:
#ifndef segment_h
#define segment_h


#include "common.h"


typedef enum {
  OP_RETURN,
} op_code;


typedef struct {
  int count;
  int capacity;
  uint8_t* code;
} code_segment;


int init_code_segment(code_segment* segment);


#endif
Code:
#include "segment.h"

int init_code_segment(code_segment* segment){
    if (segment == NULL)
        return -1;
    segment->count = 0;
    segment->capacity = 0;
    segment->code = NULL;
    return 0;
}
Code:
#include "/Users/david/Programming/C/Interpreter/src/segment.h"#include <stdlib.h>
#include <stdio.h>
#include <assert.h>


void test_init_segment();
Code:
#include "test_segment.h"

void test_init_segment(){
    code_segment* segment = (code_segment*) malloc(sizeof(code_segment));
    int exit_status = init_code_segment(segment);
    assert(exit_status == 0);
    assert(segment->count == 0 && segment->capacity == 0 && 
        segment->code == NULL);


}


int main(int argc, char* argv[]){
    
    test_init_segment();


    return 0;
}
and the makefile in the "test" directory looks like this:
Code:
all: test_segment

test_segment: test_segment.c
    gcc -Wall -o test_segment test_segment.c
    ./test_segment
When I execute make in the "test" directory I get:
Code:
ld: Undefined symbols:  _init_code_segment, referenced from:
      _test_init_segment in test_segment-0bf004.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
so basically the function in "segment.h" is not found although I included it in "test_segment.h". Can someone tell me whats wrong? thanks!