WinMain verstecken
-
Guten Tag,
ich hab greade Angefangen eine kleine Lib für GUI sachen zu entwickeln.
Für diese will ich ala MFC-Sytle die WinMain verbergen, allerdings sieht die Testanwendung die WinMain auch nicht, so dass der Linker "fatal error LNK1561: Einstiegspunkt muss definiert werden."Könnt ihr mir weiterhelfen?
-
Du musst die WinMain dann ja logischerweise in deiner Bibliothek definieren, und diese Bibliothek wird zur Anwendung hinzugelinkt. Oder wo genau liegt jetzt dein Problem?
-
Ok ich zeig mal bisschen Code:
Core.hpp // Include Datei fuer alles
#ifndef CORE_HPP #define CORE_HPP // STL includes #include <string> #include <iostream> #ifdef WIN32 #include <windows.h> // Include of Windows based implementation #include "Application_win32.hpp" #include "Window_win32.hpp" // Namespace Mapping namespace CoreBase = Core_Win32; #endif #ifdef MAC //namespace CoreBase = Core_Mac; #endif // Core own includes #include "Application.hpp" #include "String.hpp" #include "Window.hpp" #endif CORE_HPPApplication.hpp
#include <core.hpp> #ifndef APPLICATION_HPP #define APPLICATION_HPP namespace Core { class Application : public CoreBase::Application { public: }; } #endif APPLICATION_HPPApplication_win32.hpp
#include <core.hpp> #ifndef APPLICATION_WIN32_HPP #define APPLICATION_WIN32_HPP namespace Core_Win32 { class Application { public: Application(void); ~Application(void); virtual void init(HINSTANCE); virtual void main(void); static Application * Instance(void) { return m_pApp; } private: HINSTANCE m_h; static Application * m_pApp; }; } #endif APPLICATION_WIN32_HPPApplication_win32.hpp
#include "Application_Win32.hpp" #include "core.hpp" Core_Win32::Application::Application(void) { m_pApp = this; } Core_Win32::Application::~Application(void) { } void Core_Win32::Application::init(HINSTANCE hInstance) { } void Core_Win32::Application::main() { } int __stdcall WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){ if(Core_Win32::Application::Instance != 0) { Core_Win32::Application::Instance()->init(hInstance); Core_Win32::Application::Instance()->main(); } return 0; }Testanwenung main.cpp
#include <core.hpp> using Core::Application; class myApp : Application { public: void main() { ::MessageBoxA(0, "Test", "Test", MB_OK); } }; myApp app01;1>core.lib(Application_win32.obj) : error LNK2001: Nicht aufgelöstes externes Symbol ""private: static class Core_Win32::Application * Core_Win32::Application::m_pApp" (?m_pApp@Application@Core_Win32@@0PAV12@A)".
1>D:\Corelib\app_test01\Debug\app_test01.exe : fatal error LNK1120: 1 nicht aufgelöste externe Verweise.Wenn ich extern myApp app01; schreibe dann kann er es auflösen, aber meckert dann dass es keine Einstiegstpunkt gibst.
-
Dieser Thread wurde von Moderator/in rüdiger aus dem Forum Rund um die Programmierung in das Forum WinAPI verschoben.
Im Zweifelsfall bitte auch folgende Hinweise beachten:
C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?Dieses Posting wurde automatisch erzeugt.
-
Schreib in die .cpp:
Application* Application::m_pApp = 0;
-
Danke lolz.