本文介绍了链接Apache库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

GCC 4.4.2

gcc 4.4.2

我已经安装的Apache运行便携。 APR-1.3.9

I have installed apache runtime portable. apr-1.3.9

./configure
make
make test
make install

安装一切都很好。

Everything installed fine.

我在的/ usr /本地/ APR / lib目录所有的图书馆,并在以下的/ usr /本地/月的包括/包括/ APR-1

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

我有一个简单的main.c程序进行测试:

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;
}

和我的生成文件:

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.

不过,我也不是头文件在APR-1文件夹,我用被称为libapr-1.so

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.

非常感谢任何建议,

推荐答案

我的水晶球告诉我,你需要运行添加 -D_LARGEFILE64_SOURCE CFLAGS ,或者如果你在Linux上:命令在getconf LFS_CFLAGS 给你一个确切的名单 CFLAGS 添加到您现有的 CFLAGS 大文件的支持。

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.

最后,您应该真正使用 APR-1配置--cflags 来获得编译器标志,如果可能的。名单

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

这篇关于链接Apache库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 15:11