Do you have libfoo.a in that directory after compilation? Because it looks
like that you will have only foo.o there.

On 21 October 2010 14:17, Erwin Brandenberger <bra...@heag.ch> wrote:

> The qt creators foo.pro file looks like this:
>
> QT       -= core gui
> TARGET = foo
> TEMPLATE = lib
> CONFIG += staticlib warn_off
> unix:DEFINES += RUN_LINUX \
> RUN_UNIX
> win32:DEFINES += RUN_NT
>
> Yes there is a -fPIC option set. Do I have to switch off it ? How do I do
> it ?
>
> gcc -c -pipe -g -w -fPIC -D_REENTRANT -DRUN_LINUX -DRUN_UNIX
> -I/usr/share/qt4/mkspecs/linux-g++ -IDESTDIR -I= -I.  -o foo.o foo.c
>
>
>
>
> Am Donnerstag, den 21.10.2010, 18:53 +1100 schrieb Alexander 'hatred'
> Drozdoff:
> > В Wed, 20 Oct 2010 10:34:06 +0200
> > Erwin Brandenberger <bra...@heag.ch> пишет:
> >
> > EB> I like to compile c code building a static library and then linking
> this
> > EB> library from a c++ project.
> > EB>
> > EB> But for all c-function calls I get undefined reference.
> > EB>
> >
> > What compilation options do you use for build library? Do you use [in
> gcc/mingw32 cases] -fPIC
> > options for build objects from your foo.c?
> >
> > EB> The static c-library is referenced by the c++ project in the .pro
> file:
> > EB> LIBS += -lfoo
> > EB>
> > EB>
> > EB> What goes wrong ?
> > EB>
> > EB>
> > EB> The c files look like this:
> > EB>
> > EB> int foo(int a)
> > EB> {
> > EB>   return(a);
> > EB> }
> > EB>
> > EB>
> > EB> and the header files:
> > EB>
> > EB> #ifdef __cplusplus
> > EB> extern "C" {
> > EB> #endif
> > EB>
> > EB> int foo(int a);
> > EB>
> > EB> #ifdef  __cplusplus
> > EB> } /* extern "C" */
> > EB> #endif
> > EB>
> > EB>
> > EB> and the project file parameters:
> > EB>
> > EB> QT -= core gui
> > EB> TEMPLATE = lib
> > EB> CONFIG += staticlib
> > EB>
> >
> >
>
>
>
> _______________________________________________
> Qt-creator mailing list
> Qt-creator@trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-creator
>
_______________________________________________
Qt-creator mailing list
Qt-creator@trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-creator

Reply via email to