gammasoft71/Examples_wxWidgets

ApplicationIcon example does not properly load icon on linux

ericfont opened this issue · 3 comments

"Failed to load image from file "Resources/Gammasoft.png"
2021-09-15_19-29

This happens if I run the ApplicationIcon example from anywhere except:

~/Examples_wxWidgets/src/Applications/ApplicationIcon

In which case I invoke execution with this relative path:

../../../build/src/Applications/ApplicationIcon/ApplicationIcon

because at least there the png is under the Resources directory.

note: if I create a directory named "Resources" relative to wherever I'm executing the program and have copied Gammsoft.png into that directory, then it works.

I can even add the line:

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Resources/Gammasoft.png ${CMAKE_CURRENT_BINARY_DIR}/Resources/Gammasoft.png COPYONLY)

to src/Applications/ApplicationIcon/CMakeLists.txt and then it will get copied to the destination build directory...but still the icon will only load if I execute from build/src/Applications/ApplicationIcon/. I have no idea about the proper way to do copy the icon over, though.

for the record I was following these steps from the readme:

mkdir build
cd build
cmake ..
cmake --build . --config Debug

Fixed

thanks, works now on my KDE Debian 11 desktop, regardless of which directory I execute from.