CMake和两个同名的库

时间:2015-11-20 12:19:56

标签: c linker cmake

我使用的是Linux,当然还安装了libuuid。 由于GPL许可证,我想使用我已经编译过的BSD版本的libuuid。但是当我尝试链接它(Codelite和CMake)时,它试图将它与GPL许可系统库链接。

的CMakeLists.txt:

cmake_minimum_required(VERSION 2.8.11)

project(libdevino)



include_directories(
    /home/clausismus/Projekte/mandarine/Software/Mandarine/libdevino/c/devino/libdevino/
    /home/clausismus/Projekte/mandarine/Software/Mandarine/libdevino/c/devino/libdevino/
    /home/clausismus/Projekte/mandarine/Software/Mandarine/libdevino/c/devino/libdevino/libuuid

)

# Linker options
set(CMAKE_LDFLAGS "${CMAKE_LDFLAGS}  ")

# Library path
set(CMAKE_LDFLAGS "${CMAKE_LDFLAGS} -L\".\" -L\"./libuuid/.libs\" ")

# Define the C sources
set ( C_SRCS
    djson.c
    dpath.c
    dconf.c
    dmemory.c
)

set_source_files_properties(
    ${C_SRCS} PROPERTIES COMPILE_FLAGS 
    " -g -fPIC")

add_library(libdevino SHARED ${CXX_SRCS} ${C_SRCS})

target_link_libraries(libdevino
    libuuid.a
)

Codelite-输出:

/bin/sh -c '/usr/bin/make -j4 -e -f  Makefile'
----------Building project:[ libdevino - Debug ]----------
/usr/bin/make -C "libdevino" -f "libdevino.mk"
make[1]: Entering directory '/home/clausismus/Projekte/mandarine/Software/Mandarine/libdevino/c/devino/libdevino'
/usr/bin/make -C "../build"
make[2]: Entering directory '/home/clausismus/Projekte/mandarine/Software/Mandarine/libdevino/c/devino/build'
make[3]: Entering directory '/home/clausismus/Projekte/mandarine/Software/Mandarine/libdevino/c/devino/build'
make[4]: Entering directory '/home/clausismus/Projekte/mandarine/Software/Mandarine/libdevino/c/devino/build'
make[4]: Leaving directory '/home/clausismus/Projekte/mandarine/Software/Mandarine/libdevino/c/devino/build'
make[4]: Entering directory '/home/clausismus/Projekte/mandarine/Software/Mandarine/libdevino/c/devino/build'
Linking C shared library liblibdevino.so
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/libuuid.a(libuuid_la-gen_uuid.o): Die Umlagerung von ü¸½ü´¥¼¶ýü²´ýµü¶³¸ý¼´ý¶ü¶¡ýý½ü´¤ýµü¶³¸ýµ¼´ü³µý ²ý£¡ý³¶ü´¥ýµü¶³¸ýµ¼´ýµü´¤±ýµü¶³¸ýµ¼´ü¶µý ´ý£¡ý³¶ýøü¸½ü´¥¼¶ýü¶¤ý ´ý£¡ý³¶ü³©ý ²ý£¡ý³¶ü¶©ý ´ý£¡ý³¶ýý³³ýýü¶¡ýý´±ýµýýµü¶³¸ý¼´ýý ý£¡ý³¶ýý¤¥ýµü¶³¸ý¥¼´ýü´¤ýµü¶³¸ý¼´ý³³ýü¶¡ýü³±ý¥¼²ý ý£¡ý³¶ýµý¤¥ýýµü¶³¸ýµ¼´ý¥½ý¹Yü ¥¥ü ¤¥ý®¦·üº¶¹©ý¬ ý´¯ü ¦½©ý©¡ü ®ü§² ü ¦¤ ý¤²ý¹¹¯ý£ ý®¶¥´ý ò¢¸§ gegen »state_fd.6108« kann nicht unter Benutzung geteilter Objekte geschehen; Rekompilieren Sie mit -fPIC
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/libuuid.a: error adding symbols: Ungültiger Wert
collect2: error: ld returned 1 exit status
CMakeFiles/libdevino.dir/build.make:160: recipe for target 'liblibdevino.so' failed
make[4]: *** [liblibdevino.so] Error 1
make[4]: Leaving directory '/home/clausismus/Projekte/mandarine/Software/Mandarine/libdevino/c/devino/build'
CMakeFiles/Makefile2:60: recipe for target 'CMakeFiles/libdevino.dir/all' failed
make[3]: *** [CMakeFiles/libdevino.dir/all] Error 2
make[3]: Leaving directory '/home/clausismus/Projekte/mandarine/Software/Mandarine/libdevino/c/devino/build'
Makefile:76: recipe for target 'all' failed
make[2]: *** [all] Error 2
make[2]: Leaving directory '/home/clausismus/Projekte/mandarine/Software/Mandarine/libdevino/c/devino/build'
libdevino.mk:11: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/home/clausismus/Projekte/mandarine/Software/Mandarine/libdevino/c/devino/libdevino'
Makefile:4: recipe for target 'All' failed
make: *** [All] Error 2
3 errors, 0 warnings

我如何告诉CMake它应该使用BSD许可的lib(" libuuid / .libs / libuuid.a")?

0 个答案:

没有答案