【发布时间】:2016-07-26 08:07:36
【问题描述】:
我有一个 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
但我得到了一个
No such file or directory error.
我确定路径是正确的,因为我是从“属性”->“位置”复制的。但我确实删除了“C:\”,因为它没有编译。
编辑:我找到了这个http://www.mingw.org/wiki/Specify_the_libraries_for_the_linker_to_use。
所以我尝试使用
"-I" instead of "-l"
但还是不行。我明白了:
undefined reference to 'fh_set'...
【问题讨论】:
-
-I选项用于包含路径