<div style>I am having a problem linking static libraries on for 32bit windows. I've got everything setup and working on Ubuntu 12.04 and have built one project which targets i386-linux, i386-win32, and x86_64-win64.</div>
<div style><br></div><div style>I'm using mingw-w64 on Ubuntu to create static lirbaries for openssl and the ssl crypto library.</div><div style><br></div><div style>The problem:</div><div style><br></div><div style>I can build and run my application on linux (i386-linux) and 64bit windows (x86_64-win64), but it fails to link properly when I target 32bit windows (i386-win32). The errors I am getting when I link for i386-win32 are:</div>
<div style><br></div><div style>Error: Undefined symbol: __time32</div><div style><div>Undefined symbol: __localtime32</div><div>Undefined symbol: __gmtime32</div></div><div style>There were 3 errors compiling module, stopping</div>
<div style><br></div><div style>I do not get these error when targeting x86_64-win64 and my test app run perfectly on 64bit windows.</div><div style><br></div><div style>Building a pascal application which links to two openssl static library files. Here is a snippet of my source code:</div>
<div style><br></div><div style>// Unit to link a static openssl library to my pascal applications</div><div style>// With this unit I can build a single exe with no external dependencies</div><div style>unit CryptoLib;</div>
<div style><div><br></div><div>{$i cross.inc}</div><div><br></div><div>interface</div><div><br></div><div>const</div><div> SSL_ERROR_NONE = 0;</div><div> // snip ...</div><div><br></div><div>{ SSL routines }</div><div><br>
</div><div>function SSL_library_init: Integer; cdecl; external;</div><div>// snip ...</div><div><br></div><div>{ Hashing routines }</div><div><br></div><div>function MD5_Init(out context: TMD5Ctx): LongBool; cdecl; external;</div>
<div>// snip ...</div><div><br></div><div>// if were using window i pull in ming-w64 libraries</div><div>{$ifdef windows}</div><div> // pulled in from x86_64-w64-mingw32/lib or i686-w64-mingw32/lib</div><div> // as determined by project target cpu</div>
<div> // these libs satisfy the compiler</div><div> {$linklib msvcrt}</div><div> {$linklib user32}</div><div> {$linklib kernel32}</div><div> {$linklib ws2_32}</div><div> {$linklib advapi32}</div><div> {$linklib gdi32}</div>
<div> // libgcc.a is placed in project i386-win32 and x86_64-win64 folders, i copy it from </div><div> // /usr/lib/gcc/i686-w64-mingw32/4.6 and /usr/lib/gcc/x86_64-w64-mingw32/4.6 respectively</div><div> // it needs to be here needed to resolve symbol "___chkstk_ms"</div>
<div> {$linklib gcc}</div><div> // The problem ... on i386-win32 these symbols are not resolved</div><div> // Error: Undefined symbol: __time32</div><div> // Undefined symbol: __localtime32</div><div> // Undefined symbol: __gmtime32</div>
<div> // There were 3 errors compiling module, stopping</div><div> //</div><div> // *BUT*</div><div> //</div><div> // When I switch to x86_64-win64 everything works fine</div><div> // and the test application run perfectly on 64bit windows</div>
<div>{$endif}</div><div><br></div><div>// project options set link </div><div>// i386-linux version build using make</div><div>// i686-ming-w64 and x86_64-ming-w64 build using make configure script</div><div><div><br></div>
<div>// openssl static libraries. path is set by target information</div><div>// $(ProjectDir)/i386-linux, i386-win32, or x86_64-win64</div></div><div><br></div><div>{$linklib libssl.a} // static ssl library</div><div>{$linklib libcrypto.a} // static ssl cryptography library</div>
<div><br></div><div>implementation</div><div><br></div><div>end.</div></div><div style><br></div><div style>In summary here is what I've done:</div><div style>I installed mingw-w64</div><div style>I built versions of openssl using both x86_64-w64-mingw32 and i686-w64-mingw32 successfully. </div>
<div style>I copied the resulting libssl.a and libcrypto.a static libraries to my project lib/i386-win32 and lib/x86_64-win64 folders.</div><div style>I setup my environment to refer to /usr/x86_64-w64-mingw32/lib or /usr/i686-w64-mingw32/lib in order to satisy msvcrt, user32 ect</div>
<div style>I had to copy libgcc.a from /usr/lib/gcc/x86_64-w64-mingw32/4.6 and /usr/lib/gcc/i686-w64-mingw32/4.6</div><div style> libgcc.a contains "___chkstk_ms" which needs to be resolved.</div><div style> i place a copy of the file in my project lib/i386-win32 and lib/x86_64-win64 folders.</div>
<div style>On linux I build for i386-linux and it succeeds. The test application on linux returns the expected results from openssl functions.</div><div style>On linux I build for x86_64-win64 and it succeeds. The test application is copied to my 64bit windows box and returns the expected results from openssl functions.</div>
<div style>On linux I build for i386-win32 and it the linker fails when it cannot locale __time32, __localtime32, and __gmtime32.</div><div style><br></div><div style>I have tried searching for: </div><div style>find . -name "*.a" -exec i686-w64-mingw32-nm -o {} \; | grep -i time32</div>
<div style>And I cannot find the functions.</div><div style><br></div><div style>I am at my wits end here. I could really use some help in finding why my pascal compiler needs __time32 when using a static lib built from i686-ming-w64</div>
<div style><br></div><div style>Thanks</div>