Problem with Mysql++

Hello everybody,
I've tried to run following mysql++ program and it echoed errors. I've tried this using eclipse, but the same result.

Any help to fix this problem will be appreciated.

main.cpp
1
2
3
4
5
6
7
8
9
#include <iostream>
#include <mysql++.h>

int main()
{
    mysqlpp::String greeting("Hello, world!");
    std::cout << greeting << std::endl;
    return 0;
}


Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
CXX := g++
CXXFLAGS := -I/usr/include/mysql -I/usr/include/mysql++
LDFLAGS := -L/usr/lib -lmysqlpp -L/usr/lib/mysql -lmysqlclient
SOURCES := hello.cpp
OBJECTS := $(SOURCES: .cpp=.o)
EXECUTABLE := hello

all: $(SOURCES) $(EXECUTABLE)

$(EXECUTABLE): $(OBJECTS)
			$(CXX) $(LDFLAGS) $(OBJECTS) -o $@

.cpp.o:
	$(CXX) $(CXXFLAGS) $< -o $@



[root@localhost MysqlHello]# make
g++ -L/usr/lib -lmysqlpp -L/usr/lib/mysql -lmysqlclient hello.cpp -o hello
hello.cpp:2:21: error: mysql++.h: No such file or directory
hello.cpp: In function ‘int main()’:
hello.cpp:6: error: ‘mysqlpp’ has not been declared
hello.cpp:6: error: expected ‘;’ before ‘greeting’
hello.cpp:7: error: ‘greeting’ was not declared in this scope
make: *** [hello] Error 1

The error is that the compiler cannot find mysql++.h where your makefile specified it would be. Do you have the headers and are they there?
Maybe try adding:
 
-I/usr/include/mysql


to your g++ parameters.

I checked again, all required headers and files are in folders specified in 2nd and 3rd line in Makefile, and they are added to g++ parameters in 11 and 14 line in Makefile. How can I configure IDE(eclipse or NetBeans) to build this program.

Thanks.
I didn't notice until just now that your -I line is not being picked up. Try adding $(CXXFLAGS) to line 11.
I couldn't build with makefile, but it works with eclipse. In the project properties I added directories and libraries path showed in Makefile, and that is all there is to it.
Topic archived. No new replies allowed.