CMake Release Build On Windows 10 Code Redefinition

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
Cethric
In need of some credit
In need of some credit
Posts: 4
Joined: Mon Jan 01, 2018 5:30 am

CMake Release Build On Windows 10 Code Redefinition

Post by Cethric »

I am attempting to build a small project using the CMake build script that comes with the latest git revision of wxWidgets and ran into an issue compiling in release mode on MSVC (it works for debug mode). My project structure is as follows

Code: Select all

root/
    application/
        main.cpp
        CMakeLists.txt
    ext/
        wxWidgets/
            CMakeLists.txt
            ...
        CMakeLists.txt
    CMakeLists.txt
If it makes any difference I am using JetBrains CLion as the IDE.
root/CMakeLists.txt just adds the two subdirectors and sets CMAKE_CXX_STANDARD to 14
ext/CMakeLists.txt adds the wxWidgets subdirector and creates an INTERFACE library with the wxWidgets libraries I am using as INTERFACE links
application/CMakeLists.txt contains the executable definition and links to the INTERFACE library
Both Debug and Release mode will both create their respective make files (in seperate directories to ensure no conflict)
Debug Build in MSVC2017 works fine no issues
Release Build in MSVC2017 fails to build with the following error `wxmsw31u_core.lib(wxmsw312u_core_vc_x64_custom.dll) : error LNK2005: "public: virtual __cdecl wxNavigationEnabled<class wxWindow>::~wxNavigationEnabled<class wxWindow>(void)" (??1?$wxNavigationEnabled@VwxWindow@@@@UEAA@XZ) already defined in treelist.cpp.obj`

What I want to know is, is any one else suffering from this? and are there any suggestions to resolve this? (I plan to use components from the wxAdvanced library so can't disable it)

Let me know if more information is required

Thanks in advanced Cethric :D
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: CMake Release Build On Windows 10 Code Redefinition

Post by ONEEYEMAN »

Hi,
Is it possible you ae linking the library twice?
What command producing such error? You should probably start verbose build to see the log on the screen...
And what commands is executing for the building that library where you have issues?
Also, are you able to run the program in Debug mode? Is there any issues?

Finally - did you buiold wxWidgets using CMake? Did you use any non-default options? Any issues during the build?

Thank you.
Cethric
In need of some credit
In need of some credit
Posts: 4
Joined: Mon Jan 01, 2018 5:30 am

Re: CMake Release Build On Windows 10 Code Redefinition

Post by Cethric »

I will look into what the build log states, while linking twice sounds like a high possibility I do not understand how it could have occured as the only difference (for my build scripts, I haven't read all of the cmake scripts for wxWidgets yet) is that I specify the debug build mode or release build mode '-DCMAKE_BUILD_TYPE="Release"' on the command line
Cl.exe produces the error, I will work on producing a more verbose output soon.
In Debug mode all the sample files work fine and my program runs smoothly.
wxWidgets is a sub directory in my cmake script so it is build using cmake as a dependency to my project.
The only options I have are to enable OpenGL and to set the language to CPP-14.

I would also like to note that if I set the flag to build the treelist to off then it compiles fine under release mode. (While having tree list disabled isn't an issue for me as I won't be using it) I still want to know why it causes cmake to fail to build. So will continue to investigate.

Thanks for the help Cethric :D
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: CMake Release Build On Windows 10 Code Redefinition

Post by ONEEYEMAN »

Hi,
Did you also build wxWidgets using CMake? Or you just run the compiler from the command line>
Keep in mind that CMake is still a not official way of building the library. You can build an application using CMake but not the library itself.

Thank you.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: CMake Release Build On Windows 10 Code Redefinition

Post by PB »

ONEEYEMAN wrote:Keep in mind that CMake is still a not official way of building the library. You can build an application using CMake but not the library itself.
Are you sure about that? Since 2017 wxWidgets comes with CMake support and provides a guide how to build the library (and samples and tools) with it. I would say that's quite official...
Cethric
In need of some credit
In need of some credit
Posts: 4
Joined: Mon Jan 01, 2018 5:30 am

Re: CMake Release Build On Windows 10 Code Redefinition

Post by Cethric »

wxWidgets is built using CMake
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: CMake Release Build On Windows 10 Code Redefinition

Post by ONEEYEMAN »

Hi
PB wrote:
ONEEYEMAN wrote: Keep in mind that CMake is still a not official way of building the library. You can build an application using CMake but not the library itself.
Are you sure about that? Since 2017 wxWidgets comes with CMake support and provides a guide how to build the library (and samples and tools) with it. I would say that's quite official...
But it is WIP, so I should consider it "non-official".

Thank you.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: CMake Release Build On Windows 10 Code Redefinition

Post by PB »

ONEEYEMAN wrote:But it is WIP, so I should consider it "non-official".
AFAIK, while it may have its issues (just as any other part of wxWidgets), it is not a WIP: WIPs are not merged into the master branch of wxWidgets. Unless you consider the whole master branch of wxWidgets itself a WIP...


@Cethric
As for the topic, I do not use CMake, all I know is that the almost current wxWidgets master (81cac4e) including all the samples does build with CMake-generated makefiles for with MSVC 2017's nmake target as 64-bit release shared.

It is very odd that the release build of your application fails while the debug one succeeds. Isn't this (aside from NDEBUG and such) often caused by differences in code generation, such as inlining but that dtor is not even inlined... If I didn't know any better I would have thought it to be a template-related compiler glitch.

I assume you have cleared all the builds and somehow set all the necessary #defines for your both builds of your application, including WXUSINGDLL and NDEBUG.
Cethric
In need of some credit
In need of some credit
Posts: 4
Joined: Mon Jan 01, 2018 5:30 am

Re: CMake Release Build On Windows 10 Code Redefinition

Post by Cethric »

IIRC cmake will apply the NDEBUG flag and I have been applying the WXUSINGDLL to both debug and release.
So far I have only noticed this issue on Windows 10 x64 Release builds using visual studio 2017 community edition I have not encountered it in macOS 10.13 using Xcode (clang), MinGW64 (on windows with MSYS2) using GCC or on WSL Ubuntu16.04LTS using GCC

Thanks for the help Cethric :D
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: CMake Release Build On Windows 10 Code Redefinition

Post by ONEEYEMAN »

Hi,
It is very odd indeed.
Can you build the 'minimal' sample with the generated Makefiles for both debug and release modes? And can you try to build it with the MSVC IDE with the provided solution files?

Thank you.
Post Reply