0

Including mysql and creating a connection in Qt gives me compile problems:

MYSQL* conn;
conn = mysql_init(NULL);

If I manually qmake and then make, I see that mysql isn't being properly linked:

qmake -o Makefile "INCLUDEPATH+=/usr/local/Cellar/mysql/5.1.54/include" "LIBS+=/usr/local/Cellar/mysql/5.1.54/lib/mysql/libmysqlclient.a"

Undefined symbols: "_mysql_init", referenced from: _main in main.o ld: symbol(s) not found collect2: ld returned 1 exit status

What is the proper method for linking mysql to my Qt project?

0

1 Answer 1

1

LIBS+="-L/usr/local/Cellar/mysql/5.1.54/lib/mysql/ -lmysqlclient.a"

Also I'm not sure but Qt by default generates pbproj instead of Makefiles.

Sign up to request clarification or add additional context in comments.

1 Comment

Almost right. I was able to get the correct lib name by typing 'mysql_config --libs' This was the path I ended up using: LIBS += -L/usr/local/Cellar/mysql/5.1.54/lib/mysql/ -lmysqlclient Thanks for your help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.