英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论