CMOS Camera SDK on macOS -- Trouble with My First SDK Integration

Hello, I usually get along pretty well with oF but I am finding myself out of my depth in this case.

Camera SDK

I am trying to use the SDK for a CMOS camera made by ZWO. The SDK comes from the ZWO website and (spoiler alert) the contents are:

demo/
	bin/
		x86/
			main_SDK2_video_mac
			test_gui2_snap
			test_gui2_video
		main_SDK2_snap.cpp
		main_SDK2_video_mac.cpp
		main_SDK2_video.cpp
	Makefile
	readme.txt
doc/
	ASICamera2 Software Development Kit.pdf
include/
	ASICamera2.h
lib/
	armv6/
		libASICamera2.a
		libASICamera2.so
		libASICamera2.so.1.16.3
	armv7/
		libASICamera2.a
		libASICamera2.so
		libASICamera2.so.1.16.3
	armv8/
		libASICamera2.a
		libASICamera2.so
		libASICamera2.so.1.16.3
	asi.rules
	mac/
		libASICamera2.a
		libASICamera2.dylib
		libASICamera2.dylib.1.16.3
	README.txt
	x64/
		libASICamera2.a
		libASICamera2.so
		libASICamera2.so.1.16.3
	x86/
		libASICamera2.a
		libASICamera2.so
		libASICamera2.so.1.16.3
license.txt

My Attempts

There might be some holes in this because I worked on a bulk of it last week. I’ve also looked through the SDK examples, etc., but I’m still writing this post so the docs weren’t that helpful for me. I took some guidance from a few places but this is the only source I still have around.

Add Directly to Project

I brought ASICamera2.h into my project, imported that header file into a CPP file, and code completion seems to work as expected. In my target settings I added the macos folder from the SDK to Link Binary With Libraries list. I have also tried other variations like adding a higher-lever folder, adding each of the system folders with the *.a and *.so files, and just adding the *.a file(s).

As Addon

I also tried doing approximately the same process by modifying an empty add-on template, adding it with projectGenerator.

Error

Add Directly to Project

When I Build for My Mac (an M1) the main issue seems to be ld: symbol(s) not found for architecture x86_64. When I Build for My Mac (Rosetta) I am currently getting the same error but I thought that last week it showed just ...x86 (or was it ...x64? I know I should know, but, ugh).

As Addon

I don’t recall what happened and I have so little faith in my work there that I won’t bother re-creating unless this seems like this is where the answer lies.

Hi,

Based on that file list the only file you would want to add to your project is:
mac/libASICamera2.a

Add the relative path of the file from your xcodeproj file location to the libASICamera2.a to the Debug and Release section here ( add a line with the + symbol below $(LIB_OF_DEBUG) ):

If you are having issues figuring out if the path is correct you could even add the absolute file path.

Also if you need to check the architecture of the file ( to make sure it is x86_64 ) you can do:
lipo -i libASICamera2.a

Hope that helps!
Theo

Seems like I was trying to take the long way around the mountain! But it’s not fixed yet… Following your directions:

The mac version of libASICamera2.a shows it’s for i386 x86_64 while running lipo on any of the others returns archive with no architecture specification. When I build now the error has changed to ld: symbol(s) not found for architecture arm64.

When I build for Rosetta (thinking it might get away from arm64) it has the original ld: symbol(s) not found for architecture x86_64 and messages like Object file (libASICamera2.a(Camera.o)) was built for newer macOS version (10.13) than being linked (10.9).

Should I be trying to limit the architectures it builds for or am I hosed? I have my 2015 MBP around somewhere if I need to get back to Intel.

That makes sense. ( the arm64 part ).
I think maybe start in Rosetta mode. Check you have build active architectures only set to YES for both Debug and Release ( in build settings ).

Then either add the file path to the other linker flags for Debug and Release.

Or you could also drag and drop the file into the sidebar ( where your source files are listed ) and it should automatically link the file in the link binary with libraries build phase.

It should definitely link as long as you are not trying to build for arm64 natively.

Edit: the warning was built for newer macOS version (10.13) than being linked (10.9). can be ignored as long as it is not an error.

This seemed to have fixed some things. The only errors I see now are about Undefined symbols for x86_64 related to libusb.

Things I know or did:

  • libusb is already installed with Homebrew
  • I unlinked and linked with homebrew
  • I tried (maybe recklessly) /bin/launchctl setenv LIBRARY_PATH /usr/local/lib
  • I tried (maybe recklessly) gcc -L/usr/local/Cellar/libusb/1.0.24/lib -o "libusb_example" ./src/libusb_example.o -lusb1.0 but the file was not found

Thank you SO much for the help!

You could grab and link the libusb from ofxKinect which I think should be pretty compatibile.
Just use the PG to add ofxKinect to your project ( maybe a clean project as it will trash your other settings ) or just manually add the .a like you did for the camera library.

If that libusb is missing 3.0 stuff
the one here should be good: https://github.com/ofTheo/ofxKinectV2/tree/master/libs/libusb

It’s building!! Now to figure out the API, but it seems like we’re in business.

I did have to grab the newer libusb that you linked to