Avertissement boost lib liant dans la construction WDK ( « LNK4217: symbole défini localement _ importé en fonction _ »)

StackOverflow https://stackoverflow.com/questions/1570516

  •  21-09-2019
  •  | 
  •  

Question

Je construis l'exemple ci-dessous boost-consommation application en mode utilisateur avec le WDK, mais je reçois les erreurs suivantes lors de la liaison avec les bibliothèques Boost que j'ai construit plus tôt à l'aide d'amorçage et. \ Bjam, du même terminal fenêtre.

IIUC, MSDN dit que c'est parce que le (affreusement mutilée) fonction - qui semble être une fonction C ++ std lib - est marqué comme une importation de DLL, mais j'ai une définition locale. Comment est-ce arrivé? Est-il un moyen de contourner cela?

Voir aussi: question vaguement liées <. / p>

C:\exp>more exp.cpp
#pragma warning(disable: 4512)
#include <boost/program_options.hpp>
int __cdecl main() {
  boost::program_options::options_description desc("Allowed options");
  return 0;
}

C:\exp>more sources
TARGETNAME=exp
TARGETTYPE=PROGRAM

USE_MSVCRT=1
USE_STL=1
USE_NATIVE_EH=1

MSC_WARNING_LEVEL=/W4 /WX

_NT_TARGET_VERSION= $(_NT_TARGET_VERSION_WINXP)

INCLUDES=..\boost_1_40_0

SOURCES=exp.cpp

UMTYPE=console
UMBASE=0x400000

TARGETLIBS = $(SDK_LIB_PATH)\ws2_32.lib ..\boost_1_40_0\stage\lib\libboost_program_options-vc100-mt.lib

C:\exp>build
BUILD: Compile and Link for x86
BUILD: Loading c:\winddk\7600.16385.0\build.dat...
BUILD: Computing Include file dependencies:
BUILD: Start time: Wed Oct 14 17:34:23 2009
BUILD: Examining c:\exp directory for files to compile.
   c:\exp
Invalidating OACR warning log for 'root:x86chk'
BUILD: Saving c:\winddk\7600.16385.0\build.dat...
BUILD: Compiling and Linking c:\exp directory
Configuring OACR for 'root:x86chk' - <OACR on>
_NT_TARGET_VERSION SET TO WINXP
Linking Executable - objchk_win7_x86\i386\exp.exe
1>errors in directory c:\exp
1>link : error LNK1218: warning treated as error; no output file generated
BUILD: Finish time: Wed Oct 14 17:34:44 2009
BUILD: Done

   1 executable built - 1 Warning - 1 Error

C:\exp>more *wrn
1>warnings in directory c:\exp
1>c:\exp\libboost_program_options-vc100-mt.lib(options_description.obj): warning LNK4217: locally defined symbol ??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UAE@XZ (public: virtual __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::~basic_streambuf<char,struct std::char_traits<char> >(void)) imported in function "public: virtual __thiscall std::basic_stringbuf<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_stringbuf<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ)
Était-ce utile?

La solution

Vous explicitement .. \ incluez boost_1_40_0 \ stade \ lib \ libboost_program_options-VC100-mt.lib dans le lien.

Vous devez laisser le configurer stuff auto_link boost faire le commentaire #pragma correct (lib, ...) des choses que vous assurer d'emporter dans la bibliothèque à droite et définir le chemin de recherche de linker correctement. La chose la plus probable est que la bibliothèque boost et votre code établissent un lien entre des librairies différentes d'exécution.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top