Linking error with parmetis

Dear all,
I am trying to use parmetis in a test program with a small hand-made mesh and ParMETIS_V3_PartKway, and got a linking error. My system is kubuntu 9.10, I am using metis 5.0 (built separately from parmetis) and parmetis 4.0.2. The error message is too long, but below I am sending a small portion of it, and I will be very much grateful if anyone could point out a solution to this problem. The program is composed of a main routine only and I am including metis.h and parmetis.h.

Best regards,

Felix C. G. Santos
______________________________________
Department of Mechanical Engineering
Federal University of Pernambuco
Brazil

Building target: parM
Invoking: GCC C++ Linker
/home/fcgs/mpich2-install/bin/mpic++ -L/usr/local/bin/ -L/home/fcgs/mpich2-install/lib -o"parM" ./main.o -lmpich -lmetis -lparmetis
/usr/local/lib/libparmetis.a(kmetis.c.o): In function `libparmetis__Global_Partition':
kmetis.c:(.text+0x1c): undefined reference to `gk_mcorePush'
kmetis.c:(.text+0x13a): undefined reference to `libmetis__rsum'
kmetis.c:(.text+0x217): undefined reference to `gk_free'
kmetis.c:(.text+0x242): undefined reference to `libmetis__imalloc'
kmetis.c:(.text+0x468): undefined reference to `gk_free'
/usr/local/lib/libparmetis.a(kmetis.c.o): In function `ParMETIS_V3_PartKway':
kmetis.c:(.text+0x6c3): undefined reference to `gk_malloc_init'
kmetis.c:(.text+0x6ca): undefined reference to `gk_GetCurMemoryUsed'
kmetis.c:(.text+0x85e): undefined reference to `libmetis__icopy'
kmetis.c:(.text+0x8f2): undefined reference to `gk_GetCurMemoryUsed'
kmetis.c:(.text+0x907): undefined reference to `gk_GetCurMemoryUsed'
kmetis.c:(.text+0x934): undefined reference to `gk_malloc_cleanup'
kmetis.c:(.text+0xae7): undefined reference to `libmetis__iset'
kmetis.c:(.text+0xb24): undefined reference to `METIS_SetDefaultOptions'
kmetis.c:(.text+0xba4): undefined reference to `METIS_PartGraphKway'
/usr/local/lib/libparmetis.a(kmetis.c.o): In function `libparmetis__Global_Partition':
kmetis.c:(.text+0x286): undefined reference to `gk_mcorePop'
/usr/local/lib/libparmetis.a(graph.c.o): In function `libparmetis__FreeNonGraphNonSetupFields':
graph.c:(.text+0x9c): undefined reference to `gk_free'
/usr/local/lib/libparmetis.a(graph.c.o): In function `libparmetis__FreeNonGraphFields':
graph.c:(.text+0x1d0): undefined reference to `gk_free'
/usr/local/lib/libparmetis.a(graph.c.o): In function `libparmetis__FreeInitialGraphAndRemap':
graph.c:(.text+0x248): undefined reference to `gk_free'
graph.c:(.text+0x26f): undefined reference to `gk_free'
graph.c:(.text+0x27d): undefined reference to `gk_free'
/usr/local/lib/libparmetis.a(graph.c.o):graph.c:(.text+0x299): more undefined references to `gk_free' follow
/usr/local/lib/libparmetis.a(graph.c.o): In function `libparmetis__CreateGraph':
graph.c:(.text+0x39e): undefined reference to `gk_malloc'
/usr/local/lib/libparmetis.a(graph.c.o): In function `libparmetis__SetupGraph_nvwgts':
graph.c:(.text+0x3ed): undefined reference to `libmetis__rmalloc'
/usr/local/lib/libparmetis.a(graph.c.o): In function `libparmetis__SetupGraph':
graph.c:(.text+0x537): undefined reference to `libmetis__ismalloc'
graph.c:(.text+0x562): undefined reference to `libmetis__ismalloc'
graph.c:(.text+0x5fc): undefined reference to `libmetis__ismalloc'
graph.c:(.text+0x615): undefined reference to `libmetis__isum'
graph.c:(.text+0x637): undefined reference to `libmetis__isum'
graph.c:(.text+0x6a2): undefined reference to `libmetis__ismalloc'
/usr/local/lib/libparmetis.a(kwayrefine.c.o): In function `libparmetis__KWayBalance':
kwayrefine.c:(.text+0x61): undefined reference to `gk_mcorePush'
kwayrefine.c:(.text+0x278): undefined reference to `libmetis__iset'
kwayrefine.c:(.text+0x45e): undefined reference to `libmetis__icopy'
kwayrefine.c:(.text+0xad3): undefined reference to `libmetis__isorti'
kwayrefine.c:(.text+0x19f0): undefined reference to `gk_mcorePop'
/usr/local/lib/libparmetis.a(kwayrefine.c.o): In function `libparmetis__KWayFM':
kwayrefine.c:(.text+0x1abc): undefined reference to `gk_mcorePush'
kwayrefine.c:(.text+0x1d6c): undefined reference to `libmetis__iset'
kwayrefine.c:(.text+0x1f96): undefined reference to `libmetis__icopy'
kwayrefine.c:(.text+0x2117): undefined reference to `libmetis__rcopy'
kwayrefine.c:(.text+0x2130): undefined reference to `libmetis__rset'

RE: It seems that you are not

It seems that you are not using cmake to build parmetis. Why?

RE: RE: It seems that you are not

Dear Karypis,
I am using cmake to build parmetis. The problem appeared when I tried to link parmetis library with my program. However, I solved the problem already with a simple procedure: I just interchanged parmetis and metis in the list of libraries in the linking command. It seems that parmetis should come before metis in that list, even tough I could not explain why.