News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Run an .exe on another pc

Started by fribir, February 17, 2023, 06:03:11 PM

Previous topic - Next topic

fribir

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

Miguel Gimenez

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.

jpl

#2
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.

cacb

Quote from: fribir 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

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.