sourcey / libsourcey

C++14 evented IO libraries for high performance networking and media based applications
https://sourcey.com/libsourcey
GNU Lesser General Public License v2.1
1.31k stars 347 forks source link

OSX/Make Build: Error linking against libscy_uv.a #66

Closed Jared314 closed 8 years ago

Jared314 commented 9 years ago

I'm attempting to use libsourcey in a C++ library, using CMake and Make to build libsourcey as an external project. Unfortunately, OSX's version of ar does not allow libraries that contain only headers, like libscy_uv.

Is there a way to prevent it from linking against libscv_uv? I'm fairly new to CMake, so I might be building it incorrectly.

CMakeLists.txt:

project(project1)
include(ExternalProject)

ExternalProject_Add(libsourcey
    SOURCE_DIR ${PROJECT_SOURCE_DIR}/libsourcey
    DOWNLOAD_COMMAND ""
    CMAKE_ARGS -DBUILD_SHARED_LIBS:BOOL=0 -DLIBRARY_OUTPUT_PATH:PATH= -DBUILD_APPLICATIONS:BOOL=0 -DWITH_FFMPEG:BOOL=0 -DWITH_OPENSSL:BOOL=0 -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_BACKWARDS_COMPATIBILITY:STRING=2.8
    )
# ...
add_library(project1 MODULE ...)
target_link_libraries(project1 ...)
add_dependencies(project1 libsourcey)
#...

Build Error:

Linking CXX static library libscy_uv.a
ar: no archive members specified
usage:  ar -d [-TLsv] archive file ...
    ar -m [-TLsv] archive file ...
    ar -m [-abiTLsv] position archive file ...
    ar -p [-TLsv] archive [file ...]
    ar -q [-cTLsv] archive file ...
    ar -r [-cuTLsv] archive file ...
    ar -r [-abciuTLsv] position archive file ...
    ar -t [-TLsv] archive [file ...]
    ar -x [-ouTLsv] archive [file ...]
make[5]: *** [src/uv/libscy_uv.a] Error 1
make[4]: *** [src/uv/CMakeFiles/uv.dir/all] Error 2
make[3]: *** [all] Error 2
make[2]: *** [plugins/project1/libsourcey-prefix/src/libsourcey-stamp/libsourcey-build] Error 2
make[1]: *** [plugins/project1/CMakeFiles/libsourcey.dir/all] Error 2
make: *** [all] Error 2
ZelimDamian commented 8 years ago

This is due to the fact that uv module is a header only module. I was able to overcome this by checking if(NOT lib_srcs STREQUAL "") and only doing add_library in case its true. This is all happening in LibSourceyModule.cmake.

auscaster commented 8 years ago

Thanks for clearing up this outstanding OSX issue. Can you please make a PR for these fixes when you are able?

On 27 November 2015 at 07:47, Zelim Damian notifications@github.com wrote:

This is due to the fact that uv module is a header only module. I was able to overcome this by checking if(NOT lib_srcs STREQUAL "") and only doing add_library in case its true

— Reply to this email directly or view it on GitHub https://github.com/sourcey/libsourcey/issues/66#issuecomment-159997139.

ZelimDamian commented 8 years ago

I'm sorry, but I'm not sure if my changes are clean enough for a PR. Especially since I have not tested on non OSX machines. I had to change a lot of CMake to make it compile, but then I still got run-time assertions. I will try to clean up my changes for this particular issue and do a PR though.

ZelimDamian commented 8 years ago

@Jared314, here a version that compiles on OSX: https://github.com/ZelimDamian/libsourcey/commit/48e00c50b34980a013a3f8fc6763075d7b2abbfb

I'm not PRring just yet as I have not tested on a Windows machine

Jared314 commented 8 years ago

@ZelimDamian Thank you. I will give it a shot and update this issue if it works.

auscaster commented 8 years ago

Please sync with the latest source, as many linker issues have been fixed.