<div dir="ltr">Looking at the export directive, it seems like something is off in name mangling.<div>-export:__Z16myveryeasymethodv</div><div><br></div><div style>The double underscore seems wrong, which suggests we're applying both C and C++ mangling.  Use a version of nm that works on COFF to make sure that the .o has the same name as the -export.</div>
<div style><br></div><div style>If it's broken, try building TOT clang, and if that doesn't work, please file a bug.  There was a recent bugfix for a similar issue which had to do with stdcall mangling, but I'm not sure if it's the same as this one.</div>
<div><div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, May 18, 2013 at 11:08 AM, Stephen Kelly <span dir="ltr"><<a href="mailto:steveire@gmail.com" target="_blank">steveire@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im">Reid Kleckner wrote:<br>
<br>
> Since you're using the mingw linker, you should probably target mingw.<br>
> Try<br>
> using i386-pc-mingw32 as the triple.  I think using win32 as the os<br>
> assumes you want the Visual Studio toolchain by default, and I don't<br>
> recall what else controls it.<br>
><br>
<br>
</div>Thanks for the pointer. That indeed does not warn when linking, but it also<br>
doesn't link at all:<br>
<br>
stephen@hal:/tmp$ i686-w64-mingw32-gcc -v -shared lib.o -o example_dll.dll -<br>
Wl,--out-implib,libexample_dll.a<br>
Using built-in specs.<br>
COLLECT_GCC=i686-w64-mingw32-gcc<br>
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-w64-mingw32/4.6/lto-wrapper<br>
Target: i686-w64-mingw32<br>
Configured with: ../../src/configure --build=x86_64-linux-gnu --prefix=/usr<br>
--includedir='/usr/include' --mandir='/usr/share/man' --<br>
infodir='/usr/share/info' --sysconfdir=/etc --localstatedir=/var --<br>
libexecdir='/usr/lib/gcc-mingw-w64' --disable-maintainer-mode --disable-<br>
dependency-tracking --prefix=/usr --enable-shared --enable-static --disable-<br>
multilib --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib<br>
--without-included-gettext --libdir=/usr/lib --enable-libstdcxx-time=yes --<br>
with-tune=generic --enable-version-specific-runtime-libs --enable-<br>
threads=win32 --enable-fully-dynamic-string --enable-sjlj-exceptions --<br>
enable-languages=c,c++,fortran,objc,obj-c++,ada --enable-lto --with-plugin-<br>
ld --target=i686-w64-mingw32 --with-gxx-include-dir=/usr/include/c++/4.6 --<br>
with-as=/usr/bin/i686-w64-mingw32-as --with-ld=/usr/bin/i686-w64-mingw32-ld<br>
Thread model: win32<br>
gcc version 4.6.3 (GCC)<br>
COMPILER_PATH=/usr/lib/gcc/i686-w64-mingw32/4.6/:/usr/lib/gcc/i686-w64-<br>
mingw32/4.6/:/usr/lib/gcc/i686-w64-mingw32/:/usr/lib/gcc/i686-w64-<br>
mingw32/4.6/:/usr/lib/gcc/i686-w64-mingw32/<br>
LIBRARY_PATH=/usr/lib/gcc/i686-w64-mingw32/4.6/:/usr/lib/gcc/i686-w64-<br>
mingw32/4.6/../../../../i686-w64-mingw32/lib/../lib/:/usr/lib/gcc/i686-w64-<br>
mingw32/4.6/../../../../i686-w64-mingw32/lib/<br>
COLLECT_GCC_OPTIONS='-v' '-shared' '-o' 'example_dll.dll' '-mtune=generic'<br>
'-march=pentiumpro'<br>
 /usr/lib/gcc/i686-w64-mingw32/4.6/collect2 -m i386pe --shared -Bdynamic -e<br>
_DllMainCRTStartup@12 --enable-auto-image-base -o example_dll.dll<br>
/usr/lib/gcc/i686-w64-mingw32/4.6/../../../../i686-w64-<br>
mingw32/lib/../lib/dllcrt2.o /usr/lib/gcc/i686-w64-mingw32/4.6/crtbegin.o -<br>
L/usr/lib/gcc/i686-w64-mingw32/4.6 -L/usr/lib/gcc/i686-w64-<br>
mingw32/4.6/../../../../i686-w64-mingw32/lib/../lib -L/usr/lib/gcc/i686-w64-<br>
mingw32/4.6/../../../../i686-w64-mingw32/lib lib.o --out-implib<br>
libexample_dll.a -lmingw32 -lgcc_eh -lgcc -lmoldname -lmingwex -lmsvcrt -<br>
ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_eh -lgcc -lmoldname<br>
-lmingwex -lmsvcrt /usr/lib/gcc/i686-w64-mingw32/4.6/crtend.o<br>
Cannot export myveryeasymethod(): symbol not found<br>
collect2: ld returned 1 exit status<br>
<br>
<br>
stephen@hal:/tmp$ cat lib.o<br>
Lݘ�Q�.textd P`.drectvej�*� -export:__Z16myveryeasymethodv.text.drectve<br>
_Z16myveryeasymethodv<br>
stephen@hal:/tmp$ cat lib.o  | i686-w64-mingw32-c++filt<br>
Lݘ�Q� `.drectve�*� -export:myveryeasymethod() [clone .text]<br>
<br>
However, if I remove the BUILDING_EXAMPLE_DLL from in front of<br>
myveryeasymethod() it does successfully link, which is the opposite of what<br>
I expect...<br>
<div class=""><div class="h5"><br>
Thanks,<br>
<br>
Steve.<br>
<br>
<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</div></div></blockquote></div><br></div></div></div></div>