Brauche hilfe zu :LNK2019: unresolved external symbol

Nalamar

Grünschnabel
Hallo, ich versuche grad nen C++ programm zuschreiben, um die einstellung von MySQL zu testen wollt eich mit Visual Studio Net 2003 erstmal die examples starten.
Erst hat er die mysql++.lib gar nicht gefunden, seid ich die dann aus dem netz gezogen hab und ins richtig verzeichniss gebracht hab bringt er folgende fehler:

resetdb.obj : error LNK2019: unresolved external symbol "public: __thiscall mysqlpp::SQLString::SQLString(int)" (0SQLString@mysqlpp@@QAE@H@Z) referenced in function $L86620
resetdb.obj : error LNK2019: unresolved external symbol "public: __thiscall mysqlpp::SQLString::SQLString(double)" (0SQLString@mysqlpp@@QAE@N@Z) referenced in function $L86620
resetdb.obj : error LNK2019: unresolved external symbol "public: __thiscall mysqlpp::SQLString::SQLString(char const *)" (0SQLString@mysqlpp@@QAE@PBD@Z) referenced in function $L86620
resetdb.obj : error LNK2019: unresolved external symbol "public: void __thiscall mysqlpp::SQLQuery::parse(void)" (?parse@SQLQuery@mysqlpp@@QAEXXZ) referenced in function $L86620
resetdb.obj : error LNK2019: unresolved external symbol "public: class mysqlpp::ResNSel __thiscall mysqlpp::Query::execute(char const *)" (?execute@Query@mysqlpp@@QAE?AVResNSel@2@PBD@Z) referenced in function $L86620
resetdb.obj : error LNK2019: unresolved external symbol "public: class mysqlpp::Query __thiscall mysqlpp::Connection::query(void)" (?query@Connection@mysqlpp@@QAE?AVQuery@2@XZ) referenced in function $L86620
resetdb.obj : error LNK2019: unresolved external symbol "public: bool __thiscall mysqlpp::Connection::select_db(char const *)" (?select_db@Connection@mysqlpp@@QAE_NPBD@Z) referenced in function _main
resetdb.obj : error LNK2019: unresolved external symbol "public: __thiscall mysqlpp::Connection::~Connection(void)" (1Connection@mysqlpp@@QAE@XZ) referenced in function _main
resetdb.obj : error LNK2019: unresolved external symbol "public: class mysqlpp::ResNSel __thiscall mysqlpp::Connection::execute(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,bool)" (?execute@Connection@mysqlpp@@QAE?AVResNSel@2@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_N@Z) referenced in function "public: class mysqlpp::ResNSel __thiscall mysqlpp::Connection::execute(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?execute@Connection@mysqlpp@@QAE?AVResNSel@2@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
resetdb.obj : error LNK2019: unresolved external symbol "public: class mysqlpp::ResNSel __thiscall mysqlpp::Query::execute(class mysqlpp::SQLQueryParms &)" (?execute@Query@mysqlpp@@QAE?AVResNSel@2@AAVSQLQueryParms@2@@Z) referenced in function "public: class mysqlpp::ResNSel __thiscall mysqlpp::Query::execute(void)" (?execute@Query@mysqlpp@@QAE?AVResNSel@2@XZ)
util.obj : error LNK2019: unresolved external symbol "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl mysqlpp::eek:perator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,class mysqlpp::ColData_Tmpl<class mysqlpp::const_string> const &)" (6mysqlpp@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV12@ABV?$ColData_Tmpl@Vconst_string@mysqlpp@@@0@@Z) referenced in function "void __cdecl print_stock_table(class mysqlpp::Query &)" (?print_stock_table@@YAXAAVQuery@mysqlpp@@@Z)
util.obj : error LNK2019: unresolved external symbol "public: class mysqlpp::ColData_Tmpl<class mysqlpp::const_string> const __thiscall mysqlpp::Row::lookup_by_name(char const *)const " (?lookup_by_name@Row@mysqlpp@@QBE?BV?$ColData_Tmpl@Vconst_string@mysqlpp@@@2@PBD@Z) referenced in function "void __cdecl print_stock_table(class mysqlpp::Query &)" (?print_stock_table@@YAXAAVQuery@mysqlpp@@@Z)
util.obj : error LNK2019: unresolved external symbol "public: void __thiscall mysqlpp::SQLQuery::reset(void)" (?reset@SQLQuery@mysqlpp@@QAEXXZ) referenced in function "void __cdecl print_stock_table(class mysqlpp::Query &)" (?print_stock_table@@YAXAAVQuery@mysqlpp@@@Z)
util.obj : error LNK2001: unresolved external symbol "public: virtual class mysqlpp::ColData_Tmpl<class mysqlpp::const_string> const __thiscall mysqlpp::Row::eek:perator[](unsigned int)const " (ARow@mysqlpp@@UBE?BV?$ColData_Tmpl@Vconst_string@mysqlpp@@@1@I@Z)
util.obj : error LNK2001: unresolved external symbol "public: virtual unsigned int __thiscall mysqlpp::Row::size(void)const " (?size@Row@mysqlpp@@UBEIXZ)
util.obj : error LNK2019: unresolved external symbol "public: __thiscall mysqlpp::ResUse::~ResUse(void)" (1ResUse@mysqlpp@@QAE@XZ) referenced in function "public: virtual __thiscall mysqlpp::Result::~Result(void)" (1Result@mysqlpp@@UAE@XZ)
util.obj : error LNK2019: unresolved external symbol "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall mysqlpp::SQLQuery::str(class mysqlpp::SQLQueryParms &)" (?str@SQLQuery@mysqlpp@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAVSQLQueryParms@2@@Z) referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall mysqlpp::Query::preview(void)" (?preview@Query@mysqlpp@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
util.obj : error LNK2019: unresolved external symbol "public: class mysqlpp::Result __thiscall mysqlpp::Query::store(class mysqlpp::SQLQueryParms &)" (?store@Query@mysqlpp@@QAE?AVResult@2@AAVSQLQueryParms@2@@Z) referenced in function "public: class mysqlpp::Result __thiscall mysqlpp::Query::store(void)" (?store@Query@mysqlpp@@QAE?AVResult@2@XZ)
util.obj : error LNK2019: unresolved external symbol "public: bool __thiscall mysqlpp::Connection::connect(char const *,char const *,char const *,char const *)" (?connect@Connection@mysqlpp@@QAE_NPBD000@Z) referenced in function "bool __cdecl connect_to_db(int,char * * const,class mysqlpp::Connection &,char const *)" (?connect_to_db@@YA_NHQAPADAAVConnection@mysqlpp@@PBD@Z)
c:\mysql++\examples\Debug\resetdb.exe : fatal error LNK1120: 19 unresolved externals



Kann mir wer ne lösung für dieses Problem sagen?

Danke
Nala
 
Du kannst mal das versuchen, wenn der Linker die Lib nicht findet:

Code:
#pragma comment( lib, "c:\irgendeinVerzeichnis\mysql++.lib" )

Setz die Zeile oben in eine deiner CPPs. Den Pfad musst du natürlich anpassen. Auf diese Weise wird die Lib zu deinem Projekt gelinkt.
 
Also ich hab versucht das ganze mal bissel einfacher zu beginnen um überhaupt was auf die beine zu bekommen ...

folgenden code hab ich verwenden:
Code:
#include <iostream> 
#include <iomanip>
#include "c:\mysql++\lib\mysql++.h"

const char  MY_DATABASE[]="praxis"; 
const char  MY_HOST[]="localhost"; 
const char  MY_USER[]="root"; 
const char  MY_PASSWORD[]=""; 
const char  MY_TABLE[]="angestellte"; 
const char  MY_FIELD[]="vorname"; // BLOB field


int main() {
	Connection con(use_exceptions); 
        try { 
                con.real_connect (MY_DATABASE,MY_HOST,MY_USER,MY_PASSWORD,3306,(int)0,60,NULL); 
                Query query = con.query(); ostrstream strbuf; 
                ifstream In (argv[1],ios::in | ios::binary); struct stat for_len; 
                if ((In.rdbuf())->is_open()) { 
                        if (stat (argv[1],&for_len) == -1) return -1; 
                        unsigned int blen = for_len.st_size;  if (!blen) return -1; 
                        char  *read_buffer = new char[blen];    In.read(read_buffer,blen); string fill(read_buffer,blen); 
                        strbuf  << "INSERT INTO " << MY_TABLE << " (" << MY_FIELD << ") VALUES(\""  << escape << fill  << "\")"; 
                        query.exec(strbuf.str()); 
                        delete[] read_buffer;
                } 
                else 
                        cerr << "Your binary file " << argv[1] << "could not be open, errno = " << errno; 
                return 0; 
  }
		return 0;
}

Aber ich bekomme wieder duzende Error:
Compiling...
sql1.cpp
sql1.cpp(18) : error C2065: 'Connection' : undeclared identifier
sql1.cpp(18) : error C2146: syntax error : missing ';' before identifier 'con'
sql1.cpp(18) : error C2065: 'use_exceptions' : undeclared identifier
sql1.cpp(18) : error C3861: 'con': identifier not found, even with argument-dependent lookup
sql1.cpp(20) : error C2228: left of '.real_connect' must have class/struct/union type
type is ''unknown-type''
sql1.cpp(20) : error C3861: 'con': identifier not found, even with argument-dependent lookup
sql1.cpp(21) : error C2065: 'Query' : undeclared identifier
sql1.cpp(21) : error C2146: syntax error : missing ';' before identifier 'query'
sql1.cpp(21) : error C2065: 'query' : undeclared identifier
sql1.cpp(21) : error C2228: left of '.query' must have class/struct/union type
type is ''unknown-type''

hab die mysql++.h schon direkt und indierekt angesprochen .. aber iregndie gehts einfach nicht .. ich steh irgendwie aufn schlauch ...
 
Wenn ich mir die Fehlermeldungen oben ansehe, stelle ich fest, dass sich die Klassen anscheinend im Namespace mysqlpp befinden (z.B. class mysqlpp::Query).

Setz doch mal testweise ein "using namespace mysqlpp;" unter die letzte include-Anweisung und probier, ob der Compiler dann mit den Typen klarkommt.
 
Ganz abgehoben:

Lässt er dich die Dateien mit ++ im Dateinamen benutzen?
Zumindest in DOS konnte man + überhaupt nicht in Dateinamen verwenden, eventuell stösst sich der Compiler/Linker dran?
 
Kachelator hat gesagt.:
Wenn ich mir die Fehlermeldungen oben ansehe, stelle ich fest, dass sich die Klassen anscheinend im Namespace mysqlpp befinden (z.B. class mysqlpp::Query).

Setz doch mal testweise ein "using namespace mysqlpp;" unter die letzte include-Anweisung und probier, ob der Compiler dann mit den Typen klarkommt.

Hey danke, das hat mal wunder bewirkt :) Viele fehler sind nun weg ...

Aber ich als Blut-Newbie hab da noch nen paar mehr fehler drin ....

Compiling...
sql1.cpp
sql1.cpp(23) : error C2065: 'ostrstream' : undeclared identifier
sql1.cpp(23) : error C2146: syntax error : missing ';' before identifier 'strbuf'
sql1.cpp(23) : error C2065: 'strbuf' : undeclared identifier
sql1.cpp(24) : error C2065: 'ifstream' : undeclared identifier
sql1.cpp(24) : error C2146: syntax error : missing ';' before identifier 'In'

Hab den Code größtenteils aus dem Handbuch unter Examples rauskopiert ... dort werden solche sachen auch nicht extra deklariert soweit ich das sehe ... fehlt da noch irgendwo nen include oder sowas?

Aber danke schonmal für die hilfe bisher!

Nala
 
Mach mal noch ein "using namespace std;" dazu. Darin befinden sich nämlich Klassen wie ifstream und ostrstream (übrigens deprecated!).

Eigentlich sollte man Namespaces eher etwas selektiver benutzen, aber um schnell zu einem Resultat zu kommen, kann man ihn schon mal wie hier mit roher Gewalt weit aufreissen. (siehe auch "Büchse der Pandora") :)
 
Wieder ist einiges weg ... kann das sein das mein linker falsch eingestellt ist wenn das das zeug net so richtig findet ?

Aber noch stimmt was nicht:
Die letzten 6 fehler ...

sql1.cpp(29) : error C2065: 'ostrstream' : undeclared identifier
sql1.cpp(29) : error C2146: syntax error : missing ';' before identifier 'strbuf'
sql1.cpp(29) : error C2065: 'strbuf' : undeclared identifier
sql1.cpp(35) : error C3861: 'strbuf': identifier not found, even with argument-dependent lookup
sql1.cpp(36) : error C2228: left of '.str' must have class/struct/union type
type is ''unknown-type''
 
Setz mal ein "#include <strstream>" vor die using-Kommandos. Das ist die Headerdatei, in der ostrstream definiert ist. Vielleicht reicht das schon.
 
Zurück