无法在MingW中构建CMake项目,库路径错误。

huangapple go评论66阅读模式
英文:

Unable to build CMake project in MingW, wrong library path

问题

我正在尝试使用MingW命令行构建一个CMake项目(该项目使用OpenMP作为依赖项),但我遇到了奇怪的链接器错误:

/cannot find -lC:/msys64/mingw64/lib/libgomp.a: Invalid argument
/cannot find -lC:/msys64/mingw64/lib/libmingwthread.a: Invalid argument

我怀疑这是由于无效的库路径引起的(shell正在运行于C:/msys64)。我已确认这两个库存在于 C:/msys64/mingw64/lib 中,并尝试将 LD_LIBRARY_PATH 设置为该目录,但编译仍然失败。是否有其他设置正确库路径的方法?该项目在Linux中构建得很好。

英文:

I'm trying to build a CMake project (which uses OpenMP as a dependency) in using the MingW command line, but I'm running into strange linker errors:

/cannot find -lC:/msys64/mingw64/lib/libgomp.a: Invalid argument
/cannot find -lC:/msys64/mingw64/lib/libmingwthread.a: Invalid argument

which I suspect is caused by invalid library path (the shell is running from C:/msys64). I've confirmed that both libraries exist within C:/msys64/mingw64/lib, and have tried to set LD_LIBRARY_PATH to that directory, but compilation keeps failing.
Is there any alternative way to set the proper library paths? The project buids just fine in Linux.

答案1

得分: 1

-lC:/msys64/mingw64/lib/libgomp.a-lC:/msys64/mingw64/lib/libmingwthread.a 真的是无效的参数

链接器应该使用库文件的路径之一:

C:/msys64/mingw64/lib/libgomp.a C:/msys64/mingw64/lib/libmingwthread.a

或者使用正确的链接器标志:

-LC:/msys64/mingw64/lib -lgomp -lmingwthread

如果你使用CMake,你需要修复这些库的链接方式。

英文:

-lC:/msys64/mingw64/lib/libgomp.a and -lC:/msys64/mingw64/lib/libmingwthread.a really are Invalid arguments.

The linker should be called with either the path to the library files:

C:/msys64/mingw64/lib/libgomp.a C:/msys64/mingw64/lib/libmingwthread.a

or with proper linker flags:

-LC:/msys64/mingw64/lib -lgomp -lmingwthread

If you use CMake you need to fix how these libraries are being linked.

huangapple
  • 本文由 发表于 2023年6月8日 01:20:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/76425703.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定