METIS: undefined reference to `METIS_WPartGraphRecursive'

1.3k views Asked by At

I have to compile a software that depends on METIS library, but whose CMake thing was written by disabling all the places where METIS was needed. Now, I have to re-enable that code again and thus the code depends now on METIS.

I installed metis-5.1.0 from source, and I wrote a CMake module to find it (actually I used this one). I modify the CMakeLists.txt accordingly, basically adding the following lines

find_package(METIS REQUIRED)
if (METIS_FOUND)
    include_directories(SYSTEM ${METIS_INCLUDE_PATH})
else (METIS_FOUND)
    message (SEND_ERROR "This application cannot compile without METIS")
endif (METIS_FOUND)

and, at the end,

target_link_libraries(<my_executable> ${METIS_LIBRARIES})

After cmake, it seems everything is fine, because cmake prints:

-- Found METIS: /usr/local/include  
-- METIS libraries /usr/local/lib/libmetis.a
...
-- Configuring done
-- Generating done
 -- Build files have been written to: <mylocation>

However, after I run make, I get

 undefined reference to `METIS_WPartGraphKway'
 undefined reference to `METIS_WPartGraphRecursive'

How can I solve?

EDIT: As an additional information, when I compile with make VERBOSE=1, the linker seems to look for the right library, as it includes /usr/local/lib/libmetis.a, which corresponds to the location that cmake was specifying and which also exists. Moreover, when I look into the library with nm /usr/local/lib/libmetis.a, I see:

00000000000001c0 T METIS_WPartGraphKway
00000000000009c0 T METIS_WPartGraphRecursive

P.S.: In Ubuntu 17.04, I have tried with metis-5.1.0, metis-4.0.3 and also installing with sudo apt-get install libmetis-dev. In the latter case I find libmetis.so instead of libmetis.a, but, also in this case, this is correctly recognized by cmake, correctly looked for by the linker, but at the end I get the same error.

I also tried sudo apt-get install libmetis-dev, installing from source metis-5.1.0 and metis-3.0.6 on Ubuntu 14.04 and I had the same problem. This seems a hard-to-solve error, as many people ask the same question in this page of the METIS formum.

I have also tried to add -lmetis at the end of the compilation command, as suggested here

As an additional information, I did a grep WPartGraphKway in the METIS source folder. In version 5.1.0 there is no such string. In version 4.0.3 there is.

1

There are 1 answers

0
Andrea Araldo On

I solved doing this:

  • I install metis-3.0
  • I run cmake for my software
  • I run make VERBOSE=1
  • I copy the last gcc command being printed
  • I paste it, I add at the end of the command -lmetis and execute the command

Note that, if I repeat the same operation with metis-5.1.0, it does not work and I have the same error that I wrote in the first post.