Help with exporting wine functions using spec file

Questions about Wine on Linux
Locked
J05HYYY
Newbie
Newbie
Posts: 1
Joined: Thu Apr 18, 2019 9:33 am

Help with exporting wine functions using spec file

Post by J05HYYY »

Hi, I am trying to export atexit and puts using wine, I wrote a spec file, libwinecompat.spec with the following:

Code: Select all

@ cdecl atexit(ptr) MSVCRT_atexit
@ cdecl puts(str) MSVCRT_puts
I build an ar archive with:

Code: Select all

winebuild --implib -o libwinecompat.a -E libwinecompat.spec
I then test using this program ...

Code: Select all

/* atexit example */
#include <stdio.h>      /* puts */
#include <stdlib.h>     /* atexit */

void fnExit1 (void)
{
  puts ("Exit function 1.");
}

void fnExit2 (void)
{
  puts ("Exit function 2.");
}

int main ()
{
  atexit (fnExit1);
  atexit (fnExit2);
  puts ("Main function.");
  return 0;
}
(it's from http://www.cplusplus.com/reference/cstdlib/atexit/ which I will plug ... [thanks])

...And compile with

Code: Select all

sudo mv /usr/i686-w64-mingw32/lib/libmsvcrt.a /usr/i686-w64-mingw32/lib/libmsvcrt.a.old
i686-w64-mingw32-gcc -nostdlib test.c -lmsvcrt -L. -lwinecompat
sudo mv /usr/i686-w64-mingw32/lib/libmsvcrt.a.old /usr/i686-w64-mingw32/lib/libmsvcrt.a
I know mingw's msvcrt is not linked and wine's msvcrt is. Unfortuately I still get the following errors:

Code: Select all

undefined reference to `puts'
undefined reference to `atexit'
Any help much appreciated
Locked