I want to build my program using make and then launch the created executable via bash script, but bash can't find the executable, although it was created and i can launch it manually. The problem only exist on linux mint 19 in Gnome-terminal. Edit: The exact error message is: "/path/to/my/executable: no such file or directory"
I have a cross-platform project where i need to run cmake, then build the project and finally launch the created executable. I have a bash script to automate the process: Edit: Its only the part that causes the trouble ;)
for TASK in $@; do
if [[ $TASK == "make" ]]; then
call cmake here, this creates a .sln or a make file
elif [[ $TASK == "build" ]]; then
if [[ $OS == 'CYGWIN_NT-10.0' ]]; then
MSBuild.exe "./build/debug/myproject.sln"
elif [[ $OS == 'Linux' ]]; then
cd ./build/debug/ && make
else
error...
fi
elif [[ $TASK == "run" ]]; then
if [[ $OS == 'CYGWIN_NT-10.0' ]]; then
./build/debug/Debug/program.exe
elif [[ $OS == 'Linux' ]]; then
./build/debug/program
else
error...
fi
else
error...
fi
done
Calling "./script.sh make build run" should, for example, call cmake to create the build files, then call the build program (make on linux or msbuild on windows) and then launch the created executable. This works fine on windows 10 in a cygwin terminal. On Linux the call "./script.sh build run" fails, because it can't find the executable. However "./script.sh build && ./build/debug/program" works nicely. Surprisingly "./script.sh build && ./script.sh run" also works as expected. Why is that? Is there any Bug in the bash script? And why does it work on Cygwin but not on linux mint?