sccn / lsl_archived

Multi-modal time-synched data transmission over local network
242 stars 134 forks source link

help building biosemi app on mac/linux #243

Open nbara opened 6 years ago

nbara commented 6 years ago

Hi all,

Apologies if this has been answered before but I wanted to try the the Biosemi app (among others) on my Mac. I couldn't find any specific building instructions for OSX anywhere. Is this intentional or have I missed something?

Even better, does anyone have a compiled binary for OSX they're willing to share?

dmedine commented 6 years ago

There is no existing build solution for biosemi apart from Windows. If you are familiar with CMake, you might want to follow the pattern of one of the apps that supports CMake (e.g. https://github.com/sccn/labstreaminglayer/blob/master/Apps/BrainProducts/BrainAmpSeries/CMakeLists.txt) to generate an xcode project for you.

cboulay commented 6 years ago

I've attempted to convert BioSemi to the cmake build system. I have a built binary that runs, but I don't have any hardware or drivers to test it on.

See the branch here: https://github.com/sccn/labstreaminglayer/tree/biosemi_cmake

After building the LSL binaries, my build command from inside the Apps/BioSemi folder were:

mkdir build && cd build
cmake .. -DLSL_ROOT=/Volumes/STORE/Tools/Neurophys/labstreaminglayer/build/install/lsl_Release/LSL/ -DCMAKE_INSTALL_PREFIX=./
make
make install

You'll have to modify the LSL_ROOT part to point to the ABSOLUTE path to your recently built LSL binaries. After both are done, look in labstreaminglayer/Apps/BioSemi/build/BioSemi for a BioSemi.app . That should have everything you need.

This program has code to load DLLs/dylibs/sos at runtime. There's also another header file and dylib in the DLL/Mac for libusb. I've never worked with a program that explicitly loads a DLL in code and doesn't link to them first. I have no idea if the dependencies are correctly met.

cboulay commented 6 years ago

Actually, I should tell you the better and easier way to build this, just so you get in good habits.

in a fresh clone of the biosemi_cmake branch, change to the root labstreaminglayer directory...

cd build
cmake .. -DLSLApps_BioSemi=ON
make
make install

Then in build/install/lsl_Release/BioSemi you'll see your app.

nbara commented 6 years ago

Hi @cboulay, thanks for the help !

I've tried your second suggestion and the app seems to build fine but I can't open it :

screen shot 2017-11-14 at 10 36 27

I've tried disabling GateKeeper: sudo spctl --master-disable As well as unquarantining the app: sudo xattr -r -d com.apple.quarantine Biosemi.app

But I suspect the app did not build correctly as it's only 946 bytes.

Here's the terminal output:

→ cmake .. -DLSLApps_BioSemi=ON
-- Linking LSL against: lslboost
-- Found Boost libraries:
-- Found target lsl in current build tree
-- Found target lsl in current build tree
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE
-- Boost version: 1.65.1
-- Found the following Boost libraries:
--   iostreams
--   thread
--   regex
--   chrono
--   system
--   date_time
--   atomic
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/nicolas/Toolboxes/labstreaminglayer/build
cboulay commented 6 years ago

That terminal output is the cmake log which looks fine. I need to see the output from ‘make’ and ‘make install’.

nbara commented 6 years ago

Of course, here are the logs:

make_install_log.txt make_log.txt

cboulay commented 6 years ago

What version of MacOS? What version of Xcode? What version of Qt? What is your system boost version? Did you install Qt and boost using homebrew?

There were some important warnings at the end of your make log about translation units. I'm not sure if your lbilsl build is functional. And your make install log had some errors with the qtdeploytool.

By the way, an .app file is just a folder, you can right click on it and open its contents. You should find an executable in there somewhere and it would be useful to know how big IT is. The whole .app bundle should be much larger after it gets all its dylibs.

nbara commented 6 years ago

Ok, we're making progress.

I've re-run everything again from a fresh clone of the biosemi_cmake branch:

python lslbuild.py
cd build
cmake .. -DLSLApps_BioSemi=ON
make
make install

I now have 2 BioSemi.app :

I've attached the system report of the faulty 54MB app.

Is that the expected behaviour ?

Here is my system info as requested :

$ brew info qt
qt: stable 5.9.2 (bottled), HEAD [keg-only]

$ system_profiler SPDeveloperToolsDataType
Developer:

    Developer Tools:

      Version: 9.1 (9B55)
      Location: /Applications/Xcode.app
      Applications:
          Xcode: 9.1 (13532)

$ system_profiler SPSoftwareDataType
Software:

    System Software Overview:

      System Version: macOS 10.12.6 (16G1036)

And the new logs (attached)

make_install_log.txt make_log.txt Faulty Biosemi app log.txt

cboulay commented 6 years ago

Even though the first one runs, it probably won't actually do anything because it can't load the dylib file. I just realized that my local LSL repo has a DLL folder that isn't sync'd on git. DLL.zip Unpack this in your labstreaminglayer/Apps/BioSemi directory.

You'll have to redo 'make install' at least.

That will get rid of some of your make install errors. The other errors are because it's having trouble fixing up the linking to qt dlls. I have Qt 5.9.1 and its macdeployqt is annoying to deal with, but I managed to find a particular incantation that worked. Maybe it only works on my system?

If you're able, can you try playing around with macdeployqt BioSemi.app with different options to see if you can get it to work for you, then report back?

tstenner commented 6 years ago

I've only had a cursory look, but the drivers on the official download page seem to be based on libusb and ship with the entire source code (which is identical for Linux and OS X). In theory, we could require the user do place the labview_dll.h/.cpp in the folder and build the files as normal source files.

nbara commented 6 years ago

@cboulay Sorry for the delay, I've finally found some time to try out your suggestion, but the app still won't launch.

I'm attaching the logs. There are lots of warning in the make log, and seems to be an error in make install (-- Running Qt Deploy Tool... ERROR: Unexpected prefix "@loader_path")

make_install_log.txt make_log.txt

cboulay commented 6 years ago

@tstenner I am having another look at this today because someone was asking about Biosemi on Mac.

Including the labview files is certainly appealing, but then we are missing bsif_libusb. I guess that's something provided by the manufacturer. I think this is necessary anyway. I just worked through a few problems with the Mac build and eventually got it to tell me the real error: "wrong architecture".

cboulay commented 6 years ago

Ah, that was easy enough. It turns out my DLL folder had a copy of the 32-bit dylib instead of the 64-bit.

@nbara , I've pushed a new attempt at BioSemi support in Mac to the master branch. Please checkout the latest master and give it a try.