<div dir="ltr">Since you're using the mingw linker, you should probably target mingw.  Try using i386-pc-mingw32 as the triple.  I think using win32 as the os assumes you want the Visual Studio toolchain by default, and I don't recall what else controls it.</div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, May 18, 2013 at 10:29 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
I have now also tried to cross compile to windows with clang.<br>
<br>
 $ clang -v -target i386-pc-win32 -c main.c<br>
<br>
doesn't have any built in include paths, but I can supply them as copied<br>
from the output of i686-w64-mingw32-gcc -v -c main.c.<br>
<br>
 $ clang -v -target i386-pc-win32 -I/usr/lib/gcc/i686-w64-<br>
mingw32/4.6/include -I/usr/lib/gcc/i686-w64-mingw32/4.6/include-fixed -<br>
I/usr/lib/gcc/i686-w64-mingw32/4.6/../../../../i686-w64-mingw32/include -c<br>
main.c<br>
ignoring nonexistent directory "/usr/bin/../lib/clang/3.2/include"<br>
ignoring nonexistent directory "C:/Program Files/Microsoft Visual Studio<br>
10.0/VC/include"<br>
ignoring nonexistent directory "C:/Program Files/Microsoft Visual Studio<br>
9.0/VC/include"<br>
ignoring nonexistent directory "C:/Program Files/Microsoft Visual Studio<br>
9.0/VC/PlatformSDK/Include"<br>
ignoring nonexistent directory "C:/Program Files/Microsoft Visual Studio<br>
8/VC/include"<br>
ignoring nonexistent directory "C:/Program Files/Microsoft Visual Studio<br>
8/VC/PlatformSDK/Include"<br>
#include "..." search starts here:<br>
#include <...> search starts here:<br>
 /usr/lib/gcc/i686-w64-mingw32/4.6/include<br>
 /usr/lib/gcc/i686-w64-mingw32/4.6/include-fixed<br>
 /usr/lib/gcc/i686-w64-mingw32/4.6/../../../../i686-w64-mingw32/include<br>
End of search list.<br>
<br>
seems to work fine. Should clang not add the windows paths to the search<br>
list if host != Windows? It tries to use link.exe to link too, which<br>
obviously doesn't work:<br>
<br>
 $ clang -v -target i386-pc-win32 main.o<br>
 Ubuntu clang version 3.2-1~exp9ubuntu1 (tags/RELEASE_32/final) (based on<br>
LLVM 3.2)<br>
 Target: i386-pc-win32<br>
 Thread model: posix<br>
 "link.exe" -out:a.out -defaultlib:libcmt -nologo main.o<br>
 clang: error: unable to execute command: No such file or directory<br>
 clang: error: linker command failed due to signal (use -v to see<br>
invocation)<br>
<br>
however, I can link it with i686-w64-mingw32-gcc main.o and execute it in<br>
wine.<br>
<br>
<br>
Next up, a dll:<br>
<br>
 stephen@hal:/tmp$ cat lib.h<br>
<br>
 #ifdef BUILDING_EXAMPLE_DLL<br>
 #define EXAMPLE_DLL __declspec(dllexport)<br>
 #else<br>
 #define EXAMPLE_DLL __declspec(dllimport)<br>
 #endif<br>
<br>
 int EXAMPLE_DLL myveryeasymethod(void);<br>
<br>
 stephen@hal:/tmp$ cat lib.c<br>
<br>
 #include "lib.h"<br>
<br>
 int myveryeasymethod(void)<br>
 { return 42; }<br>
<br>
<br>
Compiling with -DBUILDING_EXAMPLE_DLL works fine.<br>
<br>
 $ i686-w64-mingw32-gcc -shared lib.o -Wl,--out-implib,libexample_dll.a -o<br>
example_dll.dll<br>
 Warning: .drectve `/EXPORT:_myveryeasymethod' unrecognized<br>
<br>
That warning does not appear when the file is compiled with gcc. There is a<br>
similar warning when building c++:<br>
<br>
 $ i686-w64-mingw32-g++ -shared lib.o -Wl,--out-implib,libexample_dll.a -o<br>
example_dll.dll<br>
 Warning: .drectve `/EXPORT:myveryeasymethod()' unrecognized<br>
<br>
What do these mean? Should I file a bug report?<br>
<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>
</blockquote></div><br></div>