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

macOS build failed, due to didn't link to ffmpeg installed by homebrew #38

Open
tommyZZM opened this issue Mar 20, 2020 · 1 comment
Open

Comments

@tommyZZM
Copy link

tommyZZM commented Mar 20, 2020

os: macOS 10.15.3

error message

CXX(target) Release/obj.target/beamcoder/src/beamcoder.o
In file included from ../src/beamcoder.cc:23:
../src/beamcoder_util.h:33:12: fatal error: 'libavutil/error.h' file not found
  #include <libavutil/error.h>
           ^~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [Release/obj.target/beamcoder/src/beamcoder.o] Error 1
gyp ERR! build error 

or

ld: library not found for -lavcodec
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Release/beamcoder.node] Error 1
gyp ERR! build error 

after adding include_dirs and library_dirs for 'OS=="mac" to the binding.gyp.

I can build succcess.

{
  "targets": [{
    "target_name" : "beamcoder",
    "sources" : [ "src/beamcoder.cc", "src/beamcoder_util.cc",
                  "src/governor.cc", "src/demux.cc",
                  "src/decode.cc", "src/filter.cc",
                  "src/encode.cc", "src/mux.cc",
                  "src/packet.cc", "src/frame.cc",
                  "src/codec_par.cc", "src/format.cc",
                  "src/codec.cc" ],
    "conditions": [
+      ['OS=="mac"', {
+        "include_dirs" : [
+          "/usr/local/Cellar/ffmpeg/4.2.2/include"
+        ],
+        "library_dirs": [
+          "/usr/local/Cellar/ffmpeg/4.2.2/lib",
+        ]
+      }],
      ['OS!="win"', {
        "defines": [
          "__STDC_CONSTANT_MACROS"
        ],
        "cflags_cc!": [
          "-fno-rtti",
          "-fno-exceptions"
        ],
        "cflags_cc": [
          "-std=c++11",
          "-fexceptions"
        ],
        "link_settings": {
          "libraries": [
            "-lavcodec",
            "-lavdevice",
            "-lavfilter",
            "-lavformat",
            "-lavutil",
            "-lpostproc",
            "-lswresample",
            "-lswscale"
          ]
        }
      }],
      ['OS=="win"', {
        "configurations": {
          "Release": {
            "msvs_settings": {
              "VCCLCompilerTool": {
                "RuntimeTypeInfo": "true"
              }
            }
          }
        },
        "include_dirs" : [
          "ffmpeg/ffmpeg-4.2.1-win64-dev/include"
        ],
        "libraries": [
          "-l../ffmpeg/ffmpeg-4.2.1-win64-dev/lib/avcodec",
          "-l../ffmpeg/ffmpeg-4.2.1-win64-dev/lib/avdevice",
          "-l../ffmpeg/ffmpeg-4.2.1-win64-dev/lib/avfilter",
          "-l../ffmpeg/ffmpeg-4.2.1-win64-dev/lib/avformat",
          "-l../ffmpeg/ffmpeg-4.2.1-win64-dev/lib/avutil",
          "-l../ffmpeg/ffmpeg-4.2.1-win64-dev/lib/postproc",
          "-l../ffmpeg/ffmpeg-4.2.1-win64-dev/lib/swresample",
          "-l../ffmpeg/ffmpeg-4.2.1-win64-dev/lib/swscale"
        ],
        "copies": [
            {
              "destination": "build/Release/",
              "files": [
                "ffmpeg/ffmpeg-4.2.1-win64-shared/bin/avcodec-58.dll",
                "ffmpeg/ffmpeg-4.2.1-win64-shared/bin/avdevice-58.dll",
                "ffmpeg/ffmpeg-4.2.1-win64-shared/bin/avfilter-7.dll",
                "ffmpeg/ffmpeg-4.2.1-win64-shared/bin/avformat-58.dll",
                "ffmpeg/ffmpeg-4.2.1-win64-shared/bin/avutil-56.dll",
                "ffmpeg/ffmpeg-4.2.1-win64-shared/bin/postproc-55.dll",
                "ffmpeg/ffmpeg-4.2.1-win64-shared/bin/swresample-3.dll",
                "ffmpeg/ffmpeg-4.2.1-win64-shared/bin/swscale-5.dll"
              ]
            }
          ]
    }]
  ]
}]
}

Same issue may also happen in Linux. #21 Add include dirs on linux

tommyZZM added a commit to tommyZZM/beamcoder that referenced this issue Mar 20, 2020
tommyZZM added a commit to tommyZZM/beamcoder that referenced this issue Mar 20, 2020
@WingDust
Copy link

windows rebuild with electron has

  ⠼ Building module: beamcoder, Completed: 0
h:\electronproject\electron_vue\electron-vue-vite\node_modules\beamcoder\src\beamcoder_util.h(33): fatal error C1083: Cannot open include file: 'libavutil/error.h': 

No such file or directory [H:\ElectronProject\Electron_Vue\electron-vue-vite\node_modules\beamcoder\build\beamcoder.vcxproj]

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

Successfully merging a pull request may close this issue.

2 participants