I wrote a code that use a library release under CC BY-SA 4.0 (Attribution-ShareAlike 4.0 International).
As far as I understand, if I cite them and release the source code as well with my code I can charge money for my work. Am I right?
Open Source Stack Exchange is a question and answer site for people organizing, marketing or licensing open source development projects. It only takes a minute to sign up.Sign up to join this community
You may charge money for your software, though you must distribute your software under CC BY-SA 4.0 terms to anyone who buys it. The Creative Commons Non-Commercial (NC) licenses prohibit commercial use or sale, but CC BY-SA is not an NC license (vs. BY-NC or BY-NC-SA, which are NC licenses).
However, please note that Creative Commons licenses are discouraged for code. I understand that you did not choose the CC BY-SA license on the library, but you may license your work as a whole under the GPLv3, because CC BY-SA 4.0 is one-way compatible into GPLv3:
CC BY-SA 4.0 is one-way compatible with the GNU GPL version 3: this means you may license your modified versions of CC BY-SA 4.0 materials under GNU GPL version 3, but you may not relicense GPL 3 licensed works under CC BY-SA 4.0.
The GPLv3 is a much more suitable license for software, so if you are comfortable doing so, please license your finished product under the GPL and share the source code.
However, note that if you choose to keep the CC BY-SA license, you do not need to distribute the source code of your application. Strictly speaking, in order to comply with the BY-SA terms on the library, you can choose to distribute only the binaries under CC BY-SA 4.0 and choose not to distribute the source code. This is exactly one reason why Creative Commons expressly discourages the use of CC BY-SA (or virtually any Creative Commons license) on software.