If you need threadsafe just add -lpthread to your final link
 
As for .o and .q -- .o are "object" files which you would use to either link 
ALL of it into your application or build your .a or .so file.
The .a and .so file allow your linker to only extract the routines it needs and 
not the whole thing you would get from the .o file.
 
If you have file1 named foo.c
foo1()
foo2()
Compile it into .o and .a
 
Now main.c
main()
{
   foo1()
}
 
Now compile
#1 cc -o main main.c foo.o -- main will contain main(), foo1(), and foo2()
#2 cc -o main main.c foo.a -- main will contain main(), foo1()
 
Imagined foo.c contains hundreds of routine and all you need is foo1() -- makes 
for less memory/disk usage
 
Michael D. Black
Senior Scientist
Advanced Analytics Directorate
Northrop Grumman Information Systems
 

________________________________

From: sqlite-users-boun...@sqlite.org on behalf of Gilles Ganault
Sent: Thu 12/2/2010 12:15 PM
To: sqlite-users@sqlite.org
Subject: EXTERNAL:Re: [sqlite] Cross-compiling SQLite for Blackfin+uClinux?



On Thu, 2 Dec 2010 08:06:13 -0600, "Black, Michael (IS)"
<michael.bla...@ngc.com> wrote:
>You're linking your two .o into the shared library instead of sqlite3.o
>
>        src/$(LIBNAME): $(OBJS)
>                $(CC) $(CFLAGS) $(LIB_OPTION) $(DRIVER_LIBS) -o $@ sqlite3.o

Thanks a bunch, problem solved :-) I can now access SQLite from Lua
through LuaSQL on the Blackfin + uClinux device.

However, to get things working, I had to...

1. Recompile SQLite with "-DSQLITE_THREADSAFE=0",or get the following
error:

=================
> ./lua
Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
> require "luasql.sqlite3"
./lua: can't resolve symbol '_pthread_mutexattr_init'
=================

For those interested, here's the command I used:

cd /usr/src/sqlite-3.7.3

#Unpacked the Blackfin toolchain in /opt
/opt/uClinux/bfin-linux-uclibc/bfin-linux-uclibc/bin/gcc
-DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -v -O2 -Wall -fpic
-c -o libsqlite3.o sqlite3.c

2. LuaSQL's Makefile had to include the two LuaSQL object files and
the SQLite object file:

=================
src/$(LIBNAME): $(OBJS)
        $(CC) $(CFLAGS) $(LIB_OPTION) -o $@ $(OBJS)
/usr/src/sqlite-3.7.3/preprocessed/libsqlite3.o

$(OBJS):
        $(CC) $(CFLAGS) $(INCS) $(DRIVER_INCS) -c $*.c -o $@
=================

Just out of curiosity, I was wondering...

1. Why does GAS display "/../../../" when compiling SQLite?

=================
...
Compiler executable checksum: ca267839d6237ba3b9dd06cf21e83f67

/opt/uClinux/bfin-linux-uclibc/lib/gcc/bfin-linux-uclibc/4.1.1/../../../../bfin-linux-uclibc/bin/as
-v -mfdpic -o libsqlite3.o /tmp/ccdSXIe3.s
GNU assembler version 2.17 (bfin-linux-uclibc) using BFD version 2.17
=================

Is it because I'm not using a Makefile, and GCC has to look around to
located the assembler?

2. I'm confused about the difference between .o and .a: Why do I need
to use a .a when compiling a static library into an executable, while
I had to use the .o to compile SQLite into the LuaSQL shared library?

Thanks again.

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to