• 请不要在回答技术问题时复制粘贴 AI 生成的内容
66CCFF
V2EX  ›  程序员

求助:google gflags 在 VS2013 中编译 error LNK2001。

  •  
  •   66CCFF · May 4, 2014 · 3557 views
    This topic created in 4419 days ago, the information mentioned may be changed or developed.
    头头要求使用gflags来搞定参数问题。

    google code上并没有写明这个东西在windows下如何使用。

    从google code上下了source code然后使用CMake编译。CMake生成的VS2013工程是可以正常编译的。
    我把include/ 中的四个header文件和source code里各种header和cc文件自行创建一个工程后,选择目标文件为.lib时可以正常编译。但是.dll时则报错:

    1>gflags.obj : error LNK2001: 无法解析的外部符号 __imp_PathMatchSpecA
    1>D:\Documents\GitHub\bioasq\x64\Release\gflags.dll : fatal error LNK1120: 1 个无法解析的外部命令



    在gflags目标选为.lib时,在其他工程中写了如下代码:

    #include "gflags/gflags.h"

    DEFINE_string(languages, "english,french,german",
    "comma-separated list of languages to offer in the 'lang' menu");

    在编译时VS提示

    1> Gflags_tester_main.cpp
    1> 正在创建库 D:\Documents\GitHub\bioasq\x64\Release\Gflags_tester_main.lib 和对象 D:\Documents\GitHub\bioasq\x64\Release\Gflags_tester_main.exp
    1>gflags.lib(gflags.obj) : error LNK2001: 无法解析的外部符号 __imp_PathMatchSpecA
    1>D:\Documents\GitHub\bioasq\x64\Release\Gflags_tester_main.exe : fatal error LNK1120: 1 个无法解析的外部命令

    似乎是有东西没有被实现。自己是个菜菜目前感觉很迷茫————不知道是我太菜了没人遇到过这个问题还是用用VS的人太少了。。

    有没有哪位成功把gflags整入VS的已有工程中呢?求帮助呀。
    1 replies    2015-02-12 14:12:36 +08:00
    handong1587
        1
    handong1587  
       Feb 12, 2015
    我在用VS2013 build Caffe工程时也遇到了这个问题,发现一个解决方案如下:
    在Properties - Configuration Properties - Linker - Input - Additional Dependencies中添加:shlwapi.lib 可以解决.
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3361 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 53ms · UTC 12:42 · PVG 20:42 · LAX 05:42 · JFK 08:42
    ♥ Do have faith in what you're doing.