[QUOTE=Dark Photon;398241]This doesn’t really have anything to do with OpenGL.
You’re trying to load a file using a relative path (“shaders/vertexshader.vs”), and it’s failing to open the file with fopen() (ERRNO 2 is ENOENT by the way, which means the file or directory doesn’t exist).
The reason is most likely that the current working directory active when you call fopen() is not the one you think it is (the one one level up from the “vertexshader.vs” file). You just need to figure out why.
Right before your fopen(), try adding this:
#include <unistd.h> // Put this line at the top of the file outside of all functions, of course
getcwd( dir, sizeof( dir ) );
printf( "CWD = %s
", dir );
That will tell you what directory is the current directory at that point.
Also, at the top of your bash script (just below the #!/bin/bash line), add a “pwd” command. That will tell you what the current working directory is as soon as your script is invoked.
When you are one directory level up from the shader file, instead of using your wrapper script, try running:
env MESA_GL_VERSION_OVERRIDE=3.3COMPAT ./yourapp
Does that work?
In your shell, try cd’ing someplace (e.g. cd /usr/bin), now run “bash” with no options, and then run “pwd” and then “exit”. Did your pwd command reveal that you were in a different directory. If so, it is likely that you have a command which changes the current working directory in one of your bash startup profiles (check them for “cd” commands for example: ~/.profile, ~/.bashrc, /etc/profile, or /etc/bash.bashrc). Whenever you startup a new bash shell (which you’re doing with your bash script file), bash will run the commands in those startup scripts before it runs the commands in the script you’re invoking. Once you remove that (or those) “cd” commands from the bash startup profiles, then your wrapper script will likely work as you expect it to again.
Of course, another alternative which bypasses all of this is to, in your C++ code when you call fopen(), provide a full path from root to fopen() and not a relative path. Then it doesn’t make any difference what the current working directory is. Alternatively, build a full path to the file using some relative path in your code combined with a base path from root, specified by some command-line option, configuration file option, or environment variable.[/QUOTE]
Yes moving the script to the same directory worked, also env from the same directory as the app worked. I will make an alias or try to go directly into the directory with in the script (split the input before the last / and than make a cd to the first half should work but how do I do this?).
Is there a possibility to write this Version Overwrite directly into the C-code if needed (for example via conditioned pre-compiler)? I would like this code in an extra file, as I will need for all my projects.