Bug 369303 - Krita fails to build on Windows in Debug mode
Summary: Krita fails to build on Windows in Debug mode
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: General (show other bugs)
Version: git master (please specify the git hash!)
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-25 02:03 UTC by Lee Zhen Yong
Modified: 2020-04-10 08:43 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lee Zhen Yong 2016-09-25 02:03:17 UTC
In the official build instructions krita is built using "RelWithDebInfo", which is a Release build with debugging information. However release builds optimized out certain values (like QStrings), which can be useful for programmers when using a debugger.

The problem is that Krita can build in Release and RelWithDebInfo mode, but fails in Debug mode. That still means Krita can be built and packaged, but that doesn't seem like something that should happen. I have replicated this error about 3 times, and the compile errors consistently points to the VC library (I rebuilt VC and Krita from scratch a few times to confirm):

C:/dev/install/lib/libVc.a(const.cpp.obj):const.cpp:(.text+0x0): 
multiple definition of `Vc1::Common::checkLibraryAbi(unsigned int, unsigned int, char const*)'
lib/libkritaimage.dll.a(d008809.o):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status

Reproducible: Always

Steps to Reproduce:
1. When configuring krita, set CMAKE_BUILD_TYPE to "Debug"
2. Build krita.
Comment 1 Halla Rempt 2016-09-26 11:42:34 UTC
Does that also happen with a completely clean build? Note that you need to build all dependencies also in Debug mode.
Comment 2 Lee Zhen Yong 2016-09-26 12:45:57 UTC
Owh... that would probably be the reason why. The error messages aren't very helpful in pointing that out. 

I know how to change the modes for all 3rd party libraries (setting "GLOBAL_BUILD_TYPE" in 3rdparty/CMakeLists.txt), but Qt and Boost has their own build system. Haven't looked to how to change them yet.

If the build mode for 3rd party libraries be the case, then there is no issue and therefore no bug. I have to build to double confirm though.

Also, if that be the case, I'd like to work towards making it easier to change the build mode of 3rd party libraries easier. It should be the case that if I set CMAKE_BUILD_TYPE in configuring 3rdparty it should affect all libraries. Should be a simple feature to add I hope.
Comment 3 Lee Zhen Yong 2016-09-26 12:49:35 UTC
_drat. I can't edit comments here..._

I meant to say I can change the build modes for all 3rd party libraries except Qt and Boost.
Comment 4 Alvin Wong 2016-09-26 13:23:48 UTC
configure.bat of Qt has the `-debug-and-release` flag which will build both the debug and release versions at the same time. Or you can just use `-debug` for a debug-only build. I would suggest doing an out-of-source build anyway if you can manage to.
Comment 5 Alvin Wong 2016-09-26 15:27:32 UTC
Actually, Qt has more flags than that:

>    -release ........... Compile and link Qt with debugging turned off.
> *  -debug ............. Compile and link Qt with debugging turned on.
> +  -debug-and-release . Compile and link two Qt libraries, with and without
>                         debugging turned on.
>
>    -force-debug-info .. Create symbol files for release builds.
>    -separate-debug-info Strip debug information into a separate file.
>
>    -developer-build ... Compile and link Qt with Qt developer options
>                         (including auto-tests exporting)

This means you can make Qt release builds with debug info too, or even haven the debug info in their own files.
Comment 6 Lee Zhen Yong 2016-09-27 00:08:54 UTC
Aite. As suggested, for Qt I've modified the CMakeLists.txt to replace "-release" with "-debug" in CONFIGURE_COMMAND <SOURCE_DIR>/configure.bat.

For boost CMakeLists.txt, in "BUILD_COMMAND <SOURCE_DIR>/b2.exe" change variant from "release" to "debug".

I left my laptop to build overnight, and here's the result:

Good news first: I managed to build debug versions of Qt and boost. Their *.dll names are different so it's easy to spot whether they are different.

Bad news: bug doesn't go away, and it's the same error. On the bright side, the compile error messages are more detailed:

C:/dev/install/lib/libVc.a(const.cpp.obj): In function `Vc_1::Common::checkLibraryAbi(unsigned int, unsigned int, char const*)':
C:/dev/lib-build/ext_vc/ext_vc-prefix/src/ext_vc/src/const.cpp:281: multiple definition of `Vc_1::Common::checkLibraryAbi(unsigned int, unsigned int, char const*)
lib/libkritaimage.dll.a(d008829.o):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
[147/1938] Linking CXX shared module bin\krita_shape_text.dll
ninja: build stopped: subcommand failed.
Comment 7 Lee Zhen Yong 2016-09-27 00:16:22 UTC
You know what, I should paste the full error message:

[142/1938] Linking CXX shared library bin\libkritalibbrush.dll
FAILED: bin/libkritalibbrush.dll lib/libkritalibbrush.dll.a
cmd.exe /C "cd . && C:\TDM-GCC-64\bin\c++.exe   -std=c++0x -Wall -Wextra -Wcast-align -Wchar-subscripts -Wformat-security -Wno-long-long -Wpointer-arith -Wundef -Wnon-v
irtual-dtor -Woverloaded-virtual -Werror=return-type  -fext-numeric-literals -fexceptions -std=c++11 -g  -Wl,--no-undefined -Wl,--fatal-warnings  -Wl,--export-all-symbo
ls -shared -o bin\libkritalibbrush.dll -Wl,--out-implib,lib\libkritalibbrush.dll.a -Wl,--major-image-version,15,--minor-image-version,0 libs/brush/CMakeFiles/kritalibbr
ush.dir/kis_predefined_brush_factory.cpp.obj libs/brush/CMakeFiles/kritalibbrush.dir/kis_auto_brush.cpp.obj libs/brush/CMakeFiles/kritalibbrush.dir/kis_boundary.cc.obj
libs/brush/CMakeFiles/kritalibbrush.dir/kis_brush.cpp.obj libs/brush/CMakeFiles/kritalibbrush.dir/kis_scaling_size_brush.cpp.obj libs/brush/CMakeFiles/kritalibbrush.dir
/kis_brush_registry.cpp.obj libs/brush/CMakeFiles/kritalibbrush.dir/kis_brush_server.cpp.obj libs/brush/CMakeFiles/kritalibbrush.dir/kis_gbr_brush.cpp.obj libs/brush/CM
akeFiles/kritalibbrush.dir/kis_abr_brush.cpp.obj libs/brush/CMakeFiles/kritalibbrush.dir/kis_abr_brush_collection.cpp.obj libs/brush/CMakeFiles/kritalibbrush.dir/kis_im
agepipe_brush.cpp.obj libs/brush/CMakeFiles/kritalibbrush.dir/kis_pipebrush_parasite.cpp.obj libs/brush/CMakeFiles/kritalibbrush.dir/kis_png_brush.cpp.obj libs/brush/CM
akeFiles/kritalibbrush.dir/kis_svg_brush.cpp.obj libs/brush/CMakeFiles/kritalibbrush.dir/kis_qimage_pyramid.cpp.obj libs/brush/CMakeFiles/kritalibbrush.dir/kis_text_bru
sh.cpp.obj libs/brush/CMakeFiles/kritalibbrush.dir/kis_auto_brush_factory.cpp.obj libs/brush/CMakeFiles/kritalibbrush.dir/kis_text_brush_factory.cpp.obj libs/brush/CMak
eFiles/kritalibbrush.dir/kritalibbrush_automoc.cpp.obj  lib/libkritaimage.dll.a -lws2_32 -lnetapi32 C:/dev/install/lib/libVc.a lib/libkritawidgets.dll.a lib/libkritafla
ke.dll.a C:/dev/install/lib/libQt5Svgd.a C:/dev/install/lib/libKF5Completion.dll.a lib/libkritapsd.dll.a lib/libkritaodf.dll.a lib/libkritastore.dll.a lib/libkritaversi
on.dll.a C:/dev/install/lib/libKF5Archive.dll.a lib/libkritapigment.dll.a -lws2_32 -lnetapi32 lib/libkritaundo2.dll.a lib/libkritawidgetutils.dll.a lib/libkritaglobal.d
ll.a C:/dev/install/lib/libQt5PrintSupportd.a C:/dev/install/lib/libKF5ConfigGui.dll.a C:/dev/install/lib/libKF5GuiAddons.dll.a C:/dev/install/lib/libKF5WidgetsAddons.d
ll.a C:/dev/install/lib/libQt5Xmld.a lib/libkritaplugin.dll.a C:/dev/install/lib/libKF5CoreAddons.dll.a C:/dev/install/lib/libKF5ConfigCore.dll.a C:/dev/install/lib/lib
KF5I18n.dll.a C:/dev/install/lib/libKF5ItemViews.dll.a C:/dev/install/lib/libQt5Widgetsd.a C:/dev/install/lib/libQt5Guid.a C:/dev/install/lib/libQt5Concurrentd.a C:/dev
/install/lib/libQt5Cored.a C:/dev/install/lib/libboost_system-mgw51-mt-d-1_61.dll C:/dev/install/lib/libImath.dll C:/dev/install/lib/libIlmImf.dll C:/dev/install/lib/li
bIex.dll C:/dev/install/lib/libHalf.dll C:/dev/install/lib/libIlmThread.dll C:/dev/install/lib/libVc.a -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut
32 -luuid -lcomdlg32 -ladvapi32 && cd ."
C:/dev/install/lib/libVc.a(const.cpp.obj): In function `Vc_1::Common::checkLibraryAbi(unsigned int, unsigned int, char const*)':
C:/dev/lib-build/ext_vc/ext_vc-prefix/src/ext_vc/src/const.cpp:281: multiple definition of `Vc_1::Common::checkLibraryAbi(unsigned int, unsigned int, char const*)'
lib/libkritaimage.dll.a(d008829.o):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
Comment 8 Alvin Wong 2016-09-27 02:23:06 UTC
Are you sure you're building everything from scratch? The easiest way to make sure is to delete the build and install dir.

From what I see though, that function is declared in Vc/version.h and not marked `dllexport`, so it shouldn't have been visible from libkritaimage.dll.a, right?

*Unless* it's caused by the linker flags in the Debug configuration. There I see a flag `--export-all-symbols` passed to the linker, which may be the cause to this problem if it's not there in the Release build.
Comment 9 Alvin Wong 2016-09-27 02:30:03 UTC
In fact --export-all-symbols should not be in the linker flags at all, exported functions should be marked `__declspec(dllexport)` properly or be using a .def file.

It seems that CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS would enable that flag. I am not in the position to grep the source quickly so I can't provide more info for now.
Comment 10 Lee Zhen Yong 2016-09-27 02:53:41 UTC
=> Are you sure you're building everything from scratch? 

Yep. The install and build folder are emptied out before I rebuild.
Comment 11 Halla Rempt 2016-11-01 11:09:54 UTC
Yeah, I see that one of the unittests isn't built.
Comment 12 Alvin Wong 2017-12-17 14:10:10 UTC
Does anyone want to try this on master again? I might have unintentionally fixed it (unless I haven't).
Comment 13 Halla Rempt 2017-12-22 12:06:57 UTC
Ok. I've started a debug build on the black monster.
Comment 14 Halla Rempt 2017-12-22 13:13:29 UTC
It still fails:

CMakeFiles\kritaui.dir/objects.a(kis_uniform_paintop_property_widget.cpp.obj): In function `KisUniformPaintOpPropertyIntSlider::KisUniformPaintOpPropertyIntSlider(QSharedPointer<KisUniformPaintOpProperty>, QWidget*)':
C:/dev/4/64/krita/libs/ui/brushhud/kis_uniform_paintop_property_widget.cpp:81: undefined reference to `KisSliderBasedPaintOpProperty<int>::max() const'
C:/dev/4/64/krita/libs/ui/brushhud/kis_uniform_paintop_property_widget.cpp:81:(.text+0x496): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `KisSliderBasedPaintOpProperty<int>::max() const'
C:/dev/4/64/krita/libs/ui/brushhud/kis_uniform_paintop_property_widget.cpp:81: undefined reference to `KisSliderBasedPaintOpProperty<int>::min() const'
C:/dev/4/64/krita/libs/ui/brushhud/kis_uniform_paintop_property_widget.cpp:81:(.text+0x4a4): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `KisSliderBasedPaintOpProperty<int>::min() const'
C:/dev/4/64/krita/libs/ui/brushhud/kis_uniform_paintop_property_widget.cpp:82: undefined reference to `KisSliderBasedPaintOpProperty<int>::singleStep() const'
C:/dev/4/64/krita/libs/ui/brushhud/kis_uniform_paintop_property_widget.cpp:82:(.text+0x4c5): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `KisSliderBasedPaintOpProperty<int>::singleStep() const'
C:/dev/4/64/krita/libs/ui/brushhud/kis_uniform_paintop_property_widget.cpp:83: undefined reference to `KisSliderBasedPaintOpProperty<int>::pageStep() const'
C:/dev/4/64/krita/libs/ui/brushhud/kis_uniform_paintop_property_widget.cpp:83:(.text+0x4e3): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `KisSliderBasedPaintOpProperty<int>::pageStep() const'
C:/dev/4/64/krita/libs/ui/brushhud/kis_uniform_paintop_property_widget.cpp:85: undefined reference to `KisSliderBasedPaintOpProperty<int>::suffix() const'
C:/dev/4/64/krita/libs/ui/brushhud/kis_uniform_paintop_property_widget.cpp:85:(.text+0x51f): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `KisSliderBasedPaintOpProperty<int>::suffix() const'
C:/dev/4/64/krita/libs/ui/brushhud/kis_uniform_paintop_property_widget.cpp:86: undefined reference to `KisSliderBasedPaintOpProperty<int>::exponentRatio() const'
C:/dev/4/64/krita/libs/ui/brushhud/kis_uniform_paintop_property_widget.cpp:86:(.text+0x551): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `KisSliderBasedPaintOpProperty<int>::exponentRatio() const'
CMakeFiles\kritaui.dir/objects.a(kis_uniform_paintop_property_widget.cpp.obj): In function `KisUniformPaintOpPropertyDoubleSlider::KisUniformPaintOpPropertyDoubleSlider(QSharedPointer<KisUniformPaintOpProperty>, QWidget*)':
C:/dev/4/64/krita/libs/ui/brushhud/kis_uniform_paintop_property_widget.cpp:121: undefined reference to `KisSliderBasedPaintOpProperty<double>::decimals() const'
C:/dev/4/64/krita/libs/ui/brushhud/kis_uniform_paintop_property_widget.cpp:121:(.text+0x9e6): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `KisSliderBasedPaintOpProperty<double>::decimals() const'
C:/dev/4/64/krita/libs/ui/brushhud/kis_uniform_paintop_property_widget.cpp:121: undefined reference to `KisSliderBasedPaintOpProperty<double>::max() const'
C:/dev/4/64/krita/libs/ui/brushhud/kis_uniform_paintop_property_widget.cpp:121:(.text+0x9f4): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `KisSliderBasedPaintOpProperty<double>::max() const'
C:/dev/4/64/krita/libs/ui/brushhud/kis_uniform_paintop_property_widget.cpp:121: undefined reference to `KisSliderBasedPaintOpProperty<double>::min() const'
C:/dev/4/64/krita/libs/ui/brushhud/kis_uniform_paintop_property_widget.cpp:121:(.text+0xa05): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `KisSliderBasedPaintOpProperty<double>::min() const'
C:/dev/4/64/krita/libs/ui/brushhud/kis_uniform_paintop_property_widget.cpp:122: undefined reference to `KisSliderBasedPaintOpProperty<double>::singleStep() const'
C:/dev/4/64/krita/libs/ui/brushhud/kis_uniform_paintop_property_widget.cpp:122:(.text+0xa33): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `KisSliderBasedPaintOpProperty<double>::singleStep() const'
C:/dev/4/64/krita/libs/ui/brushhud/kis_uniform_paintop_property_widget.cpp:124: undefined reference to `KisSliderBasedPaintOpProperty<double>::suffix() const'
C:/dev/4/64/krita/libs/ui/brushhud/kis_uniform_paintop_property_widget.cpp:124:(.text+0xa77): additional relocation overflows omitted from the output
C:/dev/4/64/krita/libs/ui/brushhud/kis_uniform_paintop_property_widget.cpp:125: undefined reference to `KisSliderBasedPaintOpProperty<double>::exponentRatio() const'
collect2.exe: error: ld returned 1 exit status
libs\ui\CMakeFiles\kritaui.dir\build.make:10277: recipe for target 'bin/libkritaui.dll' failed
mingw32-make[2]: *** [bin/libkritaui.dll] Error 1
CMakeFiles\Makefile2:16424: recipe for target 'libs/ui/CMakeFiles/kritaui.dir/all' failed
mingw32-make[1]: *** [libs/ui/CMakeFiles/kritaui.dir/all] Error 2
Makefile:139: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
Comment 15 Alvin Wong 2017-12-22 13:43:33 UTC
Weird, what's different in debug mode that can cause this error?
Comment 16 Halla Rempt 2020-04-10 08:43:33 UTC
This must have been fixed in the meantime, maybe because of an update to Vc, because Debug is now the standard build type on all platforms.