alandefreitas / matplotplusplus

Matplot++: A C++ Graphics Library for Data Visualization 📊🗾
https://alandefreitas.github.io/matplotplusplus/
MIT License
4.11k stars 313 forks source link

It doesn't work well even though static build #319

Closed Leidenschaftliche closed 1 year ago

Leidenschaftliche commented 1 year ago

Hello, I'm using matplotplusplus-1.1.0 in my KNNplot project

It works well after cmake when i execute mingw32-make install command. As it installs it on to ./build/rel directory If I delete all files other than my installed executable it still works well. (doesn't depend on other files of the project) But if I change its location it does not work well. (The working of exe is dependend of its location unfortunately)

My project has only 3 files: classifierKNN_2d.cpp, classifierKNN_2d.h and main.cpp In my project I use the matplotplusplus-1.1.0.

The directory structure before executing any build command(cmake make etc) is: Directory of C:\Users\ASUS\Desktop\knn_LabFinal

02.01.2023 02:55

. 02.01.2023 02:55 .. 01.01.2023 23:12 9.090 classifierKNN_2d.cpp 01.01.2023 23:09 4.743 classifierKNN_2d.h 02.01.2023 02:23 1.067 CMakeLists.txt 01.01.2023 21:23 1.233 main.cpp 02.01.2023 02:45 matplotplusplus 4 File(s) 16.133 bytes 3 Dir(s) 775.606.550.528 bytes free

I execute this 3 commands in order in cmd to build my project:

cmake -G "MinGW Makefiles" -DCMAKE_GNUtoMS=1 .
mingw32-make -j8 
mingw32-make install

My cmakelists.txt File:

cmake_minimum_required(VERSION 3.1)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set(BUILD_SHARED_LIBS OFF)
set(CMAKE_EXE_LINKER_FLAGS "-static")

project(knn_LabFinal)
if (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
    set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
endif ()

set(CMAKE_CXX_STANDARD 11)

set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/compiled
        CACHE PATH "install here" FORCE)

add_executable(knn_LabFinal main.cpp classifierKNN_2d.cpp classifierKNN_2d.h)

set(CMAKE_GNUtoMS 1)
set(BUILD_EXAMPLES OFF)
set(BUILD_TESTS OFF)
add_subdirectory(matplotplusplus)

target_link_libraries(knn_LabFinal PUBLIC -static matplot)

install(TARGETS knn_LabFinal  DESTINATION ./rel CONFIGURATIONS Release)

after mingw32-make -j8 command knn_LabFinal.exe is created at: C:\Users\ASUS\Desktop\knn_LabFinal\

after mingw32-make install command knn_LabFinal.exe is created at: C:\Users\ASUS\Desktop\knn_LabFinal\compiled\rel

I checked hashes for both C:\Users\ASUS\Desktop\knn_LabFinal\compiled\rel\knn_LabFinal.exe and C:\Users\ASUS\Desktop\knn_LabFinal\knn_LabFinal.exe and they're exactly the same.

I wonder why this happens? How do I solve it? I want to make my executable(knn_LabFinal.exe) portable, So it should work in every win-10_x86_64 system which has gnuplot on sytems PATH variable.

image Left one works well, while right one doesn't.

Originally posted by @Leidenschaftliche in https://github.com/alandefreitas/matplotplusplus/discussions/317

alandefreitas commented 1 year ago

But if I change its location it does not work well. (The working of exe is dependend of its location unfortunately)

At this point, you have to tell us what the error is.

Leidenschaftliche commented 1 year ago

But if I change its location it does not work well. (The working of exe is dependend of its location unfortunately)

At this point, you have to tell us what the error is.

It doesn't give any explicit error. The executable just doesn't plot anything other than legends if I change its location.

Leidenschaftliche commented 1 year ago

It is solved, it was a compatibility issue. As windows associates full path of the executable with its compatibility settings, it doesn't work if we move the executable to a new location. But if we configure settings also for new location it works there as well. So for each location change we must redo our compatibility configuration which is "windows-8".

So the new problem here is do we have to use windows-8 mode for an healthy execution, or are there any shortcuts?