954,480 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

_SDL_main

I am making a screensaver and it won't build! The error I get is "undefined reference to '_SDL_main'. Here is my code:

#include <windows.h>
#include <scrnsave.h>
BOOL WINAPI ScreenSaverConfigureDialog(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
    system("TMXDB.exe");
    return true;
}
BOOL WINAPI RegisterDialogClasses(HANDLE hmodule)
{
    return true;
}
int TMR;
LONG WINAPI ScreenSaverProc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam)
{
	switch(message)
	{
	case WM_CREATE:
        system("TMXSCR.exe");
        return 0;
	case WM_ERASEBKGND:
		return 0;
	case WM_TIMER:
		return 0;
	case WM_DESTROY:
		KillTimer(hwnd,TMR);
		PostQuitMessage(0);
		return 0;
	}
	return 0;
}


What do I do to fix this (I don't usually program with windows API (thats why all I do is call my screensaver executable rather than actually doing something with windows API, so it could be something simple)

Labdabeta
Posting Pro in Training
486 posts since Feb 2011
Reputation Points: 27
Solved Threads: 18
 

I would check if you are trying to link with SDL library in this project.

Zjarek
Junior Poster in Training
79 posts since Oct 2009
Reputation Points: 20
Solved Threads: 18
 

Yes I do link the SDL library with this project since there are other files in the project that have to use it. Is there any way to unlink it for one file?

Labdabeta
Posting Pro in Training
486 posts since Feb 2011
Reputation Points: 27
Solved Threads: 18
 

I don't know, I'm a *nix guy, but I think this can be a separate project. It does not depend in any way on TMXSC.

Zjarek
Junior Poster in Training
79 posts since Oct 2009
Reputation Points: 20
Solved Threads: 18
 

I just did some research and it seems that scrnsave.h is supposed to define main, but here is the source code of my scrnsave.h (notice no main):

/*
  Screen saver library by Anders Norlander <anorland@hem2.passagen.se>

  This library is (hopefully) compatible with Microsoft's
  screen saver library.

  This is public domain software.

 */
#ifndef _SCRNSAVE_H
#define _SCRNSAVE_H
#if __GNUC__ >=3
#pragma GCC system_header
#endif

#ifdef __cplusplus
extern "C" {
#endif

/* configure dialog identifier */
#define DLG_SCRNSAVECONFIGURE 2003

#define idsIsPassword		1000
#define idsIniFile		1001
#define idsScreenSaver		1002
#define idsPassword		1003
#define idsDifferentPW		1004
#define idsChangePW		1005
#define idsBadOldPW		1006
#define idsAppName		1007
#define idsNoHelpMemory		1008
#define idsHelpFile		1009
#define idsDefKeyword		1010

#define IDS_DESCRIPTION 1
#define ID_APP 100

#define WS_GT (WS_GROUP | WS_TABSTOP)
#define SCRM_VERIFYPW		WM_APP
#define MAXFILELEN		13
#define TITLEBARNAMELEN		40
#define APPNAMEBUFFERLEN	40
#define BUFFLEN			255

#ifndef RC_INVOKED

/* functions provided by the aothor of the screen saver */
BOOL WINAPI ScreenSaverConfigureDialog(HWND,UINT,WPARAM,LPARAM);
BOOL WINAPI RegisterDialogClasses(HANDLE);
LONG WINAPI ScreenSaverProc(HWND,UINT,WPARAM,LPARAM);

/* Change name of function if we are using UNICODE */
#ifdef UNICODE
#define DefScreenSaverProc DefScreenSaverProcW
#endif

/* default screen saver proc; call instead of DefWindowProc */
LONG WINAPI DefScreenSaverProc(HWND,UINT,WPARAM,LPARAM);

/* change password */
void WINAPI ScreenSaverChangePassword(HWND);

/* globals that may be used by screen saver */
extern HINSTANCE	hMainInstance;
extern HWND		hMainWindow;
extern BOOL		fChildPreview;
extern TCHAR		szName[];
extern TCHAR		szAppName[];
extern TCHAR		szIniFile[];
extern TCHAR		szScreenSaver[];
extern TCHAR		szHelpFile[];
extern TCHAR		szNoHelpMemory[];
extern UINT		MyHelpMessage;

#endif /* RC_INVOKED */

#ifdef __cplusplus
}
#endif

#endif /* _SCRNSAVE_H */
Labdabeta
Posting Pro in Training
486 posts since Feb 2011
Reputation Points: 27
Solved Threads: 18
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: