cgo:从位于某个程序包中的C函数调用另一个函数

I am trying to follow the guidelines to organize my code with packages and C files located in these directories should be detected and compiled by the tool. However, when I try to reference a function from another package (e.g. calling bar from foo), I am getting the following error:

ld: symbol(s) not found for architecture x86_64

Directories and files:

test/main.go

test/bar:
bar.c  bar.go bar.h

test/foo:
foo.c  foo.go foo.h

bar.h:

extern void bar();

bar.c:

#include <stdio.h>

void bar() {
  printf("bye
");
}

bar.go:

package bar

//#include "bar.h"
import "C"

func Bar() {
    C.bar()
}

foo.h:

extern void foo();

foo.c:

#include <stdio.h>

#include "../bar/bar.h"

void foo() {
  printf("hello
");
  bar();
}

foo.go:

package foo

//include "foo.h"
//include "../bar/bar.h"
import "C"

func Foo() {
    C.foo()
}

main.go:

package main

import "github.com/user/test/foo"
import "github.com/user/test/bar"


func main() {
  foo.Foo()
  bar.Bar()
}

And the output:

cd test ; go build     
# github.com/user/test/foo
Undefined symbols for architecture x86_64:
  "_bar", referenced from:
      _foo in foo.o
ld: symbol(s) not found for architecture x86_64