Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: neo1691 on December 23, 2011, 08:13:28 pm

Title: EXE fails to run on another PC
Post by: neo1691 on December 23, 2011, 08:13:28 pm
Hi.
I have compiled a very simple program and the executable file runs well on my PC.
I had sent the exe to my friend and it gave this error
 (http://i1133.photobucket.com/albums/m594/neo1691/Untitled.png)

Can somebody please explain me the exact steps on how to fix this issue by adding WHAT path WHERE?
I am very confused and i am new to C::B. I am just a beginner and am compiling program from books, not real time programming..and before C::B i was using turbo C++.

So i am very much new to this linker, paths, global variables and all!! :P
But i am loving C::B!!! 8) ;D
Title: Re: EXE fails to run on another PC
Post by: TomCatFort on December 23, 2011, 08:56:41 pm
The link of the image is broken.

Also the other PC might lack the needed runtime or some other dll. Runtimes needs to be installed and other dll files need to be distributed with your exe.
EDIT: And don't use global variables, use dependency injection.
Title: Re: EXE fails to run on another PC
Post by: neo1691 on December 23, 2011, 10:03:45 pm
The link of the image is broken.

Also the other PC might lack the needed runtime or some other dll. Runtimes needs to be installed and other dll files need to be distributed with your exe.
EDIT: And don't use global variables, use dependency injection.
fixed the broken image in the OP.
I can gives the dll file to my friend but i want to fix it permanently.
Title: Re: EXE fails to run on another PC
Post by: TomCatFort on December 23, 2011, 10:11:54 pm
1) Distribute that dll with the exe.
2) Some sources say, that you need to add the -static flag to the linker options.
Title: Re: EXE fails to run on another PC
Post by: Alpha on December 23, 2011, 10:35:44 pm
2) Some sources say, that you need to add the -static flag to the linker options.
This seems like a pretty reliable source: GCC online docs - Link Options (http://gcc.gnu.org/onlinedocs/gcc-4.6.2/gcc/Link-Options.html).

If you happen to use the flag -mthreads anywhere, you will want to remove it (Building a standalone exe (http://forums.codeblocks.org/index.php/topic,14127.0.html)).