4

This works with MSVC (compile and link).

extern void (_TMDLLENTRY * _TMDLLENTRY tpsetunsol _((void (_TMDLLENTRY *)(char _TM_FAR *, long, long)))) _((char _TM_FAR *, long, long));

But with GCC compiling is ok but linking phase fails with undefined reference pointing to this. Is this declaration already GCC compatible or is there possibly some other problem?

#define _TMDLLENTRY __stdcall
#define _TM_FAR

nm output from MSVC created object file:

00000000 N .debug$S
00000000 N .debug$S
00000000 N .debug$S
00000000 N .debug$S
00000000 N .debug$T
00000000 i .drectve
00000000 r .rdata
00000000 r .rdata
00000000 r .rdata
00000000 t .text
00000000 t .text
00000000 t .text
         U @__security_check_cookie@4
00aa766f a @comp.id
00000001 a @feat.00
         U ___security_cookie
         U __imp__CloseClipboard@0
         U __imp__EmptyClipboard@0
         U __imp__GlobalAlloc@8
         U __imp__GlobalLock@4
         U __imp__GlobalUnlock@4
         U __imp__MessageBoxA@16
         U __imp__OpenClipboard@4
         U __imp__SetClipboardData@8
00000000 T _CheckBroadcast@0
00000000 T _Inittpsetunsol@0
         U _memcpy
         U _memset
         U _sprintf
         U _tpchkunsol@0
         U _tpsetunsol@4
00000000 T _vCSLMsgHandler@12

nm output from MinGW compiler:

nm Release/broadc.o
00000000 b .bss
00000000 d .data
00000000 N .debug_abbrev
00000000 N .debug_aranges
00000000 N .debug_info
00000000 N .debug_line
00000000 N .debug_loc
00000000 r .eh_frame
00000000 r .rdata
00000000 t .text
00000104 T _CheckBroadcast@0
         U _CloseClipboard@0
         U _EmptyClipboard@0
         U _GlobalAlloc@8
         U _GlobalLock@4
         U _GlobalUnlock@4
0000010c T _Inittpsetunsol@0
         U _MessageBoxA@16
         U _OpenClipboard@4
         U _SetClipboardData@8
         U _sprintf
         U _tpchkunsol@0
         U _tpsetunsol
00000000 T _vCSLMsgHandler@12

Edit: Looking at _tpsetunsol symbol it is quite evident that MSVC and GCC produce different symbols.

GCC produces: U _tpsetunsol and MSVC: U _tpsetunsol@4

Is there a way to have GCC produce same symbol than MSVC?

Edit2: output from nm wtuxws32.lib (that is where tpsetunsol is defined)

WTUXWS32.dll:
00000000 i .idata$4
00000000 i .idata$5
00000000 t .text
00000000 I __imp__tpsetunsol@4
         U __IMPORT_DESCRIPTOR_WTUXWS32
00000000 T _tpsetunsol@4

Is this impossible to get to work with GCC? Thanks.

CKE
  • 1,533
  • 19
  • 18
  • 29
knocker_d
  • 506
  • 6
  • 16
  • It looks like there are several macros in that snippet for which most people probably have no idea how they're defined - you might want to post a simplified and/or pre-processed version of that line of code. Also, whenever asking a question about a compile/link error it's a good idea to post the actual (as in copy/pasted) error message. Precise version information about the tools involved is also usually helpful. – Michael Burr Apr 04 '13 at 15:00
  • @MichaelBurr: thank you for your response. Actually this question is derived from here. Let me know if you need any more information: http://stackoverflow.com/questions/15809604/linking-dilemma-undefined-reference-between-mingw-and-msvc-mingw-fails-msvc-w – knocker_d Apr 04 '13 at 18:26
  • Are you creating a DLL or static library? What is the output of `nm` on the object file containing the symbol? What is the output of `nm` on the object file referencing the "undefined reference"? – rubenvb Apr 05 '13 at 07:19
  • @rubenvb Thanks for the response. I'm creating win32 dll. Added output to the original post – knocker_d Apr 05 '13 at 11:34
  • The solution for this problem can be found here: http://stackoverflow.com/questions/15809604/linking-dilemma-undefined-reference-between-mingw-and-msvc-mingw-fails-msvc-w?lq=1 – knocker_d Apr 09 '13 at 12:31

0 Answers0