Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

C++ \ MySQL die 2.

Empfohlene Antworten

Veröffentlicht

hi

so nun da mein kleines c programm funktioniert dachte ich mir hmmm naja probierste die ganze geschichte auch mal unter c++...

ja wie soll ich sagen ... nach relativ kurzer zeit bin ich auf die mysqlcppapi gestoßen ... selbige habe ich auch unter suse installiert und hab auch entsprechend einiger beispiele folgenden code zusammen gezimmer ;) :


#include <mysqlcppapi/mysqlcppapi.h>

#include <iostream>

#include <iomanip>


#define MY_DATABASE	"avs"

#define MY_HOST    "10.0.88.104"

#define MY_USER    "test"

#define MY_PASSWORD "***"


int main(int argc, char *argv[]){

	try {

		mysqlcppapi::Connection con;


		con.set_Host(MY_HOST);

		con.set_User(MY_USER);

		con.set_Password(MY_PASSWORD);

		con.select_database(MY_DATABASE);


		mysqlcppapi::Query query = con.create_Query();


		query << "select * from user" << std::ends;

		mysqlcppapi::Result_Store res = query.store();


		std::cout << "Query: " << query.preview() << std::endl;

		std::cout << "Records Found: " << res.size() << std::endl << std::endl;


		mysqlcppapi::Row row;

	    std::cout.setf(std::ios::left);

	    std::cout << std::setw(10) << "ID" 

	       << std::setw(4)  << "User"

	       << std::endl

	       << std::endl;


	    mysqlcppapi::Result_Store::iterator i;


	    std::cout.precision(3);

	    for (i = res.begin(); i != res.end(); i++) {

	    	row = *i;

	    	std::cout << std::setw(10) << row["id"] << "," << std::setw(4) << row["user_name"]<< std::endl; 

	    }

	    return 0;

	} catch (mysqlcppapi::ex_BadQuery& er) { // handle any connection or

                          // query errors that may come up

		std::cerr << "Error: " << er.what() << std::endl;

		return -1;

	} catch (mysqlcppapi::ex_BadConversion& er) { // handle bad conversions

		std::cerr << "Error: Tried to convert \"" << er.get_Data() << "\" to a \""<< er.get_TypeName() << "\"." << std::endl;

		return -1;

	}

}

so pfad hab ich soweit auch richtig angegeben einzigstes problem: die lib...

also unter c konnte ich in den libpfad folgendes eintragen:

/usr/include/mysql -lmysqlclient -lm

sowas brauch ich nu auch noch für das cpp...

weis da einer rat?

thx LordTerra

Hi,

kleiner Hinweis:

As of mid-2005 the MySQL++ library is in new hands and is much improved. It is worth noting that MySQL++ is more actively maintained than mysqlcppapi and it might be a better choice to use.

Da wirst du die Libs genauso eintragen müssen. Außerdem ist /usr/include/mysql -lmysqlclient -lm meiner Meinung nach falsch, da im /usr/include/mysql Verzeichnis die Header liegen:

MySQL AB :: MySQL 5.1 Referenzhandbuch :: 2.1.5 Installationslayouts

Also eher /usr/lib/mysql.

jo die zeile war ja auch von meinem c projekt kopiert

also is richtig das cpp zeug liegt wo anders

/usr/local/include/mysqlcppapi-2.0

^^ da liegt das installierte

nur wenn ich

/usr/local/include/mysqlcppapi-2.0 -lmysqlclient -lm

bringt das gar nix

Hi,

also is richtig das cpp zeug liegt wo anders

ist das ne Frage? Die Standard CPP libs liegen woanders, aber die Mysql libs müssten eigentlich auch da liegen. Der "Wrapper" macht im Grunde nix anderes, als die Standard MySQL API entsprechend in Objekte, Eigenschaften und Methoden zu kapseln, nutzt als eigentlich keine andere Lib.

ok erst mal beantworten:

- benutze die 2005er variante

- wo ers liegt hab ich noch geporstet im anderen post..

und hmm die -lmysqlcppapi find ichnet muss aber nochmal gucken

hmmm irgendwie steh ich auf m schlauch..

also bei nem c programm geb ich als lib:

"das verzeichnis wo die header datei lieft an" -"den client den er benutzen soll"

richtig?

- benutze die 2005er variante
Den Hinweis bezüglich Mysql++ sowohl von carstenj als auch von mir hast du mitbekommen?

und hmm die -lmysqlcppapi find ichnet muss aber nochmal gucken
Du schreibst, du hast das installiert. Wie bist du da genau vorgegangen?

also bei nem c programm geb ich als lib:

"das verzeichnis wo die header datei lieft an" -"den client den er benutzen soll"

Nein.

Mit -I (großes i) gibst du zusätzliche Pfade an, in denen nach Dateien für Includedirektiven (also Headerdateien) gesucht wird. Mit -l (kleines L) gibst du Bibliotheken an. Wenn du -lBLA schreibst, sucht der Linker nach einer Datei libBLA.a, üblicherweise in /usr/lib und /usr/local/lib.

also bei meinem c programm musste ich aber:

-L/usr/include/mysql -lmysqlclient -lm angeben damit er die libs gefunden hat

wie hab ichs installiert:

also ich hab mir die version aus dem netz gezogen

und hab dann die 5 schritte zur installation ausgeführt:

1. `cd' to the directory containing the package's source code and type

`./configure' to configure the package for your system. If you're

using `csh' on an old version of System V, you might need to type

`sh ./configure' instead to prevent `csh' from trying to execute

`configure' itself.

Running `configure' takes awhile. While running, it prints some

messages telling which features it is checking for.

2. Type `make' to compile the package.

3. Optionally, type `make check' to run any self-tests that come with

the package.

4. Type `make install' to install the programs and any data files and

documentation.

5. You can remove the program binaries and object files from the

source code directory by typing `make clean'. To also remove the

files that `configure' created (so you can compile the package for

a different kind of computer), type `make distclean'. There is

also a `make maintainer-clean' target, but that is intended mainly

for the package's developers. If you use it, you may have to get

all sorts of other programs in order to regenerate files that came

with the distribution.

also ich hab das wie folgt übersetzt:

1.) geh in das verzeichnis

2.) führe make aus

3.) führe make check aus

4.) führe make install aus

5.) führe make clean aus

als nächstes hab ich:

./configure CC=c89 CFLAGS=-O2 LIBS=-lposix

gemacht...

fehlt da noch was?

also bei meinem c programm musste ich aber:

-L/usr/include/mysql -lmysqlclient -lm angeben damit er die libs gefunden hat

Mit -L gibst du zusätzliche Verzeichnisse an, in denen nach Bibliotheken gesucht wird. in /usr/include/mysql sollten aber keine Bibliotheken drin sein.

also ich hab das wie folgt übersetzt:

1.) geh in das verzeichnis

2.) führe make aus

3.) führe make check aus

4.) führe make install aus

5.) führe make clean aus

als nächstes hab ich:

./configure CC=c89 CFLAGS=-O2 LIBS=-lposix

gemacht...

Äh, du solltest eigentlich zuerst configure, und dann die ganzen makes ausführen.

Hattest du denn nach dem make install irgendwelche libmysqlapi-Bibliotheken in /usr/local/lib?

jup is da

libmysqlcppapi-2.0.a

libmysqlcppapi-2.0.la

libmysqlcppapi-2.0.so

libmysqlcppapi-2.0-2.0.so.5

libmysqlcppapi-2.0-2.0.so.5.0.0

Mit -L gibst du zusätzliche Verzeichnisse an, in denen nach Bibliotheken gesucht wird. in /usr/include/mysql sollten aber keine Bibliotheken drin sein.

hmmm naja da sind die header-files... aber wenn ich das weglass geht es net...

/usr/local/lib <--- muss ich das mitangeben also:

/usr/local/lib -lmysqlcppapi-2.0

?

bekomme jetzt beim eintragen von :

/usr/local/lib -lmysqlcppapi-2.0

diese fehlermeldung:

/home/lordterra/programme/workspace/MySQL4/Debug/MySQL4: error while loading shared libraries: libmysqlcppapi-2.0-2.0.so.5: cannot open shared object file: No such file or directory

das -L brauch ich net mit angeben da ich eclipse benutz und es da nen feld gibt wo ich das eintrag (also option libs -L eingabefeld)

habe suse 9.3

und jo user/local/lib steht in der ld.so.conf

und er kompiliert ja alles richtig durch nur beim starten schreint er den fehler zu bringen also gcc++ und linker laufen ohne fehler durch

ja thx das wars :)

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.