Undefined Reference to Matplot++ Library Functions While Linking Custom Target #155
-
Hi, I am trying to integrate matplot++ library using Clion IDE by using MinGW32 GCC compiler. Here is my CMakeList.txt file cmake_minimum_required(VERSION 3.19)
project(matplot_simple)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_PREFIX_PATH "C:/Program Files/matplotplusplus 1.1.0/lib/cmake")
set(CMAKE_MODULE_PATH "C:/Program Files/matplotplusplus 1.1.0/lib/cmake/Matplot++")
add_executable(${PROJECT_NAME} main.cpp)
find_package(Filesystem REQUIRED)
find_package(Matplot++ REQUIRED)
target_link_libraries(${PROJECT_NAME} PUBLIC std::filesystem)
target_link_libraries(${PROJECT_NAME} PUBLIC Matplot++::matplot)
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_20) Here is my code #include <vector>
#include <matplot/matplot.h>
int main()
{
std::vector<double> x = matplot::linspace(0, 2 * matplot::pi);
std::vector<double> y = matplot::transform(x, [](auto x) { return sin(x); });
matplot::plot(x, y, "-o");
matplot::show();
return 0;
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
It seems like you installed Matplot++ with MSVC, and the MSVC binaries are not compatible with MinGW32. MinGW32 is not officially supported but you can try to build from source with MinGW32 or use FetchContent. This might work. If this doesn't work, you move to MSVC (CLion works with MSVC now) or you can adapt the build script to work with MinGW (and even open a PR if that works :D). |
Beta Was this translation helpful? Give feedback.
It seems like you installed Matplot++ with MSVC, and the MSVC binaries are not compatible with MinGW32.
MinGW32 is not officially supported but you can try to build from source with MinGW32 or use FetchContent.
This might work.
If this doesn't work, you move to MSVC (CLion works with MSVC now) or you can adapt the build script to work with MinGW (and even open a PR if that works :D).