wxWidgets runtime error (Mismatch version)

Viewed 3317

I have a problem at start the program:

Fatal Error: Mismatch between the program and library build versions detected.
The library used 3.0 (wchar_t,compiler with C++ ABI 1010,wx containers,compatible with 2.8),
and your program used 3.0 (wchar_t,compiler with C++ ABI 1009,wx containers,compatible with 2.8).



My cmake settings:

cmake_minimum_required(VERSION 3.0)

project(simple)

set(CMAKE_BUILD_TYPE Release)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${wxWidgets_CXX_FLAGS} -Wall -std=c++14")

find_package(wxWidgets COMPONENTS net gl core base)

include("${wxWidgets_USE_FILE}")

add_executable(${PROJECT_NAME} main.cpp)

target_link_libraries(${PROJECT_NAME} ${wxWidgets_LIBRARIES})

Version of wxWidgets 3.0.3.

3 Answers

If your desire is to have __GXX_ABI_VERSION=1002, specify -fabi-version=2 to GCC. To do this in your CMakeLists.txt, add:

add_definitions(-fabi-version=2)

This is a preferred approach compared to manually redefining __GXX_ABI_VERSION, which would violate C++ standards and potentially cause undefined behavior.

Note: -fabi-version=2 may not always correspond to __GXX_ABI_VERSION=1002 in future releases of GCC. Compile and run this quick C++ program to check it:

#include <iostream>

int main(void) {
    std::cout << "__GXX_ABI_VERSION=" << __GXX_ABI_VERSION << std::endl;
    return 0;
}

Compile this way:

g++ -fabi-version=2 -o check_fabi_version check_fabi_version.cpp 

Run this way:

./check_fabi_version

Example output as of GCC 8.2.0:

__GXX_ABI_VERSION=1002

I had two version of wxWidgets instaled. I deleted one of them and it works great.

Related