To be more exact, the Linker fails due to -lm
I'm trying to use a pkg-config from lua5.3 from msys2. I have never had problems in C, but when I tried to use them in Nim, I got the following error:
The important part of all the error shown by Nim is this:
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lm
collect2.exe: error: ld returned 1 exit status
Error: execution of an external program failed: 'gcc.exe -o "D:\Proyectos de Programacion\Proyectos Grandes\MinimalistMake\build\mmake_debug.exe" C:\Users\adric\nimcache\mmake_r\mmake.res C:\Users\adric\nimcache\mmake_r\stdlib_assertions.nim.c.o C:\Users\adric\nimcache\mmake_r\stdlib_formatfloat.nim.c.o C:\Users\adric\nimcache\mmake_r\stdlib_widestrs.nim.c.o C:\Users\adric\nimcache\mmake_r\stdlib_io.nim.c.o C:\Users\adric\nimcache\mmake_r\stdlib_system.nim.c.o C:\Users\adric\nimcache\mmake_r\stdlib_parseutils.nim.c.o C:\Users\adric\nimcache\mmake_r\stdlib_unicode.nim.c.o C:\Users\adric\nimcache\mmake_r\stdlib_math.nim.c.o C:\Users\adric\nimcache\mmake_r\stdlib_strutils.nim.c.o C:\Users\adric\nimcache\mmake_r\stdlib_dynlib.nim.c.o C:\Users\adric\nimcache\mmake_r\stdlib_winlean.nim.c.o C:\Users\adric\nimcache\mmake_r\stdlib_pathnorm.nim.c.o C:\Users\adric\nimcache\mmake_r\stdlib_times.nim.c.o C:\Users\adric\nimcache\mmake_r\stdlib_os.nim.c.o C:\Users\adric\nimcache\mmake_r\stdlib_terminal.nim.c.o C:\Users\adric\nimcache\mmake_r\stdlib_parseopt.nim.c.o C:\Users\adric\nimcache\mmake_r\stdlib_streams.nim.c.o C:\Users\adric\nimcache\mmake_r\stdlib_lexbase.nim.c.o C:\Users\adric\nimcache\mmake_r\stdlib_parsexml.nim.c.o C:\Users\adric\nimcache\mmake_r\stdlib_hashes.nim.c.o C:\Users\adric\nimcache\mmake_r\stdlib_strtabs.nim.c.o C:\Users\adric\nimcache\mmake_r\stdlib_xmltree.nim.c.o C:\Users\adric\nimcache\mmake_r\stdlib_xmlparser.nim.c.o C:\Users\adric\nimcache\mmake_r\@[email protected] C:\Users\adric\nimcache\mmake_r\@[email protected] C:\Users\adric\nimcache\mmake_r\@mtravel_project.nim.c.o C:\Users\adric\nimcache\mmake_r\@mmmake.nim.c.o -LC:/msys64/mingw64/lib -llua -lm
Looking carefully for the problem I found that it fails due to - lm, but if I run the command that Nim shows me directly in CMD the problem does not occur and it compiles perfectly.
So I rule out that it is GCC.
I don't know what I can do to solve this problem. I hope you can help me, and if necessary I post the same problem on GitHub.
Thank you very much and forgive my English (I have used Google Translate, my English is not very good)
I have installed openlibm, but unfortunately it is something that has nothing to do with the problem.
Inside msys2 I have the following:
| File | Path |
| ------------- | ---------------------------------------- |
| libopenlibm.a | C:\msys64\mingw64\lib |
| libm.a | C:\msys64\mingw64\x86_64-w64-mingw32\lib |
The problem with the -lm library only occurs with Nim. I have tried projects with C and C ++ and there is no problem.
I'm going to try the same steps in Ubuntu to see if the same problem occurs. But it will take time because I have to install it.
Thanks for answering.
Does the different style of path definition for -L makes any difference? Backward and forward slash in the same command. I assume there is a m.dll in C:\msys64\mingw64\lib\m.dll, right?
-LC:/msys64/mingw64/lib is the same as -LC:\msys64\mingw64\lib?