C を使用してから長い時間が経ちましたが、Apache-Portable-Runtime (APR) からサーバー統計を取得する短いスクリプトをコンパイルしようとしています。
ヘッダー ファイルは /usr/include/apr-1/apr*.h にあり、ライブラリは /usr/lib64/libapr-1.* にあります。
ソース ファイルは、APR の公式サイトhttp://apr.apache.org/docs/apr/1.3/files.htmlにあります。
/* test.c */
#include <stdio.h>
#include <stdlib.h>
#include <apr_general.h>
#include <apr_time.h>
int main(int argc, const char *argv[])
{
apr_time_t t;
t = apr_time_now();
printf("The current time: %" APR_TIME_T_FMT "[us]\n", t);
return 0;
}
コンパイルしようとすると、次のエラーが発生します(これはリンクの問題だと思います)。
~> gcc -Wall $(apr-1-config --cflags --cppflags --includes --link-ld) test.c -o test.bin /tmp/cc4DYD2W.o: 関数「main」内: test.c:(.text+0x10): `apr_time_now' への未定義の参照 collect2: ld が 1 つの終了ステータスを返しました
私の環境はgentooです:
~> uname -a Linux アリスター 2.6.32.21-grsec-gt-r2 #1 SMP Tue Sep 7 23:54:49 PDT 2010\ x86_64 Intel(R) Xeon(R) CPU L5640 @ 2.27GHz 純正Intel GNU/Linux` ~> gcc -v gcc バージョン 4.3.4 (Gentoo 4.3.4 p1.1、pie-10.1.5) ~> emerge --search "%@^dev-lib.*apr" * dev-libs/apr インストールされている最新バージョン: 1.3.9 * dev-libs/apr-util インストールされている最新バージョン: 1.3.9
Linux での C の経験が豊富な人に、これを機能させるための提案はありますか?
いつもありがとうございます。