tags:

views:

74

answers:

5

Hello,

gcc 4.4.2 c89

I am trying to link some headers and libraries in my header file. But for some reason my program doesn't seem to link.

I have in my directory src/include/apr src/libs

I have compiled the libraries and placed them in my libs and I have put the headers in the include directory.

My executable is in the src directory.

In my makefile I have specified this:

LIBS_PATH -L./lib
INC_PATH -I./include

LIBS = -libapr-1

So the current directory to where the executable is executed from.

In my lib folder I have the following library called:

libapr-1.so

And in my include/apr folder I have the following header file:

apr.h

The program is getting the header files. But I don't think it is linking the library as I don't get any errors saying that it can't find the header file.

In the file where I include the header I have done this

#include <apr/apr.h>

I do get this following error message:

In file included from include/apr.h:17,                
./include/apr/apr.h:285: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘apr_int32_t’

Many thanks for any suggestions and advice,

EDIT:

LIBS_PATH -L./lib
INC_PATH -I./include

LIBS = -lapr

Error: /usr/bin/ld: cannot find -lapr

Makefile:

OBJECT_FILES = dlg_fsm.o 

CFLAGS = -ggdb -Wall 

FLATFORM = -DLINUX

CC = gcc

LIBS_PATH = -L./lib
INC_PATH = -I./include

LIBS = -lapr

dlg: $(OBJECT_FILES)
    $(CC) $(CFLAGS) $(LDFLAGS) $(OBJECT_FILES) $(FLATFORM) $(INC_PATH) $(LIBS_PATH) $(LIBS) -o dlg
+2  A: 

This has nothing to do with libraries, and may have nothing to do with paths. The compiler thinks there is a syntax error at the line indicated - please post that line, and the ones surrounding it, using copy and paste.

anon
+1  A: 

Once you've fixed the syntax error in your code, you'll want to change LIBS to contain -lapr-1, since the linker adds the "lib" prefix itself.

Ignacio Vazquez-Abrams
Yes. I have corrected that. The library is called libapr-1.so. So in my makefile I have called it -lapr-1.
robUK
+1  A: 
Alok
I commented out the errors I was getting. However, now I compile I get the following error: /usr/bin/ld: cannot find -lapr-1. I guess that its looking in the default path. However, is it possible to do link with my custom path i.e. LIBS_PATH -L.lib thanks.
robUK
Yes, linking like that should be possible, but try `-lapr` first? So now you're saying that compilation worked without an errors? What did you do? Also, post your updates in your main post, not as reply here - makes it easier for others to follow this post.
Alok
+1  A: 

Either there is a syntax error in apr.h or probably apr.h expects something to be included before itself.

For example:

you write header file abc.h which uses strlen(...), but do not include string.h inside abc.h . If you want to include abc.h in file xxx.c, you have to include string.h in xxx.c before abc.h manually to make sure that abc.h has access to the declaration of strlen(...)

Damg