Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libVLC instructions on Mac OS #13

Open
adrg opened this issue Oct 3, 2018 · 12 comments
Open

libVLC instructions on Mac OS #13

adrg opened this issue Oct 3, 2018 · 12 comments

Comments

@adrg
Copy link
Owner

adrg commented Oct 3, 2018

Installation instructions on Debian based distributions are covered in the README file.
Can someone provide installation instructions for the prerequisites of the library on Windows and Mac OS?
I can then add the information to the README or create a wiki about this in order to help new users.

@sc0Vu
Copy link

sc0Vu commented Jan 22, 2019

Hi @adrg
I tried many times on mac but it didn't work. Here was what I'd done on my mac pro:

  1. Download and compile vlc.
  2. Add build.go file to libvlc-go, and set the CFLAGS and LDFLAGS
  3. Put library and dynamic files of libvlc in directory.

Got this error: unknown image for @rpath/...

Right now I use vlc stream server instead, still try to find the root cause.

@adrg
Copy link
Owner Author

adrg commented Jan 22, 2019

Hi @sc0Vu. Thank you for taking an interest in the library.

I see there are some instructions on the vlc wiki here: https://wiki.videolan.org/OSXCompile.
Unfortunately I have no way of testing this as I don't have Mac OS machines.

@adrg adrg changed the title Installation instructions on Windows and Mac OS Installation instructions for Mac OS Mar 11, 2020
@adrg adrg changed the title Installation instructions for Mac OS Installation instructions on Mac OS Mar 11, 2020
@adrg adrg changed the title Installation instructions on Mac OS libVLC instructions on Mac OS Mar 11, 2020
@gaurav-gogia
Copy link

Hi @sc0Vu, I had similar error so something like this should work:

Make sure MacOSX.sdk exists by using following command
ls SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk

If its there then cool go for next command
export SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk

If its not there then you'll need to install xcode-command-line-tools

I hope this helps

@adrg
Copy link
Owner Author

adrg commented Jun 10, 2020

Thank you @gaurav-gogia. Ideally, there would be a wiki page similar to Install on Linux and Install on Windows with specific instructions for the whole installation process.

@ansoni-san
Copy link

The compilation instruction for VLC work fine for OSX including 11.1 (Big Sur). I also have it working fine for the M1 ARM architecture.

After following: https://wiki.videolan.org/MacOSCompile/

You'll have to set LIBRARY_PATH to the lib folder belonging to your compiled VLC, otherwise go get won't be able to link correctly.

export LIBRARY_PATH=<BUILD-DIR>/vlc_install_dir/lib

This was all I had to do.

@adrg
Copy link
Owner Author

adrg commented Dec 28, 2020

@ansoni-san Awesome. Thank you for testing the library on macOS. That should be enough information for me to create an installation wiki page.

I noticed there's a NuGet package for macOS which provides an already built version of libVLC. Can that be used as an alternative to building the library yourself? The package is just a zip file so it can be opened with any archive manager.

@adrg
Copy link
Owner Author

adrg commented Dec 28, 2020

I added a Install on macOS wiki page based on the information you provided. Please let me know if that looks ok.

@zlatko5
Copy link

zlatko5 commented Oct 20, 2021

I do not understand "vlc_install_dir" part in following command
export LIBRARY_PATH=BUILD-DIR/vlc_install_dir/lib
Following instructions in https://wiki.videolan.org/MacOSCompile/, I have used directory ~/vlc. The build command has created directory ~/vlc/build/lib/ and there is file libvlc.la in there (and number of .lo files).

Linker gives me error: Undefined symbols for architecture x86_64: _libvlc_media_player_play and others.

I have one of following problems:
(1) ~/vlc/build/lib/ is wrong directory to specify for link
(2) directory is correct but library needed has not been built
(3) directory and library (libvlc.la) are correct name but are for wrong architecture
How do I determine which problem do I have?

@adrg
Copy link
Owner Author

adrg commented Oct 21, 2021

I updated the Install on macOS wiki page with instructions on how to install libVLC through MacPorts. I find it to be a bit easier than building VLC from source.

@zlatko5 Can you try setting up your libVLC development environment this way?

@zlatko5
Copy link

zlatko5 commented Oct 22, 2021

Thank you, libVLC through MacPorts works fine.

@nkalait
Copy link

nkalait commented May 5, 2024

I had raised a new issue before I saw this one, I have a problem running the example code on Mac so I found a workaround(#113) . I am no good with c or the c compiler but I somehow think that there could be a better solution than my workaround.

@GwynethLlewelyn
Copy link

Hmm. I think that Mac users are doing twice the work they need to get this working :)

For v3.1.6, basically, you just need two things:

  1. Install VLC for macOS. It's irrelevant where you get it from, MacPorts, Homebrew, directly from the website, from the Apple store, all of that is irrelevant.
  2. Compile your application (that uses the libvlc-go package) with
CGO_CFLAGS="-I/Applications/VLC.app/Contents/MacOS/include" CGO_LDFLAGS="-L/Applications/VLC.app/Contents/MacOS/lib" go build

The above command assumes that VLC was installed under /Applications/VLC.app, of course. Adapt if needed (it might be under /Applications/MacPorts/VLC.app if installed via MacPorts, or under ~/Applications/VLC.app if installed for the local user only).

This instructs the cgo subsystem to locate the VLC include header files & libraries on non-standard locations.

See #116 for a more complete explanation.

Pros: should work out of the box on most environments out there, not only macOS, so long as you know where the VLC header files & libraries are.

Cons: Every time libvlc-go gets updated and/or your own app/pkg using this library, you must remember to add these extra environment variables to the command line, or you'll get all sorts of errors. Note that even if you have CFLAGS and LDFLAGS correctly exported from your environment (assuming you use the VLC C libraries elsewhere, not just under Go), the cgo subsystem will pretty much ignore those (unless it's forced to read from them, as per the reference manual).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants