CMake and two libs with the same name - c

I'm using Linux, and of course libuuid is installed.
Because of the GPL license, I'd like to use the BSD version of libuuid, which I already compiled. But when I try to link it (Codelite with CMake) it tries to link it with GPL licensed system library.
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-Output:
/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
How can I tell CMake, that it should use the BSD licensed lib ("libuuid/.libs/libuuid.a")?

Related

Linux Cross compile Library

I try to use Linaro to cross compile "nano-2.5.3" program for my ARM board.
my build platform is linux ubuntu 12.04. I use these commands
export PATH=$PATH:/project/gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux/bin
export CROSS_COMPILE=arm-linux-gnueabihf-
export ARCH=arm
./configure --host=arm-linux-gnueabihf --prefix=/project/nano
every thing went well then I try to use make
make
after that there is a error :
/usr/include/ncursesw/curses.h:60:34: fatal error: ncursesw/ncurses_dll.h: No such file or directory
so i compile a ncurses library with my cross compiler in path "/project/ncurses" and add the include with:
export CPPFLAGS=-I/project/ncurses/include/ncurses
and do over again. but no luck
I tried everything but the cross compiler keep checking the original path
here are the full error text:
make all-recursive
make[1]: Entering directory `/project/nano-2.5.3'
Making all in doc
make[2]: Entering directory `/project/nano-2.5.3/doc'
Making all in man
make[3]: Entering directory `/project/nano-2.5.3/doc/man'
make all-recursive
make[4]: Entering directory `/project/nano-2.5.3/doc/man'
Making all in fr
make[5]: Entering directory `/project/nano-2.5.3/doc/man/fr'
make all-am
make[6]: Entering directory `/project/nano-2.5.3/doc/man/fr'
make[6]: Nothing to be done for `all-am'.
make[6]: Leaving directory `/project/nano-2.5.3/doc/man/fr'
make[5]: Leaving directory `/project/nano-2.5.3/doc/man/fr'
make[5]: Entering directory `/project/nano-2.5.3/doc/man'
make[5]: Nothing to be done for `all-am'.
make[5]: Leaving directory `/project/nano-2.5.3/doc/man'
make[4]: Leaving directory `/project/nano-2.5.3/doc/man'
make[3]: Leaving directory `/project/nano-2.5.3/doc/man'
Making all in texinfo
make[3]: Entering directory `/project/nano-2.5.3/doc/texinfo'
make all-am
make[4]: Entering directory `/project/nano-2.5.3/doc/texinfo'
make[4]: Nothing to be done for `all-am'.
make[4]: Leaving directory `/project/nano-2.5.3/doc/texinfo'
make[3]: Leaving directory `/project/nano-2.5.3/doc/texinfo'
Making all in syntax
make[3]: Entering directory `/project/nano-2.5.3/doc/syntax'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/project/nano-2.5.3/doc/syntax'
make[3]: Entering directory `/project/nano-2.5.3/doc'
make[3]: Nothing to be done for `all-am'.
make[3]: Leaving directory `/project/nano-2.5.3/doc'
make[2]: Leaving directory `/project/nano-2.5.3/doc'
Making all in m4
make[2]: Entering directory `/project/nano-2.5.3/m4'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/project/nano-2.5.3/m4'
Making all in po
make[2]: Entering directory `/project/nano-2.5.3/po'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/project/nano-2.5.3/po'
Making all in src
make[2]: Entering directory `/project/nano-2.5.3/src'
arm-linux-gnueabihf-gcc -DHAVE_CONFIG_H -I. -I.. -DLOCALEDIR=\"/project/nano/share/locale\" -DSYSCONFDIR=\"/project/nano/etc\" -I/usr/include/ncursesw -I/project/ncurses/include/ncurses -g -O2 -Wall -MT browser.o -MD -MP -MF .deps/browser.Tpo -c -o browser.o browser.c
In file included from nano.h:93:0,
from proto.h:27,
from browser.c:25:
/usr/include/ncursesw/curses.h:60:34: fatal error: ncursesw/ncurses_dll.h: No such file or directory
compilation terminated.
make[2]: *** [browser.o] Error 1
make[2]: Leaving directory `/project/nano-2.5.3/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/project/nano-2.5.3'
make: *** [all] Error 2
Found it!
the problem was from the library name similarity.
I compile "ncurses" library BUT as I search the library name is "ncursesw"!
very similar... but yet they are not.

Make error for stellarisware

I got a stellaris board to explore the power of arm. I'm using arch linux. I want to setup a toolchain based on eclipse, but if I donwload the SW-LM3S-9453.exe, unzip it, and try to make it I got the following errors:
[root#vaio stellaris]# make
make[1]: Entering directory '/home/erbal/src/stellaris/driverlib'
make[2]: Entering directory '/home/erbal/src/stellaris/driverlib'
CC adc.c
as: unrecognized option '-mcpu=cortex-m3'
../makedefs:186: recipe for target 'gcc-cm3/adc.o' failed
make[2]: *** [gcc-cm3/adc.o] Error 1
make[2]: Leaving directory '/home/erbal/src/stellaris/driverlib'
Makefile:41: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/home/erbal/src/stellaris/driverlib'
Makefile:46: recipe for target 'all' failed
make: *** [all] Error 2
What am I missing?
Have you verified which toolchain is being used? That error would be appropriate if you are trying to use the host toolchain rather than a toolchain built for ARM.

Building R on the Raspberry Pi

I am building a software package using a custom built toolchain for the Raspberry Pi.
I've run into a C standard issue. When compiling, I get an error that says SIZE_MAX is required for C99.
See here:
make[2]: Leaving directory `/home/njackson/R-2.15.3/src/unix'
make[2]: Entering directory `/home/njackson/R-2.15.3/src/unix'
make[3]: Entering directory `/home/njackson/R-2.15.3/src/unix'
making dynload.d from dynload.c
In file included from dynload.c:33:0:
../../src/include/Defn.h:209:3: error: #error SIZE_MAX is required for C99
make[3]: *** [dynload.d] Error 1
make[3]: Leaving directory `/home/njackson/R-2.15.3/src/unix'
make[2]: *** [R] Error 2
make[2]: Leaving directory `/home/njackson/R-2.15.3/src/unix'
make[1]: *** [R] Error 1
make[1]: Leaving directory `/home/njackson/R-2.15.3/src'
make: *** [R] Error 1

How to fix this error in netbeans?

I get this error message. I tried to get the right things with CYGWIN, did I do something wrong? Do you need more information?
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/cygdrive/c/Users/Liam/Documents/NetBeansProjects/playing with c'
cygwin warning:
MS-DOS style path detected: build/Debug/Cygwin_4.x-Windows/hello\.d
Preferred POSIX equivalent is: build/Debug/Cygwin_4.x-Windows/hello/.d
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/Cygwin_4.x-Windows/playing_with_c.exe
make[2]: Entering directory `/cygdrive/c/Users/Liam/Documents/NetBeansProjects/playing with c'
mkdir -p dist/Debug/Cygwin_4.x-Windows
gcc -o dist/Debug/Cygwin_4.x-Windows/playing_with_c build/Debug/Cygwin_4.x-Windows/hello\ world.o build/Debug/Cygwin_4.x-Windows/main.o
nbproject/Makefile-Debug.mk:63: recipe for target `dist/Debug/Cygwin_4.x-Windows/playing_with_c.exe' failed
make[2]: Leaving directory `/cygdrive/c/Users/Liam/Documents/NetBeansProjects/playing with c'
nbproject/Makefile-Debug.mk:60: recipe for target `.build-conf' failed
make[1]: Leaving directory `/cygdrive/c/Users/Liam/Documents/NetBeansProjects/playing with c'
nbproject/Makefile-impl.mk:39: recipe for target `.build-impl' failed
build/Debug/Cygwin_4.x-Windows/main.o: In function `main':
/cygdrive/c/Users/Liam/Documents/NetBeansProjects/playing with c/main.c:14: multiple definition of `_main'
build/Debug/Cygwin_4.x-Windows/hello world.o:/cygdrive/c/Users/Liam/Documents/NetBeansProjects/playing with c/hello world.c:3: first defined here
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/Cygwin_4.x-Windows/playing_with_c.exe] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 3s)
You have defined the main method in multiple places: main.c:14 and at hello world.c:3.
A program can have only 1 main method.
Either remove one of those files from the project, or remove one of the main method definitions.

Error Building Clang

I am trying to build Clang on Linux (Amazon's EC2). I am running the make as per the guide at:
http://clang.llvm.org/get_started.html
I am getting the following link error messages:
llvm[2]: Linking Debug+Asserts executable opt
/home/ec2-user/benchmark/build/tools/opt/Debug+Asserts/opt.o: In function `llvm::ParseIR(llvm::MemoryBuffer*, llvm::SMDiagnostic&, llvm::LLVMContext&)':
opt.cpp:(.text._ZN4llvm7ParseIREPNS_12MemoryBufferERNS_12SMDiagnosticERNS_11LLVMContextE[llvm::Pars eIR(llvm::MemoryBuffer*, llvm::SMDiagnostic&, llvm::LLVMContext&)]+0x5f): undefined reference to `llvm::ParseBitcodeFile(llvm::MemoryBuffer*, llvm::LLVMContext&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
collect2: ld returned 1 exit status
make[2]: *** [/home/ec2-user/benchmark/build/Debug+Asserts/bin/opt] Error 1
make[2]: Leaving directory `/home/ec2-user/benchmark/build/tools/opt'
make[1]: *** [opt/.makeall] Error 2
make[1]: Leaving directory `/home/ec2-user/benchmark/build/tools'
make: *** [all] Error 1
Does anyone know what this means?
Edit: I rebuilt the entire project from svn and now I am getting the following error:
COMPILE: clang_linux/asan-i386/i386: /home/ec2-user/benchmark/llvm/projects/compiler-rt/lib/asan/asan_rtl.cc
/home/ec2-user/benchmark/llvm/projects/compiler-rt/lib/asan/asan_rtl.cc:28:10: fatal error: 'new' file not found
#include <new>
^
1 error generated.
make[5]: *** [/home/ec2-user/benchmark/build/tools/clang/runtime/compiler-rt/clang_linux/asan-i386/i386/SubDir.lib__asan/asan_rtl.o] Error 1
make[5]: Leaving directory `/home/ec2-user/benchmark/llvm/projects/compiler-rt'
make[4]: *** [BuildRuntimeLibraries] Error 2
make[4]: Leaving directory `/home/ec2-user/benchmark/build/tools/clang/runtime/compiler-rt'
make[3]: *** [compiler-rt/.makeall] Error 2
make[3]: Leaving directory `/home/ec2-user/benchmark/build/tools/clang/runtime'
make[2]: *** [all] Error 1
make[2]: Leaving directory `/home/ec2-user/benchmark/build/tools/clang'
make[1]: *** [clang/.makeall] Error 2
make[1]: Leaving directory `/home/ec2-user/benchmark/build/tools'
make: *** [all] Error 1
I followed this and I was able to build it successfully in the first shot itself.
I guess, you are hitting issues with your C++ standard library headers. So you need to follow the Step #6 in the above mentioned link!
Start a fresh build and please ensure that you satisfy this prerequisite.

Resources