对“clock_gettime”的未定义引用。将 LIBRTDEF=-lrt 添加到 Makefile 并不能解决问题

发布于 2024-10-11 01:15:56 字数 2303 浏览 2 评论 0原文

我想编译这个软件: http://snap.stanford.edu/snap/download.html 在 ubuntu 9.10 服务器上。

我的 Makefile:

#
# Makefile for non-Microsoft compilers
#

## Linux  (uncomment the 2 lines below for compilation on Linux)
CXXFLAGS += -std=c++98 -Wall
LDFLAGS += -lrt
LIBRTDEF=-lrt
## CygWin (uncomment the 2 lines below for compilation on CygWin)
#CXXFLAGS += -Wall
#LDFLAGS += 

all: MakeAll

opt: CXXFLAGS += -O4
opt: LDFLAGS += -O4
opt: MakeAll

MakeAll:
#   $(MAKE) -C cascades
    $(MAKE) -C centrality
    $(MAKE) -C community
    $(MAKE) -C concomp
    $(MAKE) -C forestfire
    $(MAKE) -C krongen
    $(MAKE) -C kronfit
    $(MAKE) -C mkdatasets
    $(MAKE) -C motifs
    $(MAKE) -C ncpplot
    $(MAKE) -C netevol
    $(MAKE) -C netstat
    $(MAKE) -C testgraph

clean:
#   $(MAKE) clean -C cascades
    $(MAKE) clean -C centrality
    $(MAKE) clean -C community
    $(MAKE) clean -C concomp
    $(MAKE) clean -C forestfire
    $(MAKE) clean -C krongen
    $(MAKE) clean -C kronfit
    $(MAKE) clean -C mkdatasets
    $(MAKE) clean -C motifs
    $(MAKE) clean -C ncpplot
    $(MAKE) clean -C netevol
    $(MAKE) clean -C netstat
    $(MAKE) clean -C testgraph

我的错误:

marc.riera@NODE01:~/snap/examples$ make
make -C centrality
make[1]: Entering directory `/hpcdrive/homes/marc.riera/snap/examples/centrality'
g++  -o centrality centrality.cpp Snap.o -I../../glib -I../../snap
Snap.o: In function `TSysTm::GetMSecsFromOsStart()':
Snap.cpp:(.text+0x4b908): undefined reference to `clock_gettime'
Snap.o: In function `TSysTm::GetProcessMSecs()':
Snap.cpp:(.text+0x4b98e): undefined reference to `clock_gettime'
Snap.o: In function `TSysTm::GetThreadMSecs()':
Snap.cpp:(.text+0x4ba16): undefined reference to `clock_gettime'
Snap.o: In function `TSysTm::GetPerfTimerTicks()':
Snap.cpp:(.text+0x4baa9): undefined reference to `clock_gettime'
Snap.o: In function `TSysProc::Sleep(unsigned int const&)':
Snap.cpp:(.text+0x4bb63): undefined reference to `clock_nanosleep'
collect2: ld returned 1 exit status
make[1]: *** [centrality] Error 1
make[1]: Leaving directory `/hpcdrive/homes/marc.riera/snap/examples/centrality'
make: *** [MakeAll] Error 2

有什么想法吗?

谢谢。

I would like to compile this software : http://snap.stanford.edu/snap/download.html
on ubuntu 9.10 server.

My Makefile:

#
# Makefile for non-Microsoft compilers
#

## Linux  (uncomment the 2 lines below for compilation on Linux)
CXXFLAGS += -std=c++98 -Wall
LDFLAGS += -lrt
LIBRTDEF=-lrt
## CygWin (uncomment the 2 lines below for compilation on CygWin)
#CXXFLAGS += -Wall
#LDFLAGS += 

all: MakeAll

opt: CXXFLAGS += -O4
opt: LDFLAGS += -O4
opt: MakeAll

MakeAll:
#   $(MAKE) -C cascades
    $(MAKE) -C centrality
    $(MAKE) -C community
    $(MAKE) -C concomp
    $(MAKE) -C forestfire
    $(MAKE) -C krongen
    $(MAKE) -C kronfit
    $(MAKE) -C mkdatasets
    $(MAKE) -C motifs
    $(MAKE) -C ncpplot
    $(MAKE) -C netevol
    $(MAKE) -C netstat
    $(MAKE) -C testgraph

clean:
#   $(MAKE) clean -C cascades
    $(MAKE) clean -C centrality
    $(MAKE) clean -C community
    $(MAKE) clean -C concomp
    $(MAKE) clean -C forestfire
    $(MAKE) clean -C krongen
    $(MAKE) clean -C kronfit
    $(MAKE) clean -C mkdatasets
    $(MAKE) clean -C motifs
    $(MAKE) clean -C ncpplot
    $(MAKE) clean -C netevol
    $(MAKE) clean -C netstat
    $(MAKE) clean -C testgraph

My error:

marc.riera@NODE01:~/snap/examples$ make
make -C centrality
make[1]: Entering directory `/hpcdrive/homes/marc.riera/snap/examples/centrality'
g++  -o centrality centrality.cpp Snap.o -I../../glib -I../../snap
Snap.o: In function `TSysTm::GetMSecsFromOsStart()':
Snap.cpp:(.text+0x4b908): undefined reference to `clock_gettime'
Snap.o: In function `TSysTm::GetProcessMSecs()':
Snap.cpp:(.text+0x4b98e): undefined reference to `clock_gettime'
Snap.o: In function `TSysTm::GetThreadMSecs()':
Snap.cpp:(.text+0x4ba16): undefined reference to `clock_gettime'
Snap.o: In function `TSysTm::GetPerfTimerTicks()':
Snap.cpp:(.text+0x4baa9): undefined reference to `clock_gettime'
Snap.o: In function `TSysProc::Sleep(unsigned int const&)':
Snap.cpp:(.text+0x4bb63): undefined reference to `clock_nanosleep'
collect2: ld returned 1 exit status
make[1]: *** [centrality] Error 1
make[1]: Leaving directory `/hpcdrive/homes/marc.riera/snap/examples/centrality'
make: *** [MakeAll] Error 2

Any idea?

thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

遥远的绿洲 2024-10-18 01:15:56

您已经包含了主 Makefile 中的一段内容,而不是来自进行编译的名为centrality 的目录中的 makefile 中的一段内容。

试试这个:

cd centrality
g++  -o centrality centrality.cpp Snap.o -I../../glib -I../../snap -lrt

如果有效,请将此 makefile 中的 LDFLAGS 添加到centrality/Makefile

You have included a piece from the main Makefile and not from the makefile in the directory called centrality that does the compiling.

Try this:

cd centrality
g++  -o centrality centrality.cpp Snap.o -I../../glib -I../../snap -lrt

and if that works, add the LDFLAGS in this makefile to the centrality/Makefile

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文