11

Cách sửa lỗi Visual Studio 2012 LNK2019: biểu tượng bên ngoài chưa được giải quyết" __declspec (dllimport) public: class std :: basic_string?Cách sửa lỗi Visual Studio 2012 LNK2019: biểu tượng bên ngoài chưa được giải quyết "__declspec (dllimport) công khai: class std :: basic_string?

Tôi đã biên soạn một dung dịch chứa một exe và một số dự án lib tĩnh mà trên đó các exe phụ thuộc tốt với Visual Studio 2008. libs tĩnh bao gồm:

  • TCL: tcl84tsx.lib
  • wxWidgets: wxbase.lib
  • zlib.lib
  • ws2_32.lib
  • xerces-c_2.lib
  • SN MP nghiên cứu bắt nguồn: subagent.lib, agent.lib, emanate.lib, pack.lib, mibtable.lib, devkit.lib
  • , vv

tôi nạp dung dịch vào Visual Studio 2012 và đã biên soạn tất cả các dự án trong giải pháp nhưng khi tôi cố gắng liên kết các exe, tôi nhận được lỗi về các biểu tượng chưa được giải quyết cho các công cụ trong thư viện C++ chuẩn như đầu ra bên dưới.

Tôi đã tìm thấy rất nhiều người có biểu tượng chưa được giải quyết như thế này nhưng không có bản sửa lỗi nào đang hoạt động cho tôi. Sửa chữa tôi đã cố gắng cho đến nay bao gồm

  • Cập nhật dự án EXE bằng tài liệu tham khảo bằng tay thêm vào dự án lib tĩnh mà trên đó các dự án exe phụ thuộc
  • Toggling "coi wchar_t như built-in loại" tùy chọn mối liên kết

Output từ Visual Studio 2012 mối liên kết ...

1>ace_funcs.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:LBR' specification 
1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library 
1>ComponentX-Win32.lib(MyOrgConsoleSktServer.obj) : warning LNK4049: locally defined symbol [email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported 
1>ComponentY-Win32.lib(ORBSingleton.obj) : warning LNK4049: locally defined symbol [email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported 
1>ComponentY-Win32.lib(OrbException.obj) : warning LNK4049: locally defined symbol [email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported 
1>ComponentZ-Win32.lib(ExceptionHelper.obj) : warning LNK4049: locally defined symbol [email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported 
1>ComponentZ-Win32.lib(ComponentCCheckpointImpl.obj) : warning LNK4217: locally defined symbol [email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported in function "public: __thiscall std::logic_error::logic_error(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" ([email protected]@@[email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@Z) 
1>ComponentX-Win32.lib(MyOrgConsole.obj) : warning LNK4049: locally defined symbol [email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported 
1>ComponentX-Win32.lib(MyOrgThreadFactory.obj) : warning LNK4049: locally defined symbol [email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported 
1>ComponentZ-Win32.lib(PersistenceServiceProxy.obj) : warning LNK4049: locally defined symbol [email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported 
1>ComponentZ-Win32.lib(ComponentBServiceImpl.obj) : warning LNK4049: locally defined symbol [email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported 
1>ComponentZ-Win32.lib(XmlPreferencesHelper.obj) : warning LNK4217: locally defined symbol [email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported in function "private: void __thiscall _CORBA_Sequence_String::copybuffer(unsigned long)" ([email protected][email protected]@[email protected]) 
1>ComponentZ-Win32.lib(XmlHelper.obj) : warning LNK4049: locally defined symbol [email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported 
1>ComponentA-Win32.lib(ServiceBootstrap.obj) : warning LNK4217: locally defined symbol [email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported in function "public: __thiscall std::logic_error::logic_error(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" ([email protected]@@[email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@Z) 
1>ComponentA-Win32.lib(propertyutil.obj) : warning LNK4049: locally defined symbol [email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported 
1>ComponentA-Win32.lib(SystemEnvironment.obj) : warning LNK4049: locally defined symbol [email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported 
1>ComponentZ-Win32.lib(PersistenceClient.obj) : warning LNK4049: locally defined symbol ?[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@Z (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)) imported 
1>ComponentY-Win32.lib(OrbException.obj) : warning LNK4049: locally defined symbol [email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected] (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)) imported 
1>ComponentX-Win32.lib(MyOrgConsole.obj) : warning LNK4049: locally defined symbol [email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected] (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)) imported 
1>ComponentX-Win32.lib(MyOrgThreadFactory.obj) : warning LNK4049: locally defined symbol [email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected] (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)) imported 
1>ComponentX-Win32.lib(MyOrgConsoleSktServer.obj) : warning LNK4049: locally defined symbol [email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected] (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)) imported 
1>ComponentY-Win32.lib(ORBSingleton.obj) : warning LNK4217: locally defined symbol [email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected] (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)) imported in function "public: virtual __thiscall OrbException::~OrbException(void)" ([email protected]@[email protected]) 
1>ComponentZ-Win32.lib(XmlPreferencesHelper.obj) : warning LNK4049: locally defined symbol [email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected] (public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)) imported 
-- snip -- 
1>ComponentA-Win32.lib(ServiceBootstrap.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::substr(unsigned int,unsigned int)const " ([email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@Z) referenced in function "private: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall ServiceBootstrap::trimmed(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,char const *)" ([email protected]@@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@Z) 
1>ComponentA-Win32.lib(ServiceBootstrap.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: unsigned int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::find_last_not_of(char const *,unsigned int,unsigned int)const " ([email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]) referenced in function "private: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall ServiceBootstrap::trimmed(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,char const *)" ([email protected]@@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@Z) 
1>ComponentA-Win32.lib(ServiceBootstrap.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: unsigned int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::find_first_not_of(char const *,unsigned int,unsigned int)const " ([email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]) referenced in function "private: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall ServiceBootstrap::trimmed(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,char const *)" ([email protected]@@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@Z) 
1>ComponentA-Win32.lib(ServiceBootstrap.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl std::operator+<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,char const *)" ([email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]) referenced in function "private: void __thiscall ServiceBootstrap::verifyBootstrapProperties(void)" ([email protected]@@AAEXXZ) 
1>ComponentZ-Win32.lib(PersistenceServiceProxy.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl std::operator+<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,char const *)" ([email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]) 
1>ComponentA-Win32.lib(ServiceBootstrap.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl std::operator+<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" ([email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]) referenced in function "public: class std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > > __thiscall ServiceBootstrap::getBootstrapProperties(void)" ([email protected]@@[email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected][email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@[email protected][email protected][email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@[email protected]@[email protected]@XZ) 
1>ComponentZ-Win32.lib(PersistenceServiceProxy.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl std::operator+<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" ([email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]) 
1>ComponentA-Win32.lib(propertyutil.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::_Mutex::_Lock(void)" ([email protected][email protected]@@QAEXXZ) referenced in function "public: __thiscall std::basic_ostream<char,struct std::char_traits<char> >::_Sentry_base::_Sentry_base(class std::basic_ostream<char,struct std::char_traits<char> > &)" ([email protected][email protected][email protected]@[email protected]@@[email protected]@[email protected]@@Z) 
1>ComponentZ-Win32.lib(XmlHelper.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::_Mutex::_Lock(void)" ([email protected][email protected]@@QAEXXZ) 
-- snip -- 
1>.\Debug/sComponentC.exe : fatal error LNK1120: 22 unresolved externals 
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== 
+0

Hãy thử xóa mọi tệp .h khỏi các câu lệnh bao gồm – TheMathemagician

+2

trong thuộc tính Project, đặt ** Toolset Platform ** thành * VS2008 (v90) * và các thư mục chính xác tùy thuộc vào cài đặt của bạn (ví dụ: include => * C: \ Program Files (x86) \ Windows Kits \ 8.0 \ Bao gồm \ chia sẻ; C: \ Program Files (x86) \ Windows Kits \ 8.0 \ Bao gồm \ um; $ (IncludePath) * và Thư viện => * C: \ Program Files (x86) \ Windows Kits \ 8.0 \ Lib \ win8 \ um \ x64; $ (LibraryPath) *). Đừng quên đặt .lib trong mục Liên kết. – Xaruth

+0

Trong khi googling, tôi đã thấy thủ thuật Platform Toolset. Trong công ty lớn này, bất cứ ai thiết lập MSI cho MSVC++ dường như đã không bao gồm v90. Vì vậy, thư mục MSBuild của tôi chỉ có định nghĩa công cụ cho v10. Tôi sẽ cố gắng theo dõi điều đó. Ngoài ra, tôi ổn với việc phải xây dựng lại tất cả các phụ thuộc nếu tôi có thể tìm ra vấn đề liên kết. – buzz3791

Trả lời

2

trong Properties-> c/C++ -> Laguage, tôi đặt điều trị wchar_t như xây dựng vào loại No và nó giải quyết vấn đề của tôi.

2

Nếu bạn đã cố gắng bên dưới tùy chọn:

  • Cập nhật dự án EXE bằng cách thủ công thêm tài liệu tham khảo cho các dự án lib tĩnh mà trên đó các dự án exe phụ thuộc
  • Toggling "coi wchar_t như built-in loại" tùy chọn

Hãy thử cấu hình dự án của bạn để x64 bằng các bước sau:

  • Nhấp chuột phải vào Solution 'ProjectName'
  • Chọn Configuration Manager...
  • Thay đổi platform của dự án mà bạn đang cố gắng để liên kết lib file để x64 từ Win32 (hoặc vise lại)
  • Rebuild giải pháp

này thực sự đã giải quyết được vấn đề của tôi. Tôi đã không nhận thức được nếu lib bên ngoài của tôi được biên dịch cho 32-bit hoặc 64-bit.

0

Ngay cả khi tôi gặp phải loại lỗi này trong studio trực quan. Lý do cho các loại lỗi này là,

1) Bạn có thể đã bao gồm nhiều thư viện xung đột lẫn nhau. Đôi khi, một lớp trong thư viện có thể xung đột lớp khác trong thư viện khác.

2) Bạn có thể đã bao gồm thư viện từ thư mục. Kiểm tra đường dẫn của các thư viện một lần nữa.

3) Bạn cần chỉ định thư viện và tệp tiêu đề (nếu bạn phải bao gồm) trong thuộc tính dự án. Kiểm tra lại một lần nữa cho dù các đường dẫn là chính xác.

Các vấn đề liên quan