Using -Wl will cause error and stop the complier.
For msvc the WL is for detailed error info , not for enter options.
log
-----------------------------------------------------------------------------------
builddir="`pwd`"; cd libcharset && make all && make install-lib libdir="$builddir/lib" includedir="$builddir/lib"
make[1]: Entering directory '/f/Software/Application/lib/libiconv-1.17/libcharset'
cd lib && make all
make[2]: Entering directory '/f/Software/Application/lib/libiconv-1.17/libcharset/lib'
/bin/sh ../libtool --mode=link cl.exe -g -o
libcharset.la -rpath F:\Software\Application\lib\libiconv/lib -version-info 1:0:0 -no-undefined localcharset.lo relocatable-stub.lo
libtool: link: rm -fr .libs/charset.exp
libtool: link: dumpbin -symbols -headers .libs/localcharset.obj .libs/relocatable-stub.obj | gawk ' {last_section=section; section=$ 3}; /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]}; /Section length .*#relocs.*(pick any)/{hide[last_section]=1}; /^ *Symbol name *: /{split($ 0,sn,":"); si=substr(sn[2],2)}; /^ *Type *: code/{print "T",si,substr(si,length(prfx))}; /^ *Type *: data/{print "I",si,substr(si,length(prfx))}; $ 0!~/External *\|/{next}; / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next}; {if(hide[section]) next}; {f="D"}; $ 0~/\(\).*\|/{f="T"}; {split($ 0,a,/\||\r/); split(a[2],s)}; s[1]~/^[@?]/{print f,s[1],s[1]; next}; s[1]~prfx {split(s[1],t,"@"); print f,t[1],substr(t[1],length(prfx))} ' prfx=^ | /usr/bin/sed '/ __gnu_lto/d' | /usr/bin/sed -e '/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/' | /usr/bin/sed -e '/^[AITW][ ]/s/.*[ ]//' | sort | uniq > .libs/charset.exp
libtool: link: if test DEF = "`/usr/bin/sed -n -e 's/^[ ]*//' -e '/^\(;.*\)*$/d' -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' -e q .libs/charset.exp`" ; then cp ".libs/charset.exp" ".libs/charset-1.dll.def"; echo ".libs\\charset-1.dll.def" > ".libs/charset-1.dll.exp"; else /usr/bin/sed -e 's/^/-link -EXPORT:/' < .libs/charset.exp > .libs/charset-1.dll.exp; fi
libtool: link: cl.exe -o .libs\\charset-1.dll .libs/localcharset.obj .libs/relocatable-stub.obj -g "@.libs\\charset-1.dll.exp" -Wl,-DLL,-IMPLIB:".libs\\charset.dll.lib"
用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.29.30152 版
版权所有(C) Microsoft Corporation。保留所有权利。
cl: 命令行 warning D9035 :“o”选项已否决,并将在将来的版本中移除
//-o parameter will be removed in future version.
cl -link -EXPORT:?_OptionsStorage@?1??__local_stdio_printf_options@@9@9,DATA
-link -EXPORT:libcharset_set_relocation_prefix
-link -EXPORT:locale_charset
cl: 命令行 error D8021 :无效的数值参数“/Wl,-DLL,-IMPLIB:.libs\charset.dll.lib”
//invalid parametermake[2]: *** [Makefile:55:
libcharset.la] Error 2
make[2]: Leaving directory '/f/Software/Application/lib/libiconv-1.17/libcharset/lib'
make[1]: *** [Makefile:34: all] Error 2
make[1]: Leaving directory '/f/Software/Application/lib/libiconv-1.17/libcharset'
make: *** [Makefile:41: lib/localcharset.h] Error 2
-----------------------------------------------------------------------------------
I modified the libtool on libcharset\lib\
And it continue compile then stop at
libtool: link: if test DEF = "`/usr/bin/sed -n -e 's/^[ ]*//' -e '/^\(;.*\)*$/d' -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' -e q .libs/charset.exp`" ; then cp ".libs/charset.exp" ".libs/charset-1.dll.def"; echo ".libs\\charset-1.dll.def" > ".libs/charset-1.dll.exp"; else /usr/bin/sed -e 's/^/-link -EXPORT:/' < .libs/charset.exp > .libs/charset-1.dll.exp; fi
libtool: link: cl.exe -o .libs\\charset-1.dll .libs/localcharset.obj .libs/relocatable-stub.obj -g "@.libs\\charset-1.dll.exp" -DLL,-IMPLIB:".libs\\charset.dll.lib"
用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.29.30152 版
版权所有(C) Microsoft Corporation。保留所有权利。
cl: 命令行 warning D9035 :“o”选项已否决,并将在将来的版本中移除
cl -link -EXPORT:?_OptionsStorage@?1??__local_stdio_printf_options@@9@9,DATA
-link -EXPORT:libcharset_set_relocation_prefix
-link -EXPORT:locale_charset
cl: 命令行 warning D9002 :忽略未知选项“-g”
Microsoft (R) Incremental Linker Version 14.29.30152.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:localcharset.exe
/out:.libs\charset-1.dll
-EXPORT:?_OptionsStorage@?1??__local_stdio_printf_options@@9@9,DATA
-EXPORT:libcharset_set_relocation_prefix
-EXPORT:locale_charset
.libs/localcharset.obj
.libs/relocatable-stub.obj
正在创建库 .libs\charset-1.lib 和对象 .libs\charset-1.exp
LINK : fatal error LNK1561: 必须定义入口点
//must to define the entry point
make: *** [Makefile:55:
libcharset.la] Error 2
Run complier again with modified parameter, it returned no error but can't open a file
cl.exe .libs/localcharset.obj .libs/relocatable-stub.obj /WL /link /out:test.dll "@.libs\\charset-1.dll.exp" /DLL /IMPLIB:".libs\\charset.dll.lib"
用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.29.30152 版
版权所有(C) Microsoft Corporation。保留所有权利。
Microsoft (R) Incremental Linker Version 14.29.30152.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:localcharset.exe
/out:test.dll
@.libs\\charset-1.dll.exp
/DLL
/IMPLIB:.libs\\charset.dll.lib
.libs/localcharset.obj
.libs/relocatable-stub.obj
LINK : fatal error LNK1181: 无法打开输入文件“@.libs\\charset-1.dll.exp”
It look like caused the command in below is invalid
dumpbin -symbols -headers .libs/localcharset.obj .libs/relocatable-stub.obj | gawk ' {last_section=section; section=$ 3}; /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]}; /Section length .*#relocs.*(pick any)/{hide[last_section]=1}; /^ *Symbol name *: /{split($ 0,sn,":"); si=substr(sn[2],2)}; /^ *Type *: code/{print "T",si,substr(si,length(prfx))}; /^ *Type *: data/{print "I",si,substr(si,length(prfx))}; $ 0!~/External *\|/{next}; / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next}; {if(hide[section]) next}; {f="D"}; $ 0~/\(\).*\|/{f="T"}; {split($ 0,a,/\||\r/); split(a[2],s)}; s[1]~/^[@?]/{print f,s[1],s[1]; next}; s[1]~prfx {split(s[1],t,"@"); print f,t[1],substr(t[1],length(prfx))} ' prfx=^ | /usr/bin/sed '/ __gnu_lto/d' | /usr/bin/sed -e '/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/' | /usr/bin/sed -e '/^[AITW][ ]/s/.*[ ]//' | sort | uniq > .libs/charset.explibtool: link: if test DEF = "`/usr/bin/sed -n -e 's/^[ ]*//' -e '/^\(;.*\)*$/d' -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' -e q .libs/charset.exp`" ; then cp ".libs/charset.exp" ".libs/charset-1.dll.def"; echo ".libs\\charset-1.dll.def" > ".libs/charset-1.dll.exp"; else /usr/bin/sed -e 's/^/-link -EXPORT:/' < .libs/charset.exp > .libs/charset-1.dll.exp; filibtool: link: cl.exe -o .libs\\charset-1.dll .libs/localcharset.obj .libs/relocatable-stub.obj -g "@.libs\\charset-1.dll.exp" -DLL,-IMPLIB:".libs\\charset.dll.lib"
I'm using GNU Awk 5.1.1, API: 3.1 (GNU MPFR 4.1.0-p13, GNU MP 6.2.1)
on msys
I saved the output of dumpbin
I find there are character escape problem.
On msys shell it shows "-bash: syntax error near unexpected token `then'"
But after using vc init script it entered to cmd.
The error become "'/{next}' is not recognized as an internal or external command,
operable program or batch file
I'm not sure where the problem is , but in "make" command the gawk never through error.
cl.exe .libs/localcharset.obj .libs/relocatable-stub.obj /WL /link /out:test.dll /DLL
using cl.exe .libs/localcharset.obj .libs/relocatable-stub.obj /WL /link /out:test.dll ".libs\\charset-1.dll.exp" /DLL /IMPLIB:".libs\\charset.dll.lib"
will return the charset-1.dll.exp is corrupt. Can't read from 0x96
Well my head is not clear. I'm going to sleep.
Conclusion: A symbol "@" in cl.exe parameter caused fatal error and the exp file looks wrong.
Maybe my modify is wrong. I know nothing about how to use export file with cl.exe
You can see without the exp file the cl works fine.
Anything past the /link is the options for linker.
//Appends additional information to an error or warning message.