0

I have been writing some simple scripts in C++ for my Physics lab experiments (at uni), and am wondering where to make my setup file install my programs to on somebody else's computer?

What is the best practice for this on Windows and Mac/Linux?

khelwood
  • 55,782
  • 14
  • 81
  • 108
  • 1
    In windows you install to Program Files like most programs. Your installer software should do that by default. I use NSIS but there are several other choices: [https://nsis.sourceforge.io/Main_Page](https://nsis.sourceforge.io/Main_Page) – drescherjm Mar 17 '22 at 14:26
  • 2
    On linux you first have to think if you want to install from source code or if not what distributions and package managers you will want to support. – drescherjm Mar 17 '22 at 14:31

1 Answers1

2

For Windows, in "Program Files" for native mode (i.e. 32-bits programs on 32-bits Windows, 64-bits programs on 64-bits Windows).

A 32-bits program on a 64-bits Windows should be in "Program Files (x86)". You have environment variables to get the real paths of these folders, or you can use also Win32 API to retrieve them.

There is other things to think about, like where to save data produced by your application (usually, a subfolder of %APPDATA%). This directory must contains ALL files who are written by your program, like configuration file, since "Program Files" is write-protected in a non-elevated process.

Please also note that global resources, i.e. writable and used by ALL users, should go in "ProgramData" instead of user's profile.

Wisblade
  • 1,483
  • 4
  • 13
  • Thank you so much!! This was very helpful... I will keep that all in mind. – Gregor Hartl Watters Mar 17 '22 at 16:14
  • You're welcome. Feel free to ask for more details, once you chose your installer software and have a definitive compiled product (i.e. knowing the details of your application and its behavior regarding files needing a write access). – Wisblade Mar 17 '22 at 16:54
  • Thank you!! Really it's something quite modest, it's just a program to help compute values for a physics experiment at my uni (but it does have program files, such as .dat files used to save the data), and since I always share my programs with other people doing the experiment I wanted to know where I should instally my software on their computers! Thank you again, I will aim to install all of my stuff in AppData (at least on Windows) and I also think I've figured out how to update the path variable using the setx PATH "newPathName" command. Cheers! – Gregor Hartl Watters Mar 17 '22 at 19:27
  • 1
    Tools like InnoSetup (my prefered) or NSIS gives tons of examples of "how to..." for usual operations: adding something to PATH, put an icon somewhere, changing access rights, managing dependencies, etc. so it won't be a problem. As I said, `%AppData%` is for writable stuff dedicated to current user. `ProgramData`, also known as `%AllUsersProfile%`, is for writable stuff shared by everyone and/or for "big" data that you don't want to have in multiple copies. Also, don't forget to take care of UPDATES, think your install script with this possibility in mind! Have fun! – Wisblade Mar 18 '22 at 15:02
  • once again, very helpful!! I'm new to programming, but it is a lot of fun! And it helps having places like this to clear things up :) I'll have a look into all that you've sent! Have yourself a lovely day – Gregor Hartl Watters Mar 18 '22 at 22:11