CC ++ Access MySQL (GCC)

zhaozj2021-02-16  61

In recent times, I will watch C programming under Linux. According to my experience, I have to learn a new thing, I must find a detonation point. And I have been concerned about the network and database related technologies. Therefore, from these two aspects, the information is attached.

From yesterday afternoon, I was watching C Access MySQL. I found a good information: http://www.hk8.org/old_web/linux/SQL/ch13_01.htm This page has an example, which is highly inspired. However, this example has a small problem: call mySQL_REAL_CONNECT, as long as it is finally added with a parameter 0.

This page is accessed with C, which is accessed using C . And provide a packaged Connection Result and Row. Especially useful. In addition, an example program that uses these three classes is provided, but it is not available on this page and needs to be downloaded on http://examples.oreilly.com/msql/ page. See Chapter 13 folders. But here should remind everyone, this is a C file, you need to compile with G ! ! And there are many files, and if it is compiled one by one, it will be a considerable effort. Makefile is to solve this problem. I can't understand this thing. Today, I found some information (http://mrbook.org/tutorials/make/), and finally finally solved. It's so happy! !

Finally, I put my makefile:

All: Demo

Demo: Select.o Row.o Result.o Connection.o

G select.o connection.o result.o row.o -l / usr / lib / mysql -i / usr / include / mysql -lmysqlclient -o demo

SELECT.O: SELECT.CC

G -L / usr / lib / mysql -i / usr / include / mysql -c select.cc

Connection.o: connection.cc connection.h

G -L / usr / lib / mysql -i / usr / include / mysql -c connection.cc

Result.o: result.cc result.h

G -L / usr / lib / mysql -i / usr / include / mysql -c result.cc

Row.o: row.cc row.h

G -l / usr / lib / mysql -i / usr / include / mysql -c row.cc

Two points need

note:

1, the file name is the best is makefile, and pay attention to case, so that directly make, its executable is Demo;

2, each G command must be a TAB! !

This page is too strong in Linux, and the editorial command is all.

If you want to use it, you only use HTML tags! ! Fortunately, my skill is very good.

Good luck !!

转载请注明原文地址:https://www.9cbs.com/read-17545.html

New Post(0)