这篇文章演示了Makefile使用mysqlpp库和lua库的写法。

test.cpp:

  1. #include <iostream>
  2. #include <stdint.h>
  3. #include <mysql++.h>
  4. extern "C"{
  5. #include <lua.h>
  6. #include <lualib.h>
  7. #include <lauxlib.h>
  8. };
  9.  
  10. int main()
  11. {
  12. mysqlpp::Connection link_gm(false);
  13. if(!link_gm.connect("gm", "127.0.0.1", "root", "", ))
  14. {
  15. std::cout << "connect failed!" << std::endl;
  16. }
  17.  
  18. lua_State* L = luaL_newstate();
  19. luaL_openlibs(L);
  20. luaL_dofile(L, "test.lua");
  21. lua_close(L);
  22.  
  23. std::cout << "hello world" << std::endl;
  24. link_gm.disconnect();
  25. }

test.lua:

  1. print("hello world, lua")

Makefile:

  1. CC = gcc
  2. GXX = g++
  3. CFLAGS = -g -Wall
  4. INCPATH = -I/usr/include/mysql++ -I/usr/include/mysql -I/usr/local/include
  5. LIBS += -L/usr/lib -L/usr/local/lib -L/usr/lib64 -lmysqlpp -llua -ldl -lpthread
  6. TARGET = test.exe
  7. OBJS = test.o
  8.  
  9. .PHONY : all clean
  10.  
  11. all : clean $(TARGET)
  12.  
  13. $(TARGET) : $(OBJS)
  14. $(GXX) -o $@ $(OBJS) $(LIBS)
  15.  
  16. %.o : %.cpp
  17. $(GXX) $(CFLAGS) $(INCPATH) -o $@ -c $<
  18.  
  19. clean :
  20. rm -f $(OBJS) $(TARGET)

Makefile使用库的更多相关文章

  1. makefile笔记10 - makefile 函数库文件

    函数库文件也就是对 Object 文件(程序编译的中间文件)的打包文件.在 Unix 下,一般是由命令"ar"来完成打包工作. 一.函数库文件的成员 一个函数库文件由多个文件组成. ...

  2. Makefile编译库

    funs.h: #ifndef __FUNS_H__ #define __FUNS_H__ void fun1(); #endif funs.c #include "funs.h" ...

  3. g++编译的makefile模板库和脚本

    编译C++文件,特别是多文件的时候,经常要找模板,这里为了后面方便,就自己做了一个模板. makefile模板:Makefile # Object files to either reference ...

  4. C、C++的Makefile的编写以及动、静态库的制作调用(包括MAC地址的获取及MD5加密)

    一.C代码 静态库 四个.h.c文件 add.h #ifndef ADD_H #define ADD_H int add(int a,int b); #endif add.c #include < ...

  5. Makefile的学习笔记

    Makefile的学习笔记 标签: makefilewildcard扩展includeshellfile 2012-01-03 00:07 9586人阅读 评论(2) 收藏 举报  分类: Linux ...

  6. linux编译链接找不到库文件的解决方法。

    今天编译出现ld: 0706-006 Cannot find or open library file: -l xerces-c_static,ld:open(): A file or directo ...

  7. iOS编译集成linux开源c库的一些记录

    最近一个iOS项目需要使用一些Linux下面的开源c库,说是Linux的其实是跨平台的,各种Unix系统都有支持.理论上iOS来自MacOS,而MacOS其实是一种兼容的Unix系统,所以这些库应该也 ...

  8. C/C++ 条件编译静态库

    ==>windows 下方法: 1.方法一:VS工程中中直接添加 1.1在VS的属性->常规->附加库目录,添上文件夹的路径:例如:lib/x64: 1.2输入的附加依赖项,添加上库 ...

  9. Linux动静态库

    gcc编译过程 预处理,gcc -E,.c->.i 展开宏和头文件,替换条件编译,删除注释.空白和空行 编译, gcc -S,.i -> .s 检查语法规范 [消耗时间和系统资源最多] 汇 ...

随机推荐

  1. POMDP

    本文转自:http://www.pomdp.org/ 一.Background on POMDPs We assume that the reader is familiar with the val ...

  2. 使用太过简单jqprint源码也极其简洁易懂

    就像开发一样, 这篇文档如果没有人关心和维护, 里面的内容就会变得老旧, 过时而不再具有参考价值. 所以, 我希望所有看到并喜欢这篇文档的人都一起来维护它. 放心大胆的提交 Pull Request ...

  3. Java数据校验(Bean Validation / JSR303)

    文档: http://beanvalidation.org/1.1/spec/ API : http://docs.jboss.org/hibernate/beanvalidation/spec/1. ...

  4. 一起来做webgame,《Javascript贪食蛇》

    2019-09-22更新: 使用canvas实现:https://github.com/onlyfu/SnakeSir-Javascript 以下为HTML4实现: 今天来个略有意思的,<贪食蛇 ...

  5. mock the facade

    mock the facade: Auth::shouldReceive('user')->andReturn($user = m::mock('StdClass')); $user->s ...

  6. get back to the slower clock rate that allows it to save more power

    http://www.howtogeek.com/177790/why-you-cant-use-cpu-clock-speed-to-compare-computer-performance/ Wh ...

  7. JavaScript中一些常用的方法整理

    当前时间和输入时间比较 var timeLong = Date.parse(new Date());//当前时间var t1 = Date.parse($("#returnTime2&quo ...

  8. 解决国内npm依赖包安装慢的问题

    可以通过 npm config set registry http://registry.npm.taobao.org命令设置镜像服务器为阿里巴巴镜像服务器,速度会快很多,亲测有效.

  9. golang: 常用数据类型底层结构分析

    虽然golang是用C实现的,并且被称为下一代的C语言,但是golang跟C的差别还是很大的.它定义了一套很丰富的数据类型及数据结构,这些类型和结构或者是直接映射为C的数据类型,或者是用C struc ...

  10. 简单的js菜单

    <!DOCTYPE html> <html> <head> <title>hovertree</title><base target= ...