Statische Bibliothek einbinden.
-
Hallo,
ich würde gern mal wissen, wie man eine statische Bibliothek richtig in ein Projekt einbindet. Ich habe eine statische Bibliothek geschrieben, die die Klassen A,B unc C enthält. Außerdem gibt es ein File MyStaticLib.h, das wie folgt aussieht:
#include "A.h" #include "B.h" #include "C.h"Das ganze habe ich als statische Bibliothek übersetzt - klappt. Jetzt will ich in einem anderen Projekt diese Statische Bibliothek einbinden, wie mache ich das? Irgendwo kommt
#include "MyStaticLib.h"aber dann gibt es Linker-Fehler ... welche Settings muß ich noch vornehmen? Als Info noch: MS VC++ 6.0!
Vielen Dank!
-
Eins noch. Die typischen Fehlermeldungen des Linkers sehen wie folgt aus:
Linking...
libcpmt.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined in Laplagllib.lib(AnalysisList-AnalysisList.obj)
LIBC.lib(crt0dat.obj) : error LNK2005: __cinit already defined in LIBCMT.lib(crt0dat.obj)
LIBC.lib(crt0dat.obj) : error LNK2005: _exit already defined in LIBCMT.lib(crt0dat.obj)
LIBC.lib(crt0dat.obj) : error LNK2005: __exit already defined in LIBCMT.lib(crt0dat.obj)
LIBC.lib(crt0dat.obj) : error LNK2005: __cexit already defined in LIBCMT.lib(crt0dat.obj)
LIBC.lib(crt0dat.obj) : error LNK2005: __c_exit already defined in LIBCMT.lib(crt0dat.obj)
LIBC.lib(crt0dat.obj) : error LNK2005: __C_Exit_Done already defined in LIBCMT.lib(crt0dat.obj)
LIBC.lib(crt0dat.obj) : error LNK2005: __C_Termination_Done already defined in LIBCMT.lib(crt0dat.obj)
LIBC.lib(crt0dat.obj) : error LNK2005: __exitflag already defined in LIBCMT.lib(crt0dat.obj)
LIBC.lib(crt0dat.obj) : error LNK2005: __wpgmptr already defined in LIBCMT.lib(crt0dat.obj)
LIBC.lib(crt0dat.obj) : error LNK2005: __pgmptr already defined in LIBCMT.lib(crt0dat.obj)
LIBC.lib(crt0dat.obj) : error LNK2005: ___winitenv already defined in LIBCMT.lib(crt0dat.obj)
LIBC.lib(crt0dat.obj) : error LNK2005: __wenviron already defined in LIBCMT.lib(crt0dat.obj)
LIBC.lib(crt0dat.obj) : error LNK2005: ___initenv already defined in LIBCMT.lib(crt0dat.obj)
LIBC.lib(crt0dat.obj) : error LNK2005: __environ already defined in LIBCMT.lib(crt0dat.obj)
LIBC.lib(crt0dat.obj) : error LNK2005: ___wargv already defined in LIBCMT.lib(crt0dat.obj)
LIBC.lib(crt0dat.obj) : error LNK2005: ___argv already defined in LIBCMT.lib(crt0dat.obj)
LIBC.lib(crt0dat.obj) : error LNK2005: ___argc already defined in LIBCMT.lib(crt0dat.obj)
LIBC.lib(crt0dat.obj) : error LNK2005: __winminor already defined in LIBCMT.lib(crt0dat.obj)
LIBC.lib(crt0dat.obj) : error LNK2005: __winmajor already defined in LIBCMT.lib(crt0dat.obj)
LIBC.lib(crt0dat.obj) : error LNK2005: __winver already defined in LIBCMT.lib(crt0dat.obj)
LIBC.lib(crt0dat.obj) : error LNK2005: __osver already defined in LIBCMT.lib(crt0dat.obj)
LIBC.lib(crt0dat.obj) : error LNK2005: __umaskval already defined in LIBCMT.lib(crt0dat.obj)
Was mache ich hier denn falsch? Die Bibliothek LIBC interessiert mich doch gar nicht ...
-
Hallo,
ich tippe auf diesen Grund
MSDN schrieb:
Der häufigste Grund für diesen Fehler ist das versehentlich gleichzeitige Binden mit den Single-Threaded- und Multithreaded-Bibliotheken. Stellen Sie sicher, daß die Anwendungsprojektdatei nur geeignete Bibliotheken einbezieht und Bibliotheken von Fremdanbietern über entsprechend erstellte Single-Threaded- oder Multithreaded-Versionen verfügen.
MfG