[CMake] Re-2: .so libraries and Xcode

Bjoern Sarrazin bjoern at apoambach.de
Mon Mar 3 14:18:49 EST 2014


                        Hi,
no, I haven't. I assume the ".dylib" extension on Mac is pure convention, isn't
it? And this convention is not used for instance by ROOT libraries installed
via macports
(https://trac.macports.org/browser/trunk/dports/science/root/Portfile). This is
not a problem for cmake when used with make on OS X but it is when used with
Xcode.  No "not a valid library name" warning shows up when used with make and
linking is successful. 
To give a minimal example, I use a directory with the following content:
- empty directory build
- file CMakeLists.txt:
CMAKE_MINIMUM_REQUIRED(VERSION 2.6 FATAL_ERROR)PROJECT(test CXX)add_executable(
myexe helloworld.cpp)target_link_libraries(my exe /fullpath/mylib.so)
- file helloworld.cpp :
#include <iostream>
int main(){
  std::cout<<"Hello world"<<std::endl;
}
- file mylib.cpp:

void foo(){
}
Than I create the library with:clang++ -dynamiclib -o mylib.so mylib.cppAfter
that the following works fine without any warning:cd buildcmake ..make
But the following gives the warning:cd buildcmake -G Xcode ..
And the build in Xcode fails. :(
Cheers,Bjoern            
  
Original Message processed by David.fx12   Subject: Re: [CMake] .so libraries
and Xcode (03-Mar-2014 19:04)From:    Lucas Soltic
<lucas.soltic at orange.fr>To:      bjoern at apoambach.de Le 3 mars 2014 à
18:25, Bjoern Sarrazin <bjoern at apoambach.de> a écrit :




                        Hi!
I'm trying to link shared libraries with filename extension ".so"  (like the
ROOT libraries from root.cern.ch). This works fine using Makefiles, also on Mac
OS. Using option -G Xcode however it does not work:
I use something like
target_link_libraries(myexe /full/path/to/somelib.so)
Running cake with -G Xcode prints a warning:
  "Target "myexe" links to item /full/path/to/somelib.so which is a full-path
but not a valid library file name."
When I run the build step in Xcode the linking step fails with ld: library not
found for -lsomelib.so.
What's going wrong here? I have this problem whenever I try to link a shared
library with .so filename extension and option -G Xcode.
 As a work around everything works fine when I use
LINK_DIRECTORIES( /full/path/to )
and add -lsomelib to the link flags of my exe. But this is an annoying
workaround because I'd like to use FIND_LIBRARY to search for the library and
FIND_LIBRARY returns /full/path/to/somelib.so. 
Cheers,Bjorn



    

Hi,
Mac OS X libraries have a ".dylib" extension, not ".so". Thus somelib.so is
"not a valid library file name".Maybe your workaround works because you have
somelib.dylib in your link directory?
Lucas   
      




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20140303/efb74a70/attachment-0001.html>


More information about the CMake mailing list