c++ - MinGW on Cygwin. Some issues on linking the GNU Scientific Library -
i have couple of issues when linking gnu scientific library mingw on cygwin. let me explain situation.
i have installed both mingw , gsl cygwin setup utility. path /usr/i686-w64-mingw32/sys-root/mingw/bin/
contains:
gsl-config libgfortran-3.dll libssp-0.dll libatomic-1.dll libgomp-1.dll libstdc++-6.dll libblas.dll libgomp-plugin-host_nonshm-1.dll libvtv_stubs-0.dll libcblas.dll libgsl-19.dll libvtv-0.dll libgcc_s_sjlj-1.dll libquadmath-0.dll libwinpthread-1.dll
the path /usr/i686-w64-mingw32/sys-root/mingw/include/
contains gsl headers.
the path /usr/i686-w64-mingw32/sys-root/mingw/lib/
contains, among many other libraries, files libgsl.dll.a
, libgslcblas.dll.a
if compile using
i686-w64-mingw32-g++.exe -std=c++11 -s somegslapp.cpp -lgsl -static-libgcc -wl,-bstatic -lstdc++ -lpthread -lm
it compiles without problem, , executable can run provided /usr/i686-w64-mingw32/sys-root/mingw/bin/
added path environment variable.
let me point out first strange issue. if not set path variable, in order run program, have copy files in /usr/i686-w64-mingw32/sys-root/mingw/bin/
path executable located. careful, files, not gsl dlls. strange, because other libraries linked statically. indeed, have other programs not use gsl, , when compile them statically linking standard library in same way somegslapp above, can run without setting path, nor copying dlls.
the second issue happens when try statically link gsl. if try:
i686-w64-mingw32-g++.exe -std=c++11 -s somegslapp.cpp -static-libgcc -wl,-bstatic -lstdc++ -lpthread -lm -lgsl
the gnu linker returns error cannot find -lgsl
. tried add
-i/usr/i686-w64-mingw32/sys-root/mingw/include/ -l/usr/i686-w64-mingw32/sys-root/mingw/lib/
but not change anything, still same error.
so, concerning first issue, explain why need copy dlls? tentative explanation gsl dll needs others, cannot understand why fortran dll needed.
concerning second issue, tell me how link gsl statically?
update on second issue
if link statically using
i686-w64-mingw32-g++.exe -std=c++11 -s somegslapp.cpp -static-libgcc -wl,-bstatic -lstdc++ -lpthread -lm -lgsl.dll
i not error cannot find -lgsl
anymore, compilation , linking terminate without error or warning, executable still not run if not set path or copy dlls seen above. seems static linking not working gsl.
try adding -static. linking dll might not generate static dependency on library without according flag, if @ all. linking stdc++ not needed. (as -w,.. if -static used.
Comments
Post a Comment