I received several .dll files with a simple framework. And in the project I have only two files.
1), where to contain all declarations of functions from dll. 2) The file where I want to call some of these functions.
one)
#pragma once #if defined(FRAMEWORK_PROJECT) #define FRAMEWORK_API __declspec(dllexport) #else #define FRAMEWORK_API __declspec(dllimport) #endif Class Sprite; FRAMEWORK_API Sprite* createSprite(const char* path); FRAMEWORK_API void drawSprite(Sprite*, int x, int y); FRAMEWORK_API void getSpriteSize(Sprite* s, int& w, int &h); FRAMEWORK_API void destroySprite(Sprite* s); FRAMEWORK_API void drawTestBackground(); FRAMEWORK_API void getScreenSize(int& w, int &h); FRAMEWORK_API unsigned int getTickCount(); FRAMEWORK_API void showCursor(bool bShow); enum class FRKey { RIGHT, LEFT, DOWN, UP, COUNT }; enum class FRMouseButton { LEFT, MIDDLE, RIGHT, COUNT }; class FRAMEWORK_API Framework { public: virtual void PreInit(int& width, int& height, bool& fullscreen) = 0; virtual bool Init() = 0; virtual void Close() = 0; virtual bool Tick() = 0; // param: xrel, yrel: The relative motion in the X/Y direction // param: x, y : coordinate, relative to window virtual void onMouseMove(int x, int y, int xrelative, int yrelative) = 0; virtual void onMouseButtonClick(FRMouseButton button, bool isReleased) = 0; virtual void onKeyPressed(FRKey k) = 0; virtual void onKeyReleased(FRKey k) = 0; virtual ~Framework() {}; }; FRAMEWORK_API int run(Framework*); 2)
#include "Framework.h" class MyFramework : public Framework { public: virtual bool Tick() { drawTestBackground(); return (false); } }; int main(int argc, char *argv[]) { return run(new MyFramework); } But on any call, I get an undfined reference error. I do not have the source code dll. Tell me what is wrong: my mistake, or perhaps in the most dll?
I just started working on Windows and first encountered a DLL, so I will be grateful for any indication of errors.
I compile it like this: g ++ frame.lib game.cpp

-lkey, who will? - Fat-Zer 3:54 pmundefined reference- Alexander Chernin.libis most likely a static library, not a shared library. So most likely it should be specified along with the rest of the source / object files in the compiler options (linker); through-lshould also work, but I don’t presume to. I do not know the peculiarities of the linker operation under win ... And also the -l key should usually be specified before the source codes / object codes that use these symbols (put it at the beginning). - Fat-Zer pm