Skip to content

undefined references when transfer to CMake #2

Description

@AIBluefisher

Hi, @iromu
I'm using your library of graclus recently, it goes well when I run make and I can get a executable file and two static libbraries.
However, when I use metis.a and multilevel.a to build my own program, problem occurs. I use the two libs and write a CMakeLists.txt:


cmake_minimum_required(VERSION 3.5)
project(TEST)

include_directories(/usr/include/graclus)
add_executable(graclus graclus.cpp io.cpp)
target_link_libraries(graclus metis multilevel)


error messages is below:


[ 66%] Linking CXX executable graclus
CMakeFiles/graclus.dir/graclus.cpp.o: In function normalizedCut()': graclus.cpp:(.text+0x10a): undefined reference to __log2_metis(int)'
graclus.cpp:(.text+0x146): undefined reference to __log2_metis(int)' graclus.cpp:(.text+0x1ba): undefined reference to __idxmalloc(int, char*)'
graclus.cpp:(.text+0x276): undefined reference to MLKKM_PartGraphKway(int*, int*, int*, int*, int*, int*, int*, int*, int*, int*, int*, int*, int)' graclus.cpp:(.text+0x2d9): undefined reference to __ComputePartitionBalance(graphdef*, int, int*, float*)'
graclus.cpp:(.text+0x2f8): undefined reference to ComputeNCut(graphdef*, int*, int)' graclus.cpp:(.text+0x394): undefined reference to __GKfree(void**, ...)'
CMakeFiles/graclus.dir/io.cpp.o: In function ReadGraph(graphdef*, char*, int*)': io.cpp:(.text+0x340): undefined reference to __InitGraph(graphdef*)'
io.cpp:(.text+0x5e0): undefined reference to __idxsmalloc(int, int, char*)' io.cpp:(.text+0x613): undefined reference to __idxmalloc(int, char*)'
io.cpp:(.text+0x652): undefined reference to __idxmalloc(int, char*)' io.cpp:(.text+0x692): undefined reference to __idxmalloc(int, char*)'
io.cpp:(.text+0x756): undefined reference to __errexit(char*, ...)' CMakeFiles/graclus.dir/io.cpp.o: In function WritePartition(char*, int*, int, int)':
io.cpp:(.text+0x99e): undefined reference to extractfilename(char*, char*)' io.cpp:(.text+0xa07): undefined reference to __errexit(char*, ...)'
CMakeFiles/graclus.dir/io.cpp.o: In function WriteMeshPartition(char*, int, int, int*, int, int*)': io.cpp:(.text+0xb2e): undefined reference to __errexit(char*, ...)'
io.cpp:(.text+0xbfc): undefined reference to __errexit(char*, ...)' CMakeFiles/graclus.dir/io.cpp.o: In function WritePermutation(char*, int*, int)':
io.cpp:(.text+0xd09): undefined reference to __errexit(char*, ...)' CMakeFiles/graclus.dir/io.cpp.o: In function ReadMesh(char*, int*, int*, int*)':
io.cpp:(.text+0x10b4): undefined reference to __errexit(char*, ...)' io.cpp:(.text+0x10ca): undefined reference to __idxmalloc(int, char*)'
io.cpp:(.text+0x1152): undefined reference to `__idxamax(int, int*)'
collect2: error: ld returned 1 exit status
CMakeFiles/graclus.dir/build.make:120: recipe for target 'graclus' failed
make[2]: *** [graclus] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/graclus.dir/all' failed
make[1]: *** [CMakeFiles/graclus.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2


and I found that the source directory doesn't contain header files, I think that's the reason. But why make command goes well? And how to write the right CMakeLists? May you help me.

Thank you very much!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions