I'm making a library by compiling several fortran sources.
Compilation of each source is OK but when making the library with the call to ar I obtain an error.
Here is the full log obtained :
-------------- Générer : libsphr dans Test (compilateur : Compilateur Fortran GNU)---------------
mingw32-gfortran.exe -Jobj -w -Wall -finit-real=nan -O2 -fbounds-check -Wuninitialized -ftrapv -fimplicit-none -fno-automatic -I..\inc -c D:\Users\Gerard\Test\error_mesg.f90 -o obj\Test\error_mesg.o
mingw32-gfortran.exe -Jobj -w -Wall -finit-real=nan -O2 -fbounds-check -Wuninitialized -ftrapv -fimplicit-none -fno-automatic -I..\inc -c D:\Users\Gerard\Test\math_latlon_to_vect.f90 -o obj\Test\math_latlon_to_vect.o
mingw32-gfortran.exe -Jobj -w -Wall -finit-real=nan -O2 -fbounds-check -Wuninitialized -ftrapv -fimplicit-none -fno-automatic -I..\inc -c D:\Users\Gerard\Test\sphr_module_variables.f90 -o obj\Test\sphr_module_variables.o
mingw32-gfortran.exe -Jobj -w -Wall -finit-real=nan -O2 -fbounds-check -Wuninitialized -ftrapv -fimplicit-none -fno-automatic -I..\inc -c D:\Users\Gerard\Test\stripack.f90 -o obj\Test\stripack.o
mingw32-gfortran.exe -Jobj -w -Wall -finit-real=nan -O2 -fbounds-check -Wuninitialized -ftrapv -fimplicit-none -fno-automatic -I..\inc -c D:\Users\Gerard\Test\stripack_module_variables.f90 -o obj\Test\stripack_module_variables.o
mingw32-gfortran.exe -Jobj -w -Wall -finit-real=nan -O2 -fbounds-check -Wuninitialized -ftrapv -fimplicit-none -fno-automatic -I..\inc -c D:\Users\Gerard\Test\sphr_init.f90 -o obj\Test\sphr_init.o
mingw32-gfortran.exe -Jobj -w -Wall -finit-real=nan -O2 -fbounds-check -Wuninitialized -ftrapv -fimplicit-none -fno-automatic -I..\inc -c D:\Users\Gerard\Test\sphr_recup_lum.f90 -o obj\Test\sphr_recup_lum.o
mingw32-gfortran.exe -Jobj -w -Wall -finit-real=nan -O2 -fbounds-check -Wuninitialized -ftrapv -fimplicit-none -fno-automatic -I..\inc -c D:\Users\Gerard\Test\sphr_vis_crira_2_sphr.f90 -o obj\Test\sphr_vis_crira_2_sphr.o
ar.exe -r ..\lib\libsphr.a obj\Test\error_mesg.o obj\Test\math_latlon_to_vect.o obj\Test\sphr_module_variables.o obj\Test\stripack.o obj\Test\stripack_module_variables.o obj\Test\sphr_init.o obj\Test\sphr_recup_lum.o obj\Test\sphr_vis_crira_2_sphr.o\nranlib ..\lib\libsphr.a
ar.exe: creating ..\lib\libsphr.a
ar.exe: obj\Test\sphr_vis_crira_2_sphr.o\nranlib: No such file or directory
Le processus s'est terminé avec le code d'état 1 (2 minute(s), 9 seconde(s))
0 erreur(s), 0 avertissement(s) (2 minute(s), 9 seconde(s))
I think the problem comes from the \nranlib added at the end of enumeration of .o files in the ar command. The last .o is misinterpreted as a full name "obj\Test\sphr_vis_crira_2_sphr.o\nranlib" which does not exists, but obj\Test\sphr_vis_crira_2_sphr.o exists.
I have seen that in options_gfortran.xml there is a line with \nranlib (163). Could my problem comes from here ? What I can do ?
I use CB svn 8800 on windows xp compiled by myself, and tdm 4.7.1 compilers (gcc and gfortran).
gd_on
PS : this \nranlib appears in 3 other xml files.
PS 2 : May be I'm wrong but I suppose that this command at line 163 in options_gfortran.xml is in fact 2 commands separated by a new line character (the \n). On my PC, it's not interpreted correcly. But, may be it's possible to replace this 2 line command, by only a 1 line command, beginning by ar -s -r, so something like $lib_linker -s -r $static_output $link_objects. Adding -s should do the same thing than adding a call to ranlib ? it that right ? on every system ?
Sorry, I have not yet been able to test, however, this seems to be the section that is causing the problem.
Index: src/sdk/compiler.cpp
===================================================================
--- src/sdk/compiler.cpp (revision 8834)
+++ src/sdk/compiler.cpp (working copy)
@@ -960,7 +960,9 @@
else if (node->GetName() == wxT("Command"))
{
wxString cmd = node->GetAttribute(wxT("name"), wxEmptyString);
- CompilerTool tool(value, node->GetAttribute(wxT("ext"), wxEmptyString),
+ wxString unEscape = value;
+ unEscape.Replace(wxT("\\n"), wxT("\n")); // a single tool can support multiple commands
+ CompilerTool tool(unEscape, node->GetAttribute(wxT("ext"), wxEmptyString),
node->GetAttribute(wxT("gen"), wxEmptyString));
CommandType cmdTp = ctCount;
if (cmd == wxT("CompileObject"))
But, why priorities are automatically changed ?
This should not be happening... I am looking into it.
Would this feature work for my rm+ar feature request while building static libs?
What should I do to add rm before the ar command in the last step of building static libs?
The way previously discussed (http://forums.codeblocks.org/index.php/topic,16904.0.html) involved hard coding so this worked always for all compilers. However, you could instead patch the option in each compiler you want it in. For example:
Index: src/plugins/compilergcc/resources/compilers/options_gcc.xml
===================================================================
--- src/plugins/compilergcc/resources/compilers/options_gcc.xml (revision 8834)
+++ src/plugins/compilergcc/resources/compilers/options_gcc.xml (working copy)
@@ -122,6 +122,8 @@
value="$linker $libdirs -o $exe_output $link_objects $link_resobjects $link_options $libs -mwindows"/>
<Command name="LinkDynamic"
value="$linker -shared -Wl,--output-def=$def_output -Wl,--out-implib=$static_output -Wl,--dll $libdirs $link_objects $link_resobjects -o $exe_output $link_options $libs"/>
+ <Command name="LinkStatic"
+ value="cmd /c if exist $static_output del $static_output\n$lib_linker -r -s $static_output $link_objects"/>
</if>
<else>
<Command name="LinkNative"
@@ -130,9 +132,9 @@
value="$linker $libdirs -o $exe_output $link_objects $link_resobjects $link_options $libs"/>
<Command name="LinkDynamic"
value="$linker -shared $libdirs $link_objects $link_resobjects -o $exe_output $link_options $libs"/>
+ <Command name="LinkStatic"
+ value="test -w $static_output && rm -f $static_output\n$lib_linker -r -s $static_output $link_objects"/>
</else>
- <Command name="LinkStatic"
- value="$lib_linker -r -s $static_output $link_objects"/>
<Common name="cmds"/>
<Common name="re"/>
The command test modifies the exit code, and I forgot to reset it. (Sorry for not noticing sooner; I do not often do full rebuilds.)
Index: src/plugins/compilergcc/resources/compilers/options_gcc.xml
===================================================================
--- src/plugins/compilergcc/resources/compilers/options_gcc.xml (revision 8853)
+++ src/plugins/compilergcc/resources/compilers/options_gcc.xml (working copy)
@@ -133,7 +133,7 @@
<Command name="LinkDynamic"
value="$linker -shared $libdirs $link_objects $link_resobjects -o $exe_output $link_options $libs"/>
<Command name="LinkStatic"
- value="test -w $static_output && rm -f $static_output\n$lib_linker -r -s $static_output $link_objects"/>
+ value="test -w $static_output && rm -f $static_output; echo -n\n$lib_linker -r -s $static_output $link_objects"/>
</else>
<Common name="cmds"/>