热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

C++编译问题,sqlite3

如何解决《C++编译问题,sqlite3》经验,为你挑选了1个好方法。

我正在尝试编译一个使用sqlite3的C++程序.我正在使用这个makefile:

CXX = g++ 
CC = gcc 
CFLAGS = -c -O2 
CXXFLAGS = -Wall -O3 -std=c++11
SQLFLAGS = -DSQLITE_THREADSAFE=0

OUTPUTBIN = bot
OUTPUTDIR = ./bin/
MKDIR = mkdir -p $(OUTPUTDIR) 
OBJECTC = sqlite3.o
CSOURCES = sqlite3.c  
CXXSOURCES = main.cpp bot.cpp


all: project

project: createdir sql compilecpp


createdir:
    $(MKDIR)

sql:
    $(CC) $(CSOURCES) $(SQLFLAGS) $(CFLAGS) -o $(OUTPUTDIR)$(OBJECTC)

compilecpp:
    $(CXX) $(OUTPUTDIR)$(OBJECTC) $(CXXSOURCES) $(CXXFLAGS) -o $(OUTPUTDIR)$(OUTPUTBIN)

但输出这些错误:

akf@akf-v5 ~/Documents/Proletarian/c++ $ make
mkdir -p ./bin/ 
gcc  sqlite3.c   -DSQLITE_THREADSAFE=0 -c -O2  -o ./bin/sqlite3.o
g++  ./bin/sqlite3.o main.cpp bot.cpp -Wall -O3 -std=c++11 -o ./bin/bot
./bin/sqlite3.o: In function `unixDlError':
sqlite3.c:(.text+0x170f4): undefined reference to `dlerror'
./bin/sqlite3.o: In function `unixDlClose':
sqlite3.c:(.text+0x5de9): undefined reference to `dlclose'
./bin/sqlite3.o: In function `unixDlSym':
sqlite3.c:(.text+0x5e01): undefined reference to `dlsym'
./bin/sqlite3.o: In function `unixDlOpen':
sqlite3.c:(.text+0x5e21): undefined reference to `dlopen'
collect2: error: ld returned 1 exit status
make: *** [compilecpp] Error 1

我对这导致什么感到非常困惑.我可以看到sqlite3是一个C程序,但我认为它不会导致任何问题.



1> johannes..:

错误消息告诉dlerror,dlclose,dlsymdlopen使用,但无法找到.这些函数是动态链接加载器的一部分.您还必须链接动态链接器.添加-ldl到您的链接标志.另请参阅系统的dlopen联机帮助页.


推荐阅读
author-avatar
书友36782274
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有