Page 1 of 1

Can't compile referencing another library

Posted: Fri Apr 29, 2016 2:41 pm
by kiwi
My configuration:
CodeLite 9.1.0 (installed from Arch User Repository)
clang version 3.7.1 (tags/RELEASE_371/final)
arch linux

The problem here is that I can't include a static library inside another one (lib in executable works fine). It just doesn't use the Libraries Search Path but rather tries to find the Library by name, which it can't because it's in the wrong folder.
There is a workaround but that's not how it's supposed to work and doesn't make me comfortable.

Project1: just a .h file for testing, create the static library.
Project2: more test files, static library
Libraries Search Path: (doesn't matter, won't work)
Libraries ../Project1/Debug/libProject1.a (workaround, usually I would put Project1 here and the respective path above)

I've posted this as a bug on github but eranif told me that it's a configuration issue (sorry!). Whatever, I can't find the lever to make it work properly. Any help is appreciated.

(without workaround, I've attached the files here)

Code: Select all

/bin/sh -c 'make -j4 -e -f  Makefile'
----------Building project:[ Project1 - Debug ]----------
make[1]: Entering directory '/home/viktor/Documents/Project/Project1'
/usr/bin/clang++  -c  "/home/viktor/Documents/Project/Project1/mylib1.cpp" -g  -o ./Debug/mylib1.cpp.o -I. -I.
/usr/bin/llvm-ar rcu ./Debug/libProject1.a ./Debug/mylib1.cpp.o
make[1]: Leaving directory '/home/viktor/Documents/Project/Project1'
----------Building project:[ Project2 - Debug ]----------
make[1]: Entering directory '/home/viktor/Documents/Project/Project2'
/usr/bin/clang++  -c  "/home/viktor/Documents/Project/Project2/mylib2.cpp" -g  -o ./Debug/mylib2.cpp.o -I. -I. -I"/home/viktor/Documents/Project"/Project1/
/usr/bin/llvm-ar rcu ./Debug/libProject2.a ./Debug/mylib2.cpp.o   "Project1"
/usr/bin/llvm-ar: Project1: No such file or directory.
Project2.mk:76: recipe for target 'Debug/libProject2.a' failed
make[1]: *** [Debug/libProject2.a] Error 1
make[1]: Leaving directory '/home/viktor/Documents/Project/Project2'
Makefile:4: recipe for target 'All' failed

Re: Can't compile referencing another library

Posted: Sat Apr 30, 2016 3:12 pm
by eranif
You are trying to link 2 static libraries? whats the point of that?
Usually, you should link static libraries for an executable or shared object (or DLL)

Eran