Problems finding libraries with fresh compile under windows
I'm on Windows 11, using Visual Studio 19, cloned the master branch last night. Completed the instructions on the README and it worked out perfectly. Open bin\hermes and pass in function hello() { print('Hello World'); } hello(); and she says hi to me.
However, when trying to to build the demos from https://github.com/tmikov/hermes-jsi-demos/ I get a long list of errors, example
FAILED: hello/hello.exe
cmd.exe /C "cd . && "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_exe --intdir=hello\CMakeFiles\hello.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100190~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100190~1.0\x64\mt.exe --manifests -- C:\PROGRA~2\MICROS~2\2019\COMMUN~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\link.exe /nologo hello\CMakeFiles\hello.dir\hello.cpp.obj /out:hello\hello.exe /implib:hello\hello.lib /pdb:hello\hello.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console -LIBPATH:C:\Users\Jason\Documents\hermes-ninja\build\API\hermes -LIBPATH:C:\Users\Jason\Documents\hermes-ninja\build\jsi hermes.lib jsi.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
LINK Pass 1: command "C:\PROGRA~2\MICROS~2\2019\COMMUN~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\link.exe /nologo hello\CMakeFiles\hello.dir\hello.cpp.obj /out:hello\hello.exe /implib:hello\hello.lib /pdb:hello\hello.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console -LIBPATH:C:\Users\Jason\Documents\hermes-ninja\build\API\hermes -LIBPATH:C:\Users\Jason\Documents\hermes-ninja\build\jsi hermes.lib jsi.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:hello\CMakeFiles\hello.dir/intermediate.manifest hello\CMakeFiles\hello.dir/manifest.res" failed (exit code 1120) with the following output:
Creating library hello\hello.lib and object hello\hello.exp
hello.cpp.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl hermes::vm::CrashManager::~CrashManager(void)" (??1CrashManager@vm@hermes@@UEAA@XZ) referenced in function "public: virtual void * __cdecl hermes::vm::CrashManager::`vector deleting destructor'(unsigned int)" (??_ECrashManager@vm@hermes@@UEAAPEAXI@Z)
hermes.lib(hermes.cpp.obj) : error LNK2001: unresolved external symbol "public: virtual __cdecl hermes::vm::CrashManager::~CrashManager(void)" (??1CrashManager@vm@hermes@@UEAA@XZ)
hermes.lib(DebuggerAPI.cpp.obj) : error LNK2001: unresolved external symbol "public: virtual __cdecl hermes::vm::CrashManager::~CrashManager(void)" (??1CrashManager@vm@hermes@@UEAA@XZ)
hello.cpp.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl hermes::vm::NopCrashManager::~NopCrashManager(void)" (??1NopCrashManager@vm@hermes@@UEAA@XZ) referenced in function "public: virtual void * __cdecl hermes::vm::NopCrashManager::`vector deleting destructor'(unsigned int)" (??_ENopCrashManager@vm@hermes@@UEAAPEAXI@Z)
hermes.lib(hermes.cpp.obj) : error LNK2001: unresolved external symbol "public: virtual __cdecl hermes::vm::NopCrashManager::~NopCrashManager(void)" (??1NopCrashManager@vm@hermes@@UEAA@XZ)
hermes.lib(DebuggerAPI.cpp.obj) : error LNK2001: unresolved external symbol "public: virtual __cdecl hermes::vm::NopCrashManager::~NopCrashManager(void)" (??1NopCrashManager@vm@hermes@@UEAA@XZ)
hello.cpp.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl hermes::vm::GCTripwireContext::~GCTripwireContext(void)" (??1GCTripwireContext@vm@hermes@@UEAA@XZ) referenced in function "public: virtual void * __cdecl hermes::vm::GCTripwireContext::`vector deleting destructor'(unsigned int)" (??_EGCTripwireContext@vm@hermes@@UEAAPEAXI@Z)
I can see in the example above that it the 'hello' demo needs to link to the vm lib (presuming hermesVMRuntime.lib) however the full list is must greater.
I've tried with ninja as well to the same result. The demos works great on Ubuntu.
What am I missing here?
My presumption is that while on ubuntu that the required libs are being found and linked automatically. I'm very ignorant when it comes to cmake and ninja but I'm presuming this is a configuration deference between ubuntu and windows. I can see where this step could be easier on ubuntu (really, any non-windows platform) because the libs are being compiled as shared libraries where they are all static libs on windows.
Please note that the README of hermes-jsi-demos says:
Building and running the demos has been tested on Linux and macOS, but not on Windows. PRs adding support for Windows are welcome.
Unfortunately, I don't have a Windows development setup readily available, so I can't really debug this. Based on the missing symbols above, can you try adding hermesPublic to this line:
https://github.com/tmikov/hermes-jsi-demos/blob/1fa1c701b3d48b94f5a0a7f630257e9c75a78fcb/hello/CMakeLists.txt#L39
EDIT: also, please note that issues like this should be filed against https://github.com/tmikov/hermes-jsi-demos.
Thank you for your response. I chose to post it here because it seems to be more a question of linking to the existing hermes libraries than something specific to the jsi-demos. I've tried other examples to the same effect. I can see this becoming more of an issue as people will want to build jsi modules without having to build the entire hermes branch.