undefined reference

BlitzMax Forums/BlitzMax Beginners Area/undefined reference

andre72(Posted 2007) [#1]
Well, I know there'd been a lot of discussions about but I'm not sure about what version of MinGW I've to get ...
My problem is that BM tells me an undefined reference "RegisterServiceCtrlHandlerA@8"
If I understand the discussions here right is because of my installed MinGW is not up to date.

So maybe somebody can point me the URL to a newer version to the MinGW archive I've to DL so it maybe working with ...

Thanks,

Andre


Brucey(Posted 2007) [#2]
you probably want this one .


andre72(Posted 2007) [#3]
Hi Brucey,

no, this one you recommend me last time as I couldn't compile your mods ;-)
Thanks again but I've installed it but it don't recognize RegisterServiceCtrlHandlerA@8 ...
Is there allready a newer one ?


H&K(Posted 2007) [#4]
If I understand the discussions here right is because of my installed MinGW is not up to date.
Nope its more likly that your MiniGW is too new

BMax doesnt use the newer ones.

Uninstal any you have, (make sure they are all gone), then install the 3.10 one, then add it to enviemental variables, then try building Mods.

DO NOT INSTAL A NEWER MINGW unless you know what you are doing, (which you and I dont)

(This may change by the end of the week, cos Mark may or maynot have changed Bmax to a newer MinGW)


andre72(Posted 2007) [#5]
I've tried out now serveral version of MinGW (3.10, 3.8, 3.1) - I ever get this error while linking.
Maybe somebody else havo more luck and a solution for.
Here's the source I try to compile (is not finished yet but without compiling this there's no need to work with anymore):

SuperStrict

Import "-ladvapi32"

'API Constants
Const SERVICES_ACTIVE_DATABASE:String = "ServicesActive"
' Service Control
Const SERVICE_CONTROL_STOP:Int = $1
Const SERVICE_CONTROL_PAUSE:Int = $2
' Service State - for CurrentState
Const SERVICE_STOPPED:Int = $1
Const SERVICE_START_PENDING:Int = $2
Const SERVICE_STOP_PENDING:Int = $3
Const SERVICE_RUNNING:Int = $4
Const SERVICE_CONTINUE_PENDING:Int = $5
Const SERVICE_PAUSE_PENDING:Int = $6
Const SERVICE_PAUSED:Int = $7
Const SERVICE_ACCEPT_STOP:Int = $1
Const SERVICE_ACCEPT_PAUSE_CONTINUE:Int = $2
Const SERVICE_ACCEPT_SHUTDOWN:Int = $4
'Service Control Manager object specific access types
Const STANDARD_RIGHTS_REQUIRED:Int = $F0000
Const SC_MANAGER_CONNECT:Int = $1
Const SC_MANAGER_CREATE_SERVICE:Int = $2
Const SC_MANAGER_ENUMERATE_SERVICE:Int = $4
Const SC_MANAGER_LOCK:Int = $8
Const SC_MANAGER_QUERY_LOCK_STATUS:Int = $10
Const SC_MANAGER_MODIFY_BOOT_CONFIG:Int = $20
Const SC_MANAGER_ALL_ACCESS:Int = $F003F 'STANDARD_RIGHTS_REQUIRED | SC_MANAGER_CONNECT | SC_MANAGER_CREATE_SERVICE | SC_MANAGER_ENUMERATE_SERVICE | SC_MANAGER_LOCK or SC_MANAGER_QUERY_LOCK_STATUS | SC_MANAGER_MODIFY_BOOT_CONFIG
'Service object specific access types
Const SERVICE_QUERY_CONFIG:Int = $1
Const SERVICE_CHANGE_CONFIG:Int = $2
Const SERVICE_QUERY_STATUS:Int = $4
Const SERVICE_ENUMERATE_DEPENDENTS:Int = $8
Const SERVICE_START:Int = $10
Const SERVICE_STOP:Int = $20
Const SERVICE_PAUSE_CONTINUE:Int = $40
Const SERVICE_INTERROGATE:Int = $80
Const SERVICE_USER_DEFINED_CONTROL:Int = $100
Const SERVICE_ALL_ACCESS:Int = $1FF 'STANDARD_RIGHTS_REQUIRED | SERVICE_QUERY_CONFIG | SERVICE_CHANGE_CONFIG | SERVICE_QUERY_STATUS | SERVICE_ENUMERATE_DEPENDENTS | SERVICE_START | SERVICE_STOP | SERVICE_PAUSE_CONTINUE | SERVICE_INTERROGATE | SERVICE_USER_DEFINED_CONTROL
' Service Install - Types
Const SERVICE_WIN32_OWN_PROCESS:Int = $10
Const SERVICE_ERROR_NORMAL:Int = $1
Const SERVICE_AUTO_START:Int = $2
Const SERVICE_DEMAND_START:Int = $3
' Service Types
Const SERVICE_WIN32_SHARE_PROCESS:Int = $20
Const SERVICE_WIN32:Int = $30

Type SERVICE_STATUS
Field dwServiceType:Int
Field dwCurrentState:Int
Field dwControlsAccepted:Int
Field dwWin32ExitCode:Int
Field dwServiceSpecificExitCode:Int
Field dwCheckPoint:Int
Field dwWaitHint:Int
End Type

Type SERVICE_TABLE_ENTRY
Field lpServiceName:String
Field lpServiceProc:Int
End Type

Extern "Win32"
Function CloseServiceHandle:Int (hSCObject:Int) = "CloseServiceHandle@4"
Function ControlService:Int (hService:Int, dwControl:Int, lpServiceStatus:Byte ptr) = "ControlService@12"
Function OpenSCManager:Int (lpMachineName:Byte Ptr, lpDatabaseName:Byte Ptr, dwDesiredAccess:Int) = "OpenSCManagerA@12"
Function OpenService:Int (hSCManager:Int, lpServiceName:Byte Ptr, dwDesiredAccess:Int) = "OpenServiceA@12"
Function QueryServiceStatus (hService:Int, lpServiceStatus:Byte ptr) = "QueryServiceStatus@8"
Function StartService:Int (hService:Int, dwNumServiceArgs:Int, lpServiceArgVectors:Int) = "StartServiceA@12"
Function CreateService:Int (hSCManager:Int, lpServiceName:Byte ptr, lpDisplayName:Byte ptr, dwDesiredAccess:Int, dwServiceType:Int, dwStartType:Int, dwErrorControl:Int, lpBinaryPathName:Byte ptr, lpLoadOrderGroup:Byte ptr, lpdwTagID:Int, lpDependencies:Byte ptr, lp:Byte ptr, lpPassword:Byte ptr) = "CreateServiceA@52"
Function StartServiceCtrlDispatcher:Int (lpServiceStartTable:Byte ptr) = "StartServiceCtrlDispatcherA@4"
Function RegisterSeviceCtrlHandler:Int(lpServiceName:Byte ptr, lpHandlerProc:Byte ptr) = "RegisterSeviceCtrlHandlerA@8"
End Extern

Function ServiceCreate:Int(ServiceName:String)
Local hSManager:Int = OpenSCManager(Null, SERVICES_ACTIVE_DATABASE, SC_MANAGER_ALL_ACCESS)
Local res:Int
If hSManager <> 0
Local schService:Int = CreateService(hSManager, ServiceName, ServiceName, SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL, AppFile, Null, Null, Null, Null, Null)
DebugLog(schService)
If schService <> 0
CloseServiceHandle schService
Endif
CloseServiceHandle hSManager
EndIf
Return res
End Function

ServiceCreate "TestService"
Local svc:SERVICE_TABLE_ENTRY New SERVICE_TABLE_ENTRY
svc.lpServiceName = "MyProc"
svc.lpServiceProc = SvcMain()

Function SvcMain (argc:Int = Null, argv:String = "")
Local svcStatus:SERVICE_STATUS = New SERVICE_STATUS
svcStatus.dwServiceType = SERVICE_WIN32
svcstatus.dwCurrentState = SERVICE_START_PENDING
svcstatus.dwControlsAccepted = $7
svcstatus.dwServiceSpecificExitCode = 0
svcstatus.dwCheckPoint = 0
svcstatus.dwWin32ExitCode = 0
svcstatus.dwWaitHint = 0
Local svchandle:Int = RegisterSeviceCtrlHandler("TestService", svcCtrlHandler)
DebugLog("svchandle: " + svchandle)
End Function

Function svcCtrlHandler(dwOpcode:Int = Null)

End Function


Dreamora(Posted 2007) [#6]
You can install as many MingW as you want, it won't change.
What you need to do is replace the Windows API related .a Files in the blitzmax/lib folder.
Those are from a totally outdated mingw which only supported Win98, not XP.
The MingW you use can or still should be the one officially recommend by BRL.


BladeRunner(Posted 2007) [#7]
as said in the german blitzforum, he just had a typo: RegisterSeviceCtrlHandler

No Probs with minGW.