Thread: c++ and mysql api

  1. #1
    Registered User devil@work's Avatar
    Join Date
    Mar 2003
    Posts
    33

    c++ and mysql api

    i am using redhat 8.0 and installed MySQL++ 1.7.9 RPM for Red Hat 8.0 with gcc 3.2 installation went fine.when i tried to compile the following code

    #include <iostream>
    #include <iomanip>
    #include <sqlplus/sqlplus.hh>
    Code:
    int main()
    {
    	Connection con("mysql_cpp_data");
    	
    	Query query=con.query();
    	query<<"select * from stock";
    	Result res =query.store();
    	
    	cout<<"query: "<,query.preview()<<endl;
    	cout<<"Records found: "<<res.size()<<endl<<endl;
    	
    	Row row;
    	cout.setf(iso::left);
    	cout<<setw(17)<<"item"
    	    <<setw(4)<<"Num"
    	    <<setw(7)<<"weith"
    	    <<setw(7)<<"price"
    	    <<"date"<<endl
    	    <<endl;
    	
    	Result::iterator i;
    	
    	for(i=res.begin();i!=res.end();i++){
    		row = *i;
    		cout<<setw(17)<<row[0]
    		    <<setw(4)<<row[1]
    		    <<setw(7)<<row["weight"]
    		    <<setw(7)<<row[3]
    		    <<row[4]<<endl;
    	}
    	return 0;
    }
    i got a lot of errors 20 pages or so first one is mysql.h is not found what other thing i have to install to use the api
    Last edited by devil@work; 03-28-2003 at 11:05 PM.

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Read this , then edit your post accordingly please.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User devil@work's Avatar
    Join Date
    Mar 2003
    Posts
    33
    i copied all includes file from /usr/include/mysql and /usr/include/sqlplus to /usr/include now works but still get lots of undified reference errors.

  4. #4
    Registered User devil@work's Avatar
    Join Date
    Mar 2003
    Posts
    33
    thx it took me an hour to figure problems but al last working thx everybody

Popular pages Recent additions subscribe to a feed