Intel® oneAPI DPC++/C++ Compiler
Talk to fellow users of Intel® oneAPI DPC++/C++ Compiler and companion tools like Intel® oneAPI DPC++ Library, Intel® DPC++ Compatibility Tool, and Intel® Distribution for GDB*

Windows setvars.bat issues.

ChoonHo
Beginner
2,888 Views

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.

0 Kudos
7 Replies
PrasanthD_intel
Moderator
2,869 Views

Hi Choon,

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.


Regards

Prasanth


0 Kudos
ChoonHo
Beginner
2,862 Views

Yes,

However, I want to run a program .exe by double-clicking it.

Not through a command prompt, nor a special command prompt, nor Visual Studio.

Is there any way around this setvars.bat.

 

0 Kudos
PrasanthD_intel
Moderator
2,820 Views

Hi,


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:

  1. Create a shortcut to the batch file.
  2. Once the shortcut is created, right-click the shortcut file and select Cut.
  3. Press Start, type Run, and press Enter.
  4. In the Run window, type shell:startup to open the Startup folder.
  5. 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.


Regards

Prasanth



0 Kudos
ChoonHo
Beginner
2,809 Views

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.

 

0 Kudos
jimdempseyatthecove
Honored Contributor III
2,798 Views

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:

foo.bat containing:

  date /t>foo.txt
  start notepad foo.txt
  exit

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.

YourLauncher.bat

    setvars.bat
    start YourProgram arg arg arg
    exit

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.

Jim Dempsey

0 Kudos
ChoonHo
Beginner
2,794 Views

Yes, I believe this would work, for an executable.

However, for a library (dll), it is weird to impose such a requirement on the executable (or other libraries) consuming the library.

 

0 Kudos
PrasanthD_intel
Moderator
2,804 Views

Hi Choon,


We are forwarding this thread to the internal team who can comment better regarding if a workaround is possible or not.


Regards

Prasanth


0 Kudos
Reply