I was able to do it.
I had to build ICU statically first with --enable-static --enable-shared=no
options.
During configuring postgres I had to use the right flags for ICU:
/configure --prefix=/leoaaryan/postgres-10 ... --with-icu
ICU_CFLAGS="-I/leoaaryan/postgres-10/in
IMO the whole idea behind building Postgres with ICU was to remove the
dependency provided by the OS package. Installing ICU as shared object and
configuring Postgres with the libicu*.so file may have a dependency on
LD_LIBRARY_PATH. In shared object situation un-setting/re-setting the
LD_LIBRARY_P
I was able to link ICU library with postgres as shared objects using the
configure command:
./configure --prefix=/leoaaryan/postgres-10 ... --with-icu
ICU_CFLAGS="-I/leoaaryan/postgres-10/include"
ICU_LIBS="-L/leoaaryan/postgres-10/lib -licuuc -licudata -licui18n"
Now I