Author Topic: Run an .exe on another pc  (Read 1981 times)

fribir

  • Guest
Run an .exe on another pc
« on: February 17, 2023, 06:03:11 pm »
Hello,
I am using Code::Blocks for C++ programming (MinGW compiler) on a Win10 PC.
When I succesfully compile a program an .exe-file is created. I can then  run this exe-file also directly from the windows-console, without using Code::Blocks.
I did expect that this file can then also be run on any other PC, in particular a windows-PC. However, this seems not to be the case, some .dll is obviously missing.
How can I create a portable .exe-file?
Best regards

fribir

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1563
Re: Run an .exe on another pc
« Reply #1 on: February 17, 2023, 06:10:04 pm »
You can link the static version of your libraries, if available.

Some compilers (p.e. GCC) can link statically their own libraries, see your compiler's manual for more information.

Offline jpl

  • Single posting newcomer
  • *
  • Posts: 9
Re: Run an .exe on another pc
« Reply #2 on: February 17, 2023, 08:05:02 pm »
There are next ways to solve:
1. Write different code for different OS versions. In fact you able to write different code in project and say to IDE compile various code.
2. Provide libraries.
3. Write a guide for user.

I suggest the 1, because you will be skilled in IDE, compilation and code.
« Last Edit: February 17, 2023, 08:09:03 pm by jpl »

Offline cacb

  • Lives here!
  • ****
  • Posts: 536
Re: Run an .exe on another pc
« Reply #3 on: February 17, 2023, 10:55:51 pm »
Hello,
I am using Code::Blocks for C++ programming (MinGW compiler) on a Win10 PC.
When I succesfully compile a program an .exe-file is created. I can then  run this exe-file also directly from the windows-console, without using Code::Blocks.
I did expect that this file can then also be run on any other PC, in particular a windows-PC. However, this seems not to be the case, some .dll is obviously missing.
How can I create a portable .exe-file?
Best regards

fribir

Your program is portable if it has access to all the libraries it uses at run time. If you link with static libraries, that is not a problem. If you link with DLLs, you must make sure they are available also on the user machine.

You must know which DLLs your program depend on and distribute them with your program (or make sure the user has them). To see which DLLs (on Windows) your program depend on, use Build Options -> Linker Settings in Code::Blocks. Another good tool is https://github.com/lucasg/Dependencies

To "distribute them with your program" typically means to include the DLLs in a setup package, for example using InnoSetup. Sometimes, a simple zip file also works.