开发者

compiling custom c++ wrapper sqlite3

I've downloaded the sqlite3 source, and am trying to make a thin c++ wrapper to use sqlite3 in some of my applications. But I get a list of undefined references in sqlite3.c

In my database.hpp, I have the c include:

extern "C" {

#include "sqlite3.h"

}

My makefile looks like this:

CC=gcc -g

CPP=g++ -g

CFLAGS=-c -Wall -ggdb

CPPSOURCES=$(wildcard *.cpp)

CSOURCES=$(wildcard *.c)

OBJECTS=$(CPPSOURCES:.cpp=.o) $(CSOURCES:.c=.o)

EX开发者_运维百科ECUTABLE=testdb

all: $(CPPSOURCES) $(CSOURCES) $(EXECUTABLE)

$(EXECUTABLE): $(OBJECTS)

\t $(CPP) $(OBJECTS) -o $@

.cpp.o:

\t $(CPP) $(CFLAGS) &< -o $@

.c.o:

\t $(CC) $(CFLAGS) &< -o $@

clean:

\t rm -rf *o $(EXECUTABLE)

So what is missing in my Makefile? Or somewhere else .. Do I need some linker options?

tx,

aktiv


You need to link the sqlite3 library or it won't work. I don't see any -l parameters.

Also, there's no need for you to use those .cpp.o and .c.o Makefile commands. They'll be handled by the built-in automatic rules. You just need to use the right flag variables. For C files you use CFLAGS, for C++ files you use CXXFLAGS, for the link step you provide LDFLAGS with your -l parameter.


On the download page there is a tarball with a makefile.

http://www.sqlite.org/sqlite-autoconf-3070500.tar.gz

To create the library:

./configure --prefix /your/own/directory
make
make install

Whit this the "makefile" puts the headers and libs in that directory.

Then you can link like Zan explains.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜