I'm trying to get Code::Blocks working with LLVM CLANG.
CLANG uses clang-cl to pass linker commands onto Visual Studio's Link.exe in order to link Windows GUI project into a windows executable.
clang-cl and link.exe require .lib files to *not* have a "link library (e.g. -l)" parsing option in the command line. When I try to compile, I get this in my build log:
clang-cl: warning: unknown argument ignored in clang-cl: '-lgdi32.lib' [-Wunknown-argument]
clang-cl: warning: unknown argument ignored in clang-cl: '-luser32.lib' [-Wunknown-argument]
clang-cl: warning: unknown argument ignored in clang-cl: '-lkernel32.lib' [-Wunknown-argument]
clang-cl: warning: unknown argument ignored in clang-cl: '-lcomctl32.lib' [-Wunknown-argument]
clang-cl: warning: unknown argument ignored in clang-cl: '-lgdi32.lib' [-Wunknown-argument]
clang-cl: warning: unknown argument ignored in clang-cl: '-luser32.lib' [-Wunknown-argument]
clang-cl: warning: unknown argument ignored in clang-cl: '-lkernel32.lib' [-Wunknown-argument]
clang-cl: warning: unknown argument ignored in clang-cl: '-lmsvcrt.lib' [-Wunknown-argument]
as well as "LNK2019: unresolved external symbol" errors for every function I'm calling from those libraries.
When I
* go to Settings > Compiler... > [My Windows Compiler] > Other settings > Advanced options...,
* Go to Others in "Advanced compiler options"
* Select the contents of "Link library (e.g. -l):
* Delete to clear the contents,
* Click "OK", "OK"
and build the project, the project builds successfully.
Here's the bug:
When I save everything, close Code::Blocks, and reopen Code::Blocks, [My Windows Compiler] has reverted the "Link library" field to "-l", forcing me to manually clear it again.
This is because when Code::Blocks saves default.conf, it skips over empty text fields instead of saving the empty value.
If you create a custom value in that field, then default.conf contains
<LINK>
<str>
<![CDATA[customvalue]]>
</str>
</LINK>
in the compiler initialization. If you manually dele the cusom value, creating
<LINK>
<str>
<![CDATA[]]>
</str>
</LINK>
then Code::Blocks will happily load it as an empty field.
But every time you close Code::Blocks, the empty fields get left out of default.conf, reverting them to default values.
SOLUTION:
Please write empty fields as <![CDATA[]]> instead of skipping them. "No value." may be important information to preserve.