Reputation: 22566
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,
Upvotes: 1
Views: 2313
Reputation: 96191
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.
Upvotes: 8
Reputation:
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
Upvotes: 3