How to develop simple dynamic link library or tutorial

Hello JUCE community.

I am testing dynamic link library.

A first I exported project to Xcode and added source.cpp

#include <stdio.h>
#include<iostream>
using namespace std;

int hello(){
  std::cout << "Hello World!";
  return 0;
}

libNewProject.dylib was build by Xcode then I put this in /usr/local/lib/

use_juce.cpp

#include <iostream>
int hello();

int main() {
    hello();
    std::cout << "Test Finish!\n";
    return 0;
}

try to compile this with command below.

$g++ -o use_juce use_juce.cpp -L./ -lNewProject

it shows the error.

Undefined symbols for architecture x86_64:
  "hello()", referenced from:
      _main in use_juce-60d598.o
ld: symbol(s) not found for architecture x86_64

also checked the function in dylib

$nm /usr/local/lib/libNewProject.dylib |grep hello
0000000000002260 T __Z5hellov

I made the same simple dynamic link library without JUCE, it works.

However the project exported from JUCE, this error happens.

Any help appreciated. thank you.