core icon indicating copy to clipboard operation
core copied to clipboard

Dynlink linker error on Windows MinGW

Open Mostafa-wael opened this issue 2 years ago • 2 comments

This issue was originally reported here.

Trying to install the Metacall CLI on a Windows machine using the installation guide.

The last step: cmake --build . --target install results in the following error:

C:\Users\USER>cd core

C:\Users\USER\core>cd build

C:\Users\USER\core\build>cmake --build . --target install
[  1%] Built target version
[  1%] Built target preprocessor
[  2%] Built target environment
[  3%] Built target format
[  4%] Built target backtrace
[  5%] Built target threading
[ 13%] Built target log
[ 15%] Built target memory
[ 16%] Built target portability
[ 18%] Built target adt
[ 19%] Built target filesystem
[ 20%] Linking CXX shared library ..\..\libdynlinkd.dll
CMakeFiles\dynlink.dir/objects.a(dynlink_impl_win32.c.obj): In function `dynlink_impl_interface_lib_path_win32':
C:/Users/USER/core/source/dynlink/source/dynlink_impl_win32.c:124: undefined reference to `EnumProcessModules@16'
C:/Users/USER/core/source/dynlink/source/dynlink_impl_win32.c:132: undefined reference to `GetModuleFileNameExA@16'
collect2.exe: error: ld returned 1 exit status
source\dynlink\CMakeFiles\dynlink.dir\build.make:171: recipe for target 'libdynlinkd.dll' failed
mingw32-make.exe[2]: *** [libdynlinkd.dll] Error 1
CMakeFiles\Makefile2:3839: recipe for target 'source/dynlink/CMakeFiles/dynlink.dir/all' failed
mingw32-make.exe[1]: *** [source/dynlink/CMakeFiles/dynlink.dir/all] Error 2
Makefile:154: recipe for target 'all' failed
mingw32-make.exe: *** [all] Error 2

C:\Users\USER\core\build>

Mostafa-wael avatar Feb 23 '23 23:02 Mostafa-wael

There is no need to build and install the CLI manually anymore. For Windows, consider using the PowerShell installation script.

powershell -NoProfile -ExecutionPolicy unrestricted -Command “[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing ‘https://raw.githubusercontent.com/metacall/install/master/install.ps1')))"

Refer to this repo for more details.

Mostafa-wael avatar Feb 23 '23 23:02 Mostafa-wael

I want to keep this issue open because it would be interesting to compile the core with MinGW. The issue is related to MinGW compiler and it should be handled eventually. Some loaders are not supported to be compiled with MinGW (NodeJS can't be compiled with MinGW) so this means support for this compiler will be always partial. But in any case, testing more compilers will increase the stability of the project.

viferga avatar Mar 24 '23 00:03 viferga