cellml / libcellml

Repository for libCellML development.
https://libcellml.org
Apache License 2.0
17 stars 21 forks source link

Windows: debug assertion failed when running a test program that prints the version as a string #971

Closed agarny closed 3 years ago

agarny commented 3 years ago

After building and installing libCellML locally (to C:\Program Files (x86)\libCellML while I would have expected CMake to install it to C:\Program Files\libCellML...?) and then writing a small program that only prints the version (as a string) of libCellML, i.e.

#include <iostream>
#include <libcellml>

int main()
{
    std::cout << "Hello libCellML " << libcellml::versionString() << "!" << std::endl;

    return 0;
}

then, upon running, I get a debug assertion failed: libCellML while everything works as expected under Linux and macOS.

agarny commented 3 years ago

FWIW, I was configuring libCellML and my test program using cmake -G Ninja .. and then ninja, and that resulted in CMake being confused in thinking that libCellML was built as a 32-bit library, hence ninja install was installing libCellML in C:\Program Files (x86)\libCellML, even though the library is 64-bit.

If I configure using cmake -G "Visual Studio 15 2017 Win64" .. and build using Visual Studio then everything is fine, i.e. I don't that debug assertion failed anymore...!

Something I noticed is that the "found" compiler is different. With the Ninja generator, it detects C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe while it detects C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe with the Visual Studio 15 2017 Win64 generator.

Yeah, I really hate Windows development. So unnecessarily complicated and obscure!