在Windows 7上链接.lib文件 [英] Linking a .lib file on Windows 7
问题描述
我有一个C ++程序test.cpp,我想链接两个.lib文件(fhlib.lib和gc_lib.lib)。我有.lib文件在我的.cpp程序在同一个文件夹。我在Windows 7上。
到目前为止,我尝试的是以下内容:
g ++ -o main main.cpp -L / Users\Documents\Visual Studio 2015\Projects\My Project -lfhlib
但我得到一个
没有这样的文件或目录错误。
我确定路径是正确的,因为我从Properties-> Location复制它。但我删除了C:\,因为它不是编译。
编辑:我发现这个 http:// www
- I而不是-l
work.I get:
未定义引用'fh_set'...
所以问题是lib文件在VS编译。我不得不使用VS编译器而不是g ++,一切工作正常。
I have a C++ program test.cpp and I want to link two .lib files to it(fhlib.lib and gc_lib.lib).I have the .lib files in the same folder as my .cpp program. I'm on Windows 7.
What I have tried so far is the following:
g++ -o main main.cpp -L/Users\Documents\Visual Studio 2015\Projects\My Project -lfhlib
But I get an
No such file or directory error.
I'm sure the path is correct because I copied it from Properties->Location. But I had do delete the "C:\", because it was not compiling.
EDIT: I found this http://www.mingw.org/wiki/Specify_the_libraries_for_the_linker_to_use.
So I tried using
"-I" instead of "-l"
But still doesn't work.I get:
undefined reference to 'fh_set'...
So the problem was that the lib files where compiled in VS. And I had to use the VS compiler instead of g++ and everything worked fine.
这篇关于在Windows 7上链接.lib文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!