I want to compile a DLL and use it in my project. (It has to be a DLL because I am using Windows Hooks and it has to be loaded at runtime). For more information, it uses Allegro 5 from Nuget.
I am getting the following error when I try to build my DLL:
LNK2019 unresolved external symbol _main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ) in file MSVCRTD.lib (exe_main.obj)
I've recreated the project several times now due to configuration issues. My latest iteration is Win32 Windowed Application and DLL being built with the Multi Threaded Debug DLL runtime - I have tried all the other options and none of the rest work.
I don't understand why it's searching for main: it's a DLL. I haven't provided a DLLMain as I understood it's not necessary because MSVS will provide it for you.
How would I resolve this build issue when trying to compile my DLL?
EDIT The solution was to #define ALLEGRO_NO_MAGIC_MAIN. The Allegro library expects a main function unless you define ALLEGRO_NO_MAGIC_MAIN. Problem solved.
The solution was to #define ALLEGRO_NO_MAGIC_MAIN before including Allegro 5 headers. Allegro expects to see a main function, and that is why the linker was looking for it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.