Having to initialize setvars.bat is really tedious and troublesome.
It hinders usability of any oneAPI programs, either,
- Open cmd, enter "%ONEAPI_ROOT%setvars.bat", then enter ".exe".
- Write another program, which runs the setvars.bat then run the actual application.
Are there any alternatives, like an callable API to set them from inside the program instead?
For Visual Studio development, there's Automate the setvars.bat Script with Microsoft Visual Studio* which is really handy.
However, from end user perspective, (whether a program consuming a .dll written using oneAPI or a person using an .exe that uses oneAPI) I wish to just call the .dll functions / double click the .exe without having to run setvars.bat.
In windows, if you use Visual Studio there is no need to run setvars.bat every time. If you want to use the command prompt and doesn't want to run setvars.sh use "Intel OneAPI Command Prompt" which runs the script on initialization.
Sorry for the delay in response.
Currently, it is not possible to use Intel Compilers without loading them.
So, running setvars.bat is mandatory as of now.
If you need to run the executables without running setvars.bat everytime. Now while this is not the recommended way but you can try make it run while loading windows as a startup script.
For making the script run by default during startup follow the steps below:
- Create a shortcut to the batch file.
- Once the shortcut is created, right-click the shortcut file and select Cut.
- Press Start, type Run, and press Enter.
- In the Run window, type shell:startup to open the Startup folder.
- Once the Startup folder is opened, click the Home tab at the top of the folder. Then, select Paste to paste the shortcut file into the Startup folder.
There might be many other ways if you search online.
Let us know if this helps.
I tried the startup script before, also did it again just to verify.
It doesn't work as the modifications only applies to the console running the script on startup and closes after it finishes.
Thanks for the confirmation though, I still hope to see a workaround, like via an API call.
Create a batch file that runs the setvars.bat and/or any other environment variable setups. Then follow this with the command: start YourProGram arg arg arg
and then end with the command: exit
Dummy test example:
start notepad foo.txt
If you double click on foo.bat from the File Explorer, the foo.bat file runs, creates foo.txt, then uses notepad to open the file, then exits the cmd window executing foo.bat.
start YourProgram arg arg arg
Then Create a shortcut to YourLauncher.bat and set the properties to Run Minimized.
This will provide you to name the shortcut to whatever you want and to hide the short duration blip of the cmd window setting the environment and launching your app.