Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

gfortran didn't create a stand-alone exe

Status
Not open for further replies.

GerritGroot

Technical User
Nov 3, 2006
291
ES
Hi,

I took an executable, generated by gfortran to another computer (both are windows XP) and got the following error:

Code:
libgcc-s-dw2-1.dll missing

The computer where the exe came from had gfortran version 4.7.0:

Code:
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=c:/archivos de programa/gfortran/bin/../libexec/gcc/i586-pc-
mingw32/4.7.0/lto-wrapper.exe
Target: i586-pc-mingw32
Configured with: ../gcc-trunk/configure --prefix=/mingw --enable-languages=c,for
tran --with-gmp=/home/brad/gfortran/dependencies --disable-werror --enable-threa
ds --disable-nls --build=i586-pc-mingw32 --enable-libgomp --enable-shared --disa
ble-win32-registry --with-dwarf2 --disable-sjlj-exceptions --enable-lto
Thread model: win32
gcc version 4.7.0 20110419 (experimental) [trunk revision 170140] (GCC)

and produced an exe of about 600kB.

The computer where I tried to run this already compiled and build exe also had gfortran installed, namely version 4.6.0:

Code:
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=c:/archivos de programa/gfortran/bin/../libexec/gcc/i586-pc-
mingw32/4.6.0/lto-wrapper.exe
Target: i586-pc-mingw32
Configured with: ../gcc-trunk/configure --prefix=/mingw --enable-languages=c,for
tran --with-gmp=/home/brad/gfortran/dependencies --disable-werror --enable-threa
ds --disable-nls --build=i586-pc-mingw32 --enable-libgomp --disable-shared --dis
able-win32-registry --with-dwarf2 --disable-sjlj-exceptions --enable-lto
Thread model: win32
gcc version 4.6.0 20100620 (experimental) [trunk revision 161045] (GCC)

and produced after the surprisingly necessary recompilation an exe of 1400kB.

Ok, dfferent gfortran versions my result in different exe sizes, so far, though surprising, I don't care, but the exe should be interchangeable as a stand-alone between computers at least and run on any XP OS independently whether gfortran is installed or not.

As the file size is bigger in the second case, I guess the DLL is included in the exe when using gfortran 4.6.0
Testing so, indeed the second exe of 1400kB worked on the computer where gfortran 4.7 was installed.

In both cases I used the following compiler options:
Code:
-c	-Wall	-fbounds-check	-O3
[/code[

Does anyone know how to produce REAL executables (and no fakes like the one of 600kB) with gfortran 4.7?
 
I think you are talking about static-lly linked versus dynamic-lly linked programs....dynamic-lly linked ones need dynamic libraries to be available at run time, so, they are NOT standalone programs. Static-lly linked ones makes copies of static libraries and bring along within a now standalone exe file.

Read the literature on gfortran and find how to do one and the other.

 
To answer to my own question, I added:

Code:
-static-libgfortran -static-libgcc -static-libstdc++

when building, of which I guess "-static-libgcc" did the trick. No idea what the other static linking options do.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top