Closed EMCP closed 2 years ago
Well it looks like it is unable to find the library to link to. The static and shared libraries are named differently in my cmake screen_capture_lite_static screen_capture_lite_shared both are built by default
You might need to reference the name of the type of library you are trying to link against: shared or static
Thanks for replying @smasherprog , I fiddled a bit with my recipe and (maybe) got closer
It might now be a question of Mac OSX compiler not seeing the security libs etc... I will keep trying and attempt to try these different references of static or dynamic
with conan though my experience was I put the name of the conan package.. but it's worth a try
thanks!
EDIT:
according to the docs, my recipe builds both types of libraries (shared and non shared.. and the default is non-shared.. which I assume means static?)
https://docs.conan.io/en/latest/creating_packages/getting_started.html
topics = ("screengrab", "capture")
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False]}
default_options = {"shared": False}
generators = "cmake"
It looks like you are now missing some libraries https://github.com/smasherprog/screen_capture_lite/blob/master/Example_CPP/CMakeLists.txt
the if apple libraries need to be added to your cmake
Exactly.. I think this is where I'll reach out to the Conan community as I've not really done that before
Thanks for checking in, I also see your example code compiled successfully via my recipe.. which means as a workaround I can clone the entire repo.. modify the example in place, and get at least a start of a experiment going
On Sun, Oct 10, 2021, 20:44 Scott @.***> wrote:
It looks like you are now missing some libraries https://github.com/smasherprog/screen_capture_lite/blob/master/Example_CPP/CMakeLists.txt
the if apple libraries need to be added to your cmake
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/smasherprog/screen_capture_lite/issues/115#issuecomment-939532540, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA4FJSVJWA5DURM2X6VTQBLUGHNKNANCNFSM5FWUW3RQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
for those who might look later how to do this.. so far this is my closest clue
https://docs.conan.io/en/latest/howtos/link_apple_framework.html
It is common in MacOS that your Conan package needs to link with a complete Apple framework, and, of course, you want to propagate this information to all projects/libraries that use your package.
With regular libraries, use self.cpp_info.libs
object to append to it all the libraries:
def package_info(self):
self.cpp_info.libs = ["SDL2"]
self.cpp_info.libs.append("OpenGL32")
With frameworks we need to use self.cpp_info.frameworks in a similar manner:
def package_info(self):
self.cpp_info.libs = ["SDL2"]
self.cpp_info.frameworks.extend(["Carbon", "CoreAudio", "Security", "IOKit"])
were you able to get it building?
so..
after I re-read your original reply I realized I'd mistakenly picked version 11.0.0 .. because I hadn't scrolled down to see there were yet higher git tags to be cloned..
I have since realized this error and while I did get that original Example v11.0.0 building with conan.. I am now going back to the drawing board.. and attempting to build v17.1.439
since that's the latest
for others, heres the recipe for that version of the code
from conans import ConanFile, CMake, tools
class ScreenCapLiteConan(ConanFile):
name = "screen_capture_lite"
version = "17.1.439"
license = "MIT"
author = "smasherprog@gmail.com"
url = "https://github.com/smasherprog/screen_capture_lite"
description = "Capture screen grabs in Mac OSX"
topics = ("screengrab", "capture")
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False]}
default_options = {"shared": False}
generators = "cmake"
def source(self):
self.run("git clone --depth 1 --branch 17.1.439 git@github.com:smasherprog/screen_capture_lite.git")
def build(self):
cmake = CMake(self)
cmake.configure(source_folder="screen_capture_lite")
cmake.build()
def package(self):
self.copy("*.h", dst="include", src="screen_capture_lite/include")
self.copy("*hello.lib", dst="lib", keep_path=False)
self.copy("*.dll", dst="bin", keep_path=False)
self.copy("*.so", dst="lib", keep_path=False)
self.copy("*.dylib", dst="lib", keep_path=False)
self.copy("*.a", dst="lib", keep_path=False)
def package_info(self):
if self.settings.os == "Macos":
self.cpp_info.libs = ["libscreen_capture_lite_static.a"] if not self.options.shared else ["libscreen_capture_lite_shared.dylib"]
elif self.settings.os == "Linux":
self.cpp_info.libs = ["libscreen_capture_lite_static.a"] if not self.options.shared else ["libscreen_capture_lite_shared.so"]
Just for clarity, I won't plan to upload this to say.. bintray or whatever public conan repos exist... for now I just build it and push it to a private conan repository on my gitlab account
that upload of the packages went fine.. you can see that here
conan create . /prod
Exporting package recipe
screen_capture_lite/17.1.439@/prod: The stored package has not changed
screen_capture_lite/17.1.439@/prod: Exported revision: f02e2bfab99a796aa349f61132f9941f
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=apple-clang
compiler.libcxx=libc++
compiler.version=13.0
os=Macos
os_build=Macos
[options]
[build_requires]
[env]
screen_capture_lite/17.1.439@/prod: Forced build from source
Installing package: screen_capture_lite/17.1.439@/prod
Requirements
screen_capture_lite/17.1.439@/prod from 'gitlab-screen-cap' - Cache
Packages
screen_capture_lite/17.1.439@/prod:2cd20192e71f56e1115fbdc2ebf2871bb61152e4 - Build
Installing (downloading, building) binaries...
screen_capture_lite/17.1.439@/prod: Copying sources to build folder
screen_capture_lite/17.1.439@/prod: Building your package in /Users//.conan/data/screen_capture_lite/17.1.439//prod/build/2cd20192e71f56e1115fbdc2ebf2871bb61152e4
screen_capture_lite/17.1.439@/prod: Generator cmake created conanbuildinfo.cmake
screen_capture_lite/17.1.439@/prod: Calling build()
-- The C compiler identification is AppleClang 13.0.0.13000029
-- The CXX compiler identification is AppleClang 13.0.0.13000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Building STATIC Library
Building SHARED Library
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
CMake Warning at src_csharp/CMakeLists.txt:11 (message):
CMake failed: dotnet executable not found but by this build. You must
install dotnet to generate csharp bindings
-- Using Cocoa for window creation
CMake Warning at Example_CSharp/CMakeLists.txt:11 (message):
CMake failed: dotnet executable not found but by this build. You must
install dotnet to generate csharp bindings
-- Configuring done
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
CMAKE_EXPORT_NO_PACKAGE_REGISTRY
CONAN_COMPILER
CONAN_COMPILER_VERSION
CONAN_CXX_FLAGS
CONAN_C_FLAGS
CONAN_EXPORTED
CONAN_IN_LOCAL_CACHE
CONAN_LIBCXX
CONAN_SHARED_LINKER_FLAGS
-- Build files have been written to: /Users//.conan/data/screen_capture_lite/17.1.439//prod/build/2cd20192e71f56e1115fbdc2ebf2871bb61152e4
[ 18%] Building C object Example_OpenGL/glfw/src/CMakeFiles/glfw.dir/context.c.o
[ 18%] Building CXX object src_cpp/CMakeFiles/screen_capture_lite_static.dir/SCCommon.cpp.o
[ 20%] Building C object Example_OpenGL/glfw/src/CMakeFiles/glfw.dir/input.c.o
[ 22%] Building CXX object src_cpp/CMakeFiles/screen_capture_lite_static.dir/ios/GetWindows.cpp.o
[ 22%] Building CXX object src_cpp/CMakeFiles/screen_capture_lite_static.dir/ThreadManager.cpp.o
[ 20%] Building C object Example_OpenGL/glfw/src/CMakeFiles/glfw.dir/init.c.o
[ 22%] Building CXX object src_cpp/CMakeFiles/screen_capture_lite_shared.dir/ScreenCapture.cpp.o
[ 24%] Building CXX object src_cpp/CMakeFiles/screen_capture_lite_static.dir/ScreenCapture.cpp.o
[ 24%] Building CXX object src_cpp/CMakeFiles/screen_capture_lite_shared.dir/SCCommon.cpp.o
[ 24%] Building CXX object src_cpp/CMakeFiles/screen_capture_lite_shared.dir/ios/GetWindows.cpp.o
[ 24%] Building C object Example_OpenGL/glfw/src/CMakeFiles/glfw.dir/monitor.c.o
[ 24%] Building CXX object src_cpp/CMakeFiles/screen_capture_lite_shared.dir/ThreadManager.cpp.o
[ 26%] Building C object src_cpp/CMakeFiles/screen_capture_lite_static.dir/ios/NSMouseCapture.m.o
[ 28%] Building C object src_cpp/CMakeFiles/screen_capture_lite_shared.dir/ios/NSMouseCapture.m.o
[ 30%] Building CXX object src_cpp/CMakeFiles/screen_capture_lite_static.dir/ios/NSFrameProcessor.cpp.o
[ 32%] Building C object Example_OpenGL/glfw/src/CMakeFiles/glfw.dir/vulkan.c.o
[ 34%] Building CXX object src_cpp/CMakeFiles/screen_capture_lite_shared.dir/ios/NSFrameProcessor.cpp.o
[ 36%] Building CXX object src_cpp/CMakeFiles/screen_capture_lite_static.dir/ios/NSFrameProcessor.mm.o
[ 38%] Building C object Example_OpenGL/glfw/src/CMakeFiles/glfw.dir/window.c.o
[ 40%] Building CXX object src_cpp/CMakeFiles/screen_capture_lite_static.dir/ios/NSMouseProcessor.cpp.o
[ 42%] Building C object Example_OpenGL/glfw/src/CMakeFiles/glfw.dir/cocoa_init.m.o
[ 44%] Building CXX object src_cpp/CMakeFiles/screen_capture_lite_shared.dir/ios/NSFrameProcessor.mm.o
[ 46%] Building C object Example_OpenGL/glfw/src/CMakeFiles/glfw.dir/cocoa_joystick.m.o
[ 48%] Building CXX object src_cpp/CMakeFiles/screen_capture_lite_static.dir/ios/CGFrameProcessor.cpp.o
[ 51%] Building CXX object src_cpp/CMakeFiles/screen_capture_lite_shared.dir/ios/NSMouseProcessor.cpp.o
[ 53%] Building CXX object src_cpp/CMakeFiles/screen_capture_lite_static.dir/ios/GetMonitors.cpp.o
[ 55%] Building C object Example_OpenGL/glfw/src/CMakeFiles/glfw.dir/cocoa_monitor.m.o
[ 57%] Building CXX object src_cpp/CMakeFiles/screen_capture_lite_static.dir/ios/ThreadRunner.cpp.o
[ 59%] Building CXX object src_cpp/CMakeFiles/screen_capture_lite_shared.dir/ios/CGFrameProcessor.cpp.o
[ 61%] Building C object Example_OpenGL/glfw/src/CMakeFiles/glfw.dir/cocoa_window.m.o
[ 63%] Building CXX object src_cpp/CMakeFiles/screen_capture_lite_shared.dir/ios/GetMonitors.cpp.o
[ 65%] Building CXX object src_cpp/CMakeFiles/screen_capture_lite_shared.dir/ios/ThreadRunner.cpp.o
/Users//.conan/data/screen_capture_lite/17.1.439//prod/build/2cd20192e71f56e1115fbdc2ebf2871bb61152e4/screen_capture_lite/src_cpp/ios/CGFrameProcessor.cpp:39:14: warning: unused variable 'bitsperpixel' [-Wunused-variable]
auto bitsperpixel = CGImageGetBitsPerPixel(imageRef);
^
[ 67%] Building C object Example_OpenGL/glfw/src/CMakeFiles/glfw.dir/cocoa_time.c.o
[ 69%] Building C object Example_OpenGL/glfw/src/CMakeFiles/glfw.dir/posix_thread.c.o
1 warning generated.
[ 71%] Building C object Example_OpenGL/glfw/src/CMakeFiles/glfw.dir/nsgl_context.m.o
[ 73%] Building C object Example_OpenGL/glfw/src/CMakeFiles/glfw.dir/egl_context.c.o
[ 75%] Building C object Example_OpenGL/glfw/src/CMakeFiles/glfw.dir/osmesa_context.c.o
/Users//.conan/data/screen_capture_lite/17.1.439//prod/build/2cd20192e71f56e1115fbdc2ebf2871bb61152e4/screen_capture_lite/src_cpp/ios/CGFrameProcessor.cpp:39:14: warning: unused variable 'bitsperpixel' [-Wunused-variable]
auto bitsperpixel = CGImageGetBitsPerPixel(imageRef);
^
[ 77%] Linking CXX static library libscreen_capture_lite_static.a
[ 77%] Built target screen_capture_lite_static
1 warning generated.
[ 81%] Building CXX object Example_CPP/CMakeFiles/screen_capture_example_cpp_static.dir/lodepng.cpp.o
[ 81%] Building CXX object Example_CPP/CMakeFiles/screen_capture_example_cpp_static.dir/Screen_Capture_Example.cpp.o
[ 83%] Linking C static library libglfw3.a
[ 83%] Built target glfw
[ 85%] Building CXX object Example_OpenGL/CMakeFiles/screen_capture_example_opengl_cpp_static.dir/Screen_Capture_Example_OpenGL.cpp.o
[ 87%] Building C object Example_OpenGL/CMakeFiles/screen_capture_example_opengl_cpp_static.dir/glfw/deps/glad_gl.c.o
[ 89%] Linking CXX shared library ../libscreen_capture_lite_shared.dylib
[ 89%] Built target screen_capture_lite_shared
[ 91%] Building CXX object Example_CPP/CMakeFiles/screen_capture_example_cpp_shared.dir/lodepng.cpp.o
[ 93%] Building CXX object Example_CPP/CMakeFiles/screen_capture_example_cpp_shared.dir/Screen_Capture_Example.cpp.o
[ 95%] Linking CXX executable ../screen_capture_example_opengl_cpp_static
[ 95%] Built target screen_capture_example_opengl_cpp_static
[ 97%] Linking CXX executable ../screen_capture_example_cpp_static
[ 97%] Built target screen_capture_example_cpp_static
[100%] Linking CXX executable ../screen_capture_example_cpp_shared
[100%] Built target screen_capture_example_cpp_shared
screen_capture_lite/17.1.439@/prod: Package '2cd20192e71f56e1115fbdc2ebf2871bb61152e4' built
screen_capture_lite/17.1.439@/prod: Build folder /Users//.conan/data/screen_capture_lite/17.1.439//prod/build/2cd20192e71f56e1115fbdc2ebf2871bb61152e4
screen_capture_lite/17.1.439@/prod: Generated conaninfo.txt
screen_capture_lite/17.1.439@/prod: Generated conanbuildinfo.txt
screen_capture_lite/17.1.439@/prod: Generating the package
screen_capture_lite/17.1.439@/prod: Package folder /Users//.conan/data/screen_capture_lite/17.1.439//prod/package/2cd20192e71f56e1115fbdc2ebf2871bb61152e4
screen_capture_lite/17.1.439@/prod: Calling package()
screen_capture_lite/17.1.439@/prod package(): Packaged 14 '.h' files
screen_capture_lite/17.1.439@/prod package(): Packaged 2 '.a' files: libglfw3.a, libscreen_capture_lite_static.a
screen_capture_lite/17.1.439@/prod package(): Packaged 1 '.dylib' file: libscreen_capture_lite_shared.dylib
screen_capture_lite/17.1.439@/prod: Package '2cd20192e71f56e1115fbdc2ebf2871bb61152e4' created
screen_capture_lite/17.1.439@/prod: Created package revision b673d51a699f1d9a1cb45173b2f72029
notice the last lines in particular are a good sign.. it picked up both the dynamic and static library builds
screen_capture_lite/17.1.439@/prod package(): Packaged 14 '.h' files
screen_capture_lite/17.1.439@/prod package(): Packaged 2 '.a' files: libglfw3.a, libscreen_capture_lite_static.a
screen_capture_lite/17.1.439@/prod package(): Packaged 1 '.dylib' file: libscreen_capture_lite_shared.dylib
nice so its working for you then?
I got it! Thanks for your tips which spurred me to re-check the git tag I pulled! this worked now.
so I've gotten the library right where I wanted it.. namely, in my conan recipe you must call out for these name changes based on static or dynamic libraries.. from the same conan package (otherwise you have this proliferation of static-dynamic duplicate packages)
so I had the recipe like so
def package_info(self):
if self.settings.os == "Macos":
self.cpp_info.libs = ["libscreen_capture_lite_static.a"] if not self.options.shared else ["libscreen_capture_lite_shared.dylib"]
elif self.settings.os == "Linux":
self.cpp_info.libs = ["libscreen_capture_lite_static.a"] if not self.options.shared else ["libscreen_capture_lite_shared.so"]
I skip windows since right now I don't plan to need that
cmake_minimum_required(VERSION 2.8.12)
project(osx_screengrabber)
add_compile_options(-std=c++17)
# Using the "cmake" generator
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)
if(WIN32)
set(${PROJECT_NAME}_PLATFORM_LIBS Dwmapi)
add_definitions(-DNOMINMAX)
elseif(APPLE)
find_package(Threads REQUIRED)
find_library(corefoundation_lib CoreFoundation REQUIRED)
find_library(cocoa_lib Cocoa REQUIRED)
find_library(coremedia_lib CoreMedia REQUIRED)
find_library(avfoundation_lib AVFoundation REQUIRED)
find_library(coregraphics_lib CoreGraphics REQUIRED)
find_library(corevideo_lib CoreVideo REQUIRED)
set(${PROJECT_NAME}_PLATFORM_LIBS
${CMAKE_THREAD_LIBS_INIT}
${corefoundation_lib}
${cocoa_lib}
${coremedia_lib}
${avfoundation_lib}
${coregraphics_lib}
${corevideo_lib}
)
else()
find_package(X11 REQUIRED)
if(!X11_XTest_FOUND)
message(FATAL_ERROR "X11 extensions are required, but not found!")
endif()
if(!X11_Xfixes_LIB)
message(FATAL_ERROR "X11 fixes extension is required, but not found!")
endif()
find_package(Threads REQUIRED)
set(${PROJECT_NAME}_PLATFORM_LIBS
${X11_LIBRARIES}
${X11_Xfixes_LIB}
${X11_XTest_LIB}
${X11_Xinerama_LIB}
${CMAKE_THREAD_LIBS_INIT}
)
endif()
add_executable(${PROJECT_NAME}_static
src/lodepng.cpp
src/osx_screengrabber.cpp
)
target_link_libraries(${PROJECT_NAME}_static CONAN_PKG::screen_capture_lite ${${PROJECT_NAME}_PLATFORM_LIBS} )
notice I drop the dynamic libs and just focus on static, the result ...
-- The C compiler identification is AppleClang 13.0.0.13000029
-- The CXX compiler identification is AppleClang 13.0.0.13000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Conan: Adjusting output directories
-- Conan: Using cmake targets configuration
-- Library libscreen_capture_lite_static.a found /Users/emcp/.conan/data/screen_capture_lite/17.1.439/prod/package/2cd20192e71f56e1115fbdc2ebf2871bb61152e4/lib/libscreen_capture_lite_static.a
-- Conan: Adjusting default RPATHs Conan policies
-- Conan: Adjusting language standard
-- Current conanbuildinfo.cmake directory: /Users/emcp/Dev/git/osx-screengrabber/build
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/emcp/Dev/git/osx-screengrabber/build
[ 33%] Building CXX object CMakeFiles/osx_screengrabber_static.dir/src/lodepng.cpp.o
[ 66%] Building CXX object CMakeFiles/osx_screengrabber_static.dir/src/osx_screengrabber.cpp.o
[100%] Linking CXX executable bin/osx_screengrabber_static
[100%] Built target osx_screengrabber_static
(base) emcp@emcp-mac-mini bin % ./osx_screengrabber_static
Starting Capture Demo/Test
Testing captured monitor bounds check
Id=751385872 Index=0 Height=2160 Width=3840 OffsetX=0 OffsetY=0 Name=Monitor 751385872
Id=751385872 Index=0 Height=2161 Width=3840 OffsetX=0 OffsetY=0 Name=Monitor 751385872
Id=751385872 Index=0 Height=2160 Width=3841 OffsetX=0 OffsetY=0 Name=Monitor 751385872
Running display capturing for 10 seconds
Library is requesting the list of monitors to capture!
Id=751385872 Index=0 Height=2160 Width=3840 OffsetX=0 OffsetY=0 Name=Monitor 751385872
onNewFrame fps7
onNewFrame fps10
onNewFrame fps11
onNewFrame fps10
onNewFrame fps10
onNewFrame fps11
onNewFrame fps10
onNewFrame fps10
onNewFrame fps10
^C
now I do not know where the frames go.. but I understood you said in the instructions from here I must copy them OUT .. so I will take a break now and come back to this next weekend or sooner hopefully.. but hey it runs! and with conan I can now sprinkle this library in easily into some other projects using apache thrift !
and i found the lines to uncomment to get .jpgs..
the color is looking off, but I am guessing this is merely a consequence of the bits needing to be encoded a certain way.. but this thing is FAST! Hats off to you for this !
Best Case -- Time to get diffs 35 microseconds
Best Case -- Lowest Time 35 microseconds
onNewFrame fps11
Worst Case -- Time to get diffs 3297 microseconds
Worst Case -- Lowest Time 2845 microseconds
glad to hear everything worked out
For those unaware, conan is a C++ package manager which can simplify your build process.
I have attempted to write my first conan recipe or two with varied success. I am now working on a recipe for this library.. but not quite maybe getting the naming correct.. anyone familiar with conan can lend a hand??
my
conanfile.py
Then my example program (I basically just copy the example folder for now) has it's
CMakeLists.txt
as suchconan install ..
works from a<example_proj_root>/build
works fine... then I goto compile