tags:

views:

41

answers:

2

Hello,

gcc 4.4.2

I have installed apache runtime portable. apr-1.3.9

./configure
make
make test
make install

Everything installed fine.

I have in my /usr/local/apr/lib all the libraries and the includes in the following /usr/local/apr/include/apr-1

I have a simple main.c program to test:

#include <stdio.h>
#include <apr.h>

int main(void)
{
    printf(" == Start of program ==\n");

    return 0;
}

And my makefile:

OBJECT_FILES = main.o

CC = gcc
CFLAGS = -Wall -g -D_LARGEFILE64_SOURCE

LIBS_PATH = -L/usr/local/apr/lib
INC_PATH = -I/usr/local/apr/include/apr-1

LIBS = -lapr-1

test_apr: $(OBJECT_FILES)
    $(CC) $(CFLAGS) $(OBJECT_FILES) $(LIBS_PATH) $(INC_PATH) $(LIBS) -o test_apr

main.o: main.c
    $(CC) -c $(CFLAGS) $(INC_PATH) $(LIBS_PATH) $(INC_PATH) main.c  

However, when I try and compile I get the following error:

gcc -c -I/usr/local/apr/include/apr-1 -L/usr/local/apr/lib -I/usr/local/apr/include/apr-1 main.c    
In file included from main.c:3:
/usr/local/apr/include/apr-1/apr.h:285: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘apr_off_t’
make: *** [main.o] Error 1
make: Target `test_apr' not remade because of errors.

However, I don't understand this as the header file is called apr.h in the apr-1 folder and the libary I am linking with is called libapr-1.so

I know my paths are correct I have double check them. So can't understand why I can't link them.

Many thanks for any advice,

+3  A: 

This is a near dupe of your previous question, so I will give a near dupe of my previous answer - this is not a linker error. You need to pass the include path to the compiler, not the linker:

main.o: main.c
    $(CC) -c $(INC_PATH) main.c 
anon
At least this question is much better formed than the previous question.
Alok
Actually, I was making too many changes to that previous question. So decided to close it. Here I am started fresh by installing the apache runtime and making a simple source file and makefile. However, I am still getting errors after making the changes Neil suggested.
robUK
+4  A: 

My crystal ball tells me that you need to run add -D_LARGEFILE64_SOURCE to CFLAGS, or if you're on linux: the command getconf LFS_CFLAGS gives you an exact list of CFLAGS to add to your existing CFLAGS for large file support.

Finally, you should actually use apr-1-config --cflags to get a list of compiler flags if possible.

Alok
Looks like your crystal balls were right. Currently I am compiling on linux 32 bit. However, there is no way I was would have know about -D_LARGEFILE64_SOURCE to add to the CFLAGS. I guess that is just down to experience. The command LFS_CFLAGS did give me the list of flags to add. However, the apr-1-config --cflags just gave me -pthread. Is that correct?
robUK
@rob: Use both the output of getconf command and -pthread. As Neil said, this problem should have been solved hours ago, trivially, if you had posted the code earlier when asked. I think `apr-1-config --cppflags` might be the command to print the C preprocessor flags. Try that too.
Alok
Thanks for help. This might seem like silly question. But do all libraries have -config command to run,so that you always know what to include in your make file?
robUK
@rob: it's not a formal standard, although many programs provide such `-config` command. For some others, `pkg-config` works. But it's highly dependent on the program which method to use, if any at all.
Alok