Hello:
I am trying to link a C program which gives me a Day Light Savings Flag Word to a
Assembler program. The Linking has been a Verbose pain in the butt.
this will be a long Read.
C:\masm32\bin>link /SUBSYSTEM:CONSOLE /RELEASE /VERBOSE /MAP test.obj __isDST.ob
j > linkv.txt
I pipe it to a temp file so we can edit the temp file are you ready!
linkv.txt for Your Viewing Pleasure.
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
Start Pass1
Processed /DEFAULTLIB:\masm32\lib\masm32.lib
Processed /DEFAULTLIB:\masm32\lib\gdi32.lib
Processed /DEFAULTLIB:\masm32\lib\user32.lib
Processed /DEFAULTLIB:\masm32\lib\kernel32.lib
Processed /DEFAULTLIB:\masm32\lib\Comctl32.lib
Processed /DEFAULTLIB:\masm32\lib\comdlg32.lib
Processed /DEFAULTLIB:\masm32\lib\shell32.lib
Processed /DEFAULTLIB:\masm32\lib\oleaut32.lib
Processed /DEFAULTLIB:\masm32\lib\ole32.lib
Processed /DEFAULTLIB:\masm32\lib\msvcrt.lib
__isDST.obj : warning LNK4044: unrecognized option "manifestdependency:type='win32' name='Microsoft.VC90.DebugCRT' version='9.0.21022.8' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b'"; ignored
Processed /DEFAULTLIB:uuid.lib
Processed /DEFAULTLIB:MSVCRTD
Processed /DEFAULTLIB:OLDNAMES
Searching Libraries
Searching \masm32\lib\masm32.lib:
Searching \masm32\lib\gdi32.lib:
Searching \masm32\lib\user32.lib:
Found _MessageBoxA@16
Referenced in test.obj
Loaded user32.lib(user32.dll)
Found __IMPORT_DESCRIPTOR_user32
Referenced in user32.lib(user32.dll)
Loaded user32.lib(user32.dll)
Found __NULL_IMPORT_DESCRIPTOR
Referenced in user32.lib(user32.dll)
Loaded user32.lib(user32.dll)
Found user32_NULL_THUNK_DATA
Referenced in user32.lib(user32.dll)
Loaded user32.lib(user32.dll)
Searching \masm32\lib\kernel32.lib:
Found _ExitProcess@4
Referenced in test.obj
Loaded kernel32.lib(kernel32.dll)
Found _GetDateFormatA@24
Referenced in test.obj
Loaded kernel32.lib(kernel32.dll)
Found _GetSystemTime@4
Referenced in test.obj
Loaded kernel32.lib(kernel32.dll)
Found _GetTimeFormatA@24
Referenced in test.obj
Loaded kernel32.lib(kernel32.dll)
Found __IMPORT_DESCRIPTOR_kernel32
Referenced in kernel32.lib(kernel32.dll)
Referenced in kernel32.lib(kernel32.dll)
Referenced in kernel32.lib(kernel32.dll)
Referenced in kernel32.lib(kernel32.dll)
Loaded kernel32.lib(kernel32.dll)
Found kernel32_NULL_THUNK_DATA
Referenced in kernel32.lib(kernel32.dll)
Loaded kernel32.lib(kernel32.dll)
Searching \masm32\lib\Comctl32.lib:
Searching \masm32\lib\comdlg32.lib:
Searching \masm32\lib\shell32.lib:
Searching \masm32\lib\oleaut32.lib:
Searching \masm32\lib\ole32.lib:
Searching \masm32\lib\msvcrt.lib:
Found __imp___localtime64
Referenced in __isDST.obj
Loaded msvcrt.lib(msvcrt.dll)
Found __imp___time64
Referenced in __isDST.obj
Loaded msvcrt.lib(msvcrt.dll)
Found __IMPORT_DESCRIPTOR_msvcrt
Referenced in msvcrt.lib(msvcrt.dll)
Referenced in msvcrt.lib(msvcrt.dll)
Loaded msvcrt.lib(msvcrt.dll)
Found msvcrt_NULL_THUNK_DATA
Referenced in msvcrt.lib(msvcrt.dll)
Loaded msvcrt.lib(msvcrt.dll)
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\lib\uuid.lib:
Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\LIB\MSVCRTD.lib:
Found __RTC_CheckEsp
Referenced in __isDST.obj
Loaded MSVCRTD.lib(_stack_.obj)
Found __RTC_Shutdown
Referenced in __isDST.obj
Loaded MSVCRTD.lib(_init_.obj)
Found "void __cdecl _RTC_Failure(void *,int)" (?_RTC_Failure@@YAXPAXH@Z)
Referenced in MSVCRTD.lib(_stack_.obj)
Loaded MSVCRTD.lib(_error_.obj)
Found __RTC_SetErrorFuncW
Referenced in MSVCRTD.lib(_init_.obj)
Loaded MSVCRTD.lib(_userapi_.obj)
Found __CRT_RTC_INITW
Referenced in MSVCRTD.lib(_init_.obj)
Loaded MSVCRTD.lib(MSVCR90D.dll)
Found ___security_cookie
Referenced in MSVCRTD.lib(_error_.obj)
Loaded MSVCRTD.lib(gs_cookie.obj)
Found __except_handler4
Referenced in MSVCRTD.lib(_error_.obj)
Loaded MSVCRTD.lib(chandler4gs.obj)
Found "int __cdecl _RTC_GetSrcLine(unsigned char *,wchar_t *,unsigned long,int *,wchar_t *,unsigned long)" (?_RTC_GetSrcLine@@YAHPAEPA_WKPAH1K@Z)
Referenced in MSVCRTD.lib(_error_.obj)
Loaded MSVCRTD.lib(_pdblkup_.obj)
Found @__security_check_cookie@4
Referenced in MSVCRTD.lib(_error_.obj)
Referenced in MSVCRTD.lib(chandler4gs.obj)
Referenced in MSVCRTD.lib(_pdblkup_.obj)
Loaded MSVCRTD.lib(secchk.obj)
Found __IMPORT_DESCRIPTOR_MSVCR90D
Referenced in MSVCRTD.lib(MSVCR90D.dll)
Loaded MSVCRTD.lib(MSVCR90D.dll)
Found __except_handler4_common
Referenced in MSVCRTD.lib(chandler4gs.obj)
Loaded MSVCRTD.lib(MSVCR90D.dll)
Found ___report_gsfailure
Referenced in MSVCRTD.lib(secchk.obj)
Loaded MSVCRTD.lib(gs_report.obj)
Found MSVCR90D_NULL_THUNK_DATA
Referenced in MSVCRTD.lib(MSVCR90D.dll)
Loaded MSVCRTD.lib(MSVCR90D.dll)
Found __crt_debugger_hook
Referenced in MSVCRTD.lib(gs_report.obj)
Loaded MSVCRTD.lib(MSVCR90D.dll)
Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\LIB\OLDNAMES.lib:
Searching \masm32\lib\masm32.lib:
Searching \masm32\lib\gdi32.lib:
Searching \masm32\lib\user32.lib:
Searching \masm32\lib\kernel32.lib:
Found __imp__IsDebuggerPresent@0
Referenced in MSVCRTD.lib(_error_.obj)
Referenced in MSVCRTD.lib(gs_report.obj)
Loaded kernel32.lib(kernel32.dll)
Found __imp__RaiseException@16
Referenced in MSVCRTD.lib(_error_.obj)
Loaded kernel32.lib(kernel32.dll)
Found __imp__DebugBreak@0
Referenced in MSVCRTD.lib(_error_.obj)
Loaded kernel32.lib(kernel32.dll)
Found __imp__WideCharToMultiByte@32
Referenced in MSVCRTD.lib(_error_.obj)
Loaded kernel32.lib(kernel32.dll)
Found __imp__MultiByteToWideChar@24
Referenced in MSVCRTD.lib(_error_.obj)
Loaded kernel32.lib(kernel32.dll)
Found __imp__lstrlenA@4
Referenced in MSVCRTD.lib(_error_.obj)
Loaded kernel32.lib(kernel32.dll)
Found __imp__GetProcAddress@8
Referenced in MSVCRTD.lib(_error_.obj)
Referenced in MSVCRTD.lib(_pdblkup_.obj)
Loaded kernel32.lib(kernel32.dll)
Found __imp__LoadLibraryA@4
Referenced in MSVCRTD.lib(_error_.obj)
Referenced in MSVCRTD.lib(_pdblkup_.obj)
Loaded kernel32.lib(kernel32.dll)
Found __imp__HeapFree@12
Referenced in MSVCRTD.lib(_pdblkup_.obj)
Loaded kernel32.lib(kernel32.dll)
Found __imp__HeapAlloc@12
Referenced in MSVCRTD.lib(_pdblkup_.obj)
Loaded kernel32.lib(kernel32.dll)
Found __imp__GetProcessHeap@0
Referenced in MSVCRTD.lib(_pdblkup_.obj)
Loaded kernel32.lib(kernel32.dll)
Found __imp__GetModuleFileNameW@12
Referenced in MSVCRTD.lib(_pdblkup_.obj)
Loaded kernel32.lib(kernel32.dll)
Found __imp__VirtualQuery@12
Referenced in MSVCRTD.lib(_pdblkup_.obj)
Loaded kernel32.lib(kernel32.dll)
Found __imp__FreeLibrary@4
Referenced in MSVCRTD.lib(_pdblkup_.obj)
Loaded kernel32.lib(kernel32.dll)
Found __imp__TerminateProcess@8
Referenced in MSVCRTD.lib(gs_report.obj)
Loaded kernel32.lib(kernel32.dll)
Found __imp__GetCurrentProcess@0
Referenced in MSVCRTD.lib(gs_report.obj)
Loaded kernel32.lib(kernel32.dll)
Found __imp__UnhandledExceptionFilter@4
Referenced in MSVCRTD.lib(gs_report.obj)
Loaded kernel32.lib(kernel32.dll)
Found __imp__SetUnhandledExceptionFilter@4
Referenced in MSVCRTD.lib(gs_report.obj)
Loaded kernel32.lib(kernel32.dll)
Searching \masm32\lib\Comctl32.lib:
Searching \masm32\lib\comdlg32.lib:
Searching \masm32\lib\shell32.lib:
Searching \masm32\lib\oleaut32.lib:
Searching \masm32\lib\ole32.lib:
Searching \masm32\lib\msvcrt.lib:
Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\lib\uuid.lib:
Done Searching Libraries
End Pass1
test.obj : error LNK2001: unresolved external symbol __isDST@4
test.exe : fatal error LNK1120: 1 unresolved externals
isDST.CPP
// IsDST.cpp : Defines the entry point for the console application.
// Friday, July 17, 2015 4:20:47 PM
#include "stdafx.h"
#include <windows.h>
#include <time.h>
int __isDST(int A)
{
time_t t;
t = time(0);
tm* P = localtime ( &t );
return P->tm_isdst;
}
int _tmain(int argc, _TCHAR* argv[])
{
time_t t;
t = time(0);
tm* P = localtime ( &t );
return P->tm_isdst;
}
test.asm
; TEST.ASM Friday, September 20, 2013 11:21:00 PM
; Modified Friday, July 17, 2015 4:09:41 PM
include \masm32\include\masm32rt.inc
.data
public stm
stm SYSTEMTIME<>
public dtbuf
dtbuf db 260 dup(0)
align 8
pdwIsDST dd 0
pdt dd stm
AppName db "Datum und Uhrzeit in der deutschen: ", 0
crlf db 13, 10, 0
tf db "HH':'mm':'ss tt", 0
StartT dd 0
__isDST PROTO:DWORD
;IsDaylightSavingTime PROTO pdt:PTR DATETIME, pdwIsDST:PTR DWORD
.code
start proc
mov esi, offset stm
invoke GetSystemTime, esi; Get UTC
mov ax, stm.wHour
inc ax; GET UTC +1 i e CET
mov stm.wHour, ax
call __isDST
and eax,eax
jz @F
mov ax, stm.wHour; is Daylight Savings Time i e Summer Time
inc ax; GET UTC +1 i e CET
mov stm.wHour, ax
@@:
invoke GetDateFormat, 1031, DATE_LONGDATE, addr stm, 0, addr dtbuf, 260
lea esi, offset dtbuf
add esi , eax ; eax is len of format
mov byte ptr [ esi - 1 ] , " "
mov StartT, esi
INVOKE GetTimeFormat,1031,TIME_FORCE24HOURFORMAT,addr stm, addr tf, esi,32
invoke MessageBox, NULL, addr dtbuf, addr AppName, MB_OK
exit
ret
start endp
end start
Any Ideas Please?
You didn't show how you compiled the cpp file but if you didn't add /TC to use the C compiler then you just need to add extern "C" before the function declaration. Otherwise the C++ compiler will do name mangling
extern "C" int __isDST(int a)
{
time_t t;
t = time(0);
tm* P = localtime ( &t );
return P->tm_isdst;
}
It looks like the asm file is expecting an stdcall function though, which'd require this:
extern "C" int __stdcall __isDST(void) /* Your asm file doesn't provide an argument, with cdecl/fastcall that's fine. With stdcall it'll unbalance the stack. So I changed it to no arguments */
{
time_t t;
t = time(0);
tm* P = localtime ( &t );
return P->tm_isdst;
}
If you are compiling with /TC then its probably just the __stdcall thing, and you wouldn't need any extern "C".
Hello adeyblue:
// IsDST.cpp : Defines the entry point for the console application.
// Friday, July 17, 2015 10:07:00 PM
#include "stdafx.h"
#include <windows.h>
#include <time.h>
extern "C" int __stdcall __isDST(int)
{
time_t t;
t = time(0);
tm* P = localtime ( &t );
return P->tm_isdst;
}
int _tmain(int argc, _TCHAR* argv[])
{
time_t t;
t = time(0);
tm* P = localtime ( &t );
return P->tm_isdst;
}
Well we can't get it to compile?
1>------ Build started: Project: IsDST, Configuration: Debug Win32 ------
1>Compiling...
1>IsDST.cpp
1>c:\documents and settings\owner\my documents\visual studio 2008\projects\isdst\isdst\isdst.cpp(6) : error C2059: syntax error : 'string'
1>c:\documents and settings\owner\my documents\visual studio 2008\projects\isdst\isdst\isdst.cpp(17) : error C2065: 'tm' : undeclared identifier
1>c:\documents and settings\owner\my documents\visual studio 2008\projects\isdst\isdst\isdst.cpp(17) : error C2065: 'P' : undeclared identifier
1>c:\documents and settings\owner\my documents\visual studio 2008\projects\isdst\isdst\isdst.cpp(17) : warning C4047: '=' : 'int' differs in levels of indirection from 'tm *'
1>c:\documents and settings\owner\my documents\visual studio 2008\projects\isdst\isdst\isdst.cpp(17) : error C2106: '=' : left operand must be l-value
1>c:\documents and settings\owner\my documents\visual studio 2008\projects\isdst\isdst\isdst.cpp(18) : error C2065: 'P' : undeclared identifier
1>c:\documents and settings\owner\my documents\visual studio 2008\projects\isdst\isdst\isdst.cpp(18) : error C2223: left of '->tm_isdst' must point to struct/union
1>Build log was saved at "file://c:\Documents and Settings\Owner\My Documents\Visual Studio 2008\Projects\IsDST\IsDST\Debug\BuildLog.htm"
1>IsDST - 6 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Regards herge
Hi:
We have moved on but can't get past the Linking.
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
Start Pass1
Processed /DEFAULTLIB:\masm32\lib\masm32.lib
Processed /DEFAULTLIB:\masm32\lib\gdi32.lib
Processed /DEFAULTLIB:\masm32\lib\user32.lib
Processed /DEFAULTLIB:\masm32\lib\kernel32.lib
Processed /DEFAULTLIB:\masm32\lib\Comctl32.lib
Processed /DEFAULTLIB:\masm32\lib\comdlg32.lib
Processed /DEFAULTLIB:\masm32\lib\shell32.lib
Processed /DEFAULTLIB:\masm32\lib\oleaut32.lib
Processed /DEFAULTLIB:\masm32\lib\ole32.lib
Processed /DEFAULTLIB:\masm32\lib\msvcrt.lib
__isDST.obj : warning LNK4044: unrecognized option "manifestdependency:type='win32' name='Microsoft.VC90.DebugCRT' version='9.0.21022.8' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b'"; ignored
Processed /DEFAULTLIB:uuid.lib
Processed /DEFAULTLIB:MSVCRTD
Processed /DEFAULTLIB:OLDNAMES
Searching Libraries
Searching \masm32\lib\masm32.lib:
Searching \masm32\lib\gdi32.lib:
Searching \masm32\lib\user32.lib:
Found _MessageBoxA@16
Referenced in test.obj
Loaded user32.lib(user32.dll)
Found __IMPORT_DESCRIPTOR_user32
Referenced in user32.lib(user32.dll)
Loaded user32.lib(user32.dll)
Found __NULL_IMPORT_DESCRIPTOR
Referenced in user32.lib(user32.dll)
Loaded user32.lib(user32.dll)
Found user32_NULL_THUNK_DATA
Referenced in user32.lib(user32.dll)
Loaded user32.lib(user32.dll)
Searching \masm32\lib\kernel32.lib:
Found _ExitProcess@4
Referenced in test.obj
Loaded kernel32.lib(kernel32.dll)
Found _GetDateFormatA@24
Referenced in test.obj
Loaded kernel32.lib(kernel32.dll)
Found _GetSystemTime@4
Referenced in test.obj
Loaded kernel32.lib(kernel32.dll)
Found _GetTimeFormatA@24
Referenced in test.obj
Loaded kernel32.lib(kernel32.dll)
Found __IMPORT_DESCRIPTOR_kernel32
Referenced in kernel32.lib(kernel32.dll)
Referenced in kernel32.lib(kernel32.dll)
Referenced in kernel32.lib(kernel32.dll)
Referenced in kernel32.lib(kernel32.dll)
Loaded kernel32.lib(kernel32.dll)
Found kernel32_NULL_THUNK_DATA
Referenced in kernel32.lib(kernel32.dll)
Loaded kernel32.lib(kernel32.dll)
Searching \masm32\lib\Comctl32.lib:
Searching \masm32\lib\comdlg32.lib:
Searching \masm32\lib\shell32.lib:
Searching \masm32\lib\oleaut32.lib:
Searching \masm32\lib\ole32.lib:
Searching \masm32\lib\msvcrt.lib:
Found __imp___localtime64
Referenced in __isDST.obj
Loaded msvcrt.lib(msvcrt.dll)
Found __imp___time64
Referenced in __isDST.obj
Loaded msvcrt.lib(msvcrt.dll)
Found __IMPORT_DESCRIPTOR_msvcrt
Referenced in msvcrt.lib(msvcrt.dll)
Referenced in msvcrt.lib(msvcrt.dll)
Loaded msvcrt.lib(msvcrt.dll)
Found msvcrt_NULL_THUNK_DATA
Referenced in msvcrt.lib(msvcrt.dll)
Loaded msvcrt.lib(msvcrt.dll)
Searching C:\Program Files\Microsoft SDK\Lib\.\uuid.lib:
LINK : fatal error LNK1104: cannot open file "MSVCRTD.lib"
We have a few "MSVCTD.LIB" s
// __IsDST.cpp : Defines the entry point for the console application.
// Friday, July 17, 2015 4:20:47 PM
#include "stdafx.h"
#include <windows.h>
#include <time.h>
extern "C" int __stdcall __isDST(int A)
{
time_t t;
t = time(0);
tm* P = localtime ( &t );
return P->tm_isdst;
}
int _tmain(int argc, _TCHAR* argv[])
{
time_t t;
t = time(0);
tm* P = localtime ( &t );
return P->tm_isdst;
}
Regards Herge