How can I create a C++ Console application, compiled with GCC, portable to Linux and Windows, with a password prompt without echo (does not show the password as you type it)?

I would like something like those:
- with stars echo:

User: bob
Password: ******

- or without any echo at all

User: bob
Password:

I googled this for hours without finding any solution that were a Console application (usable with bash, dos, etc) compiled with GCC and portable to Windows and Linux.