ljubobratovicrelja / ffmpeg-d

D port of the FFmpeg C headers
16 stars 9 forks source link

When linking with this depended on, LD fails. #1

Closed zeyonaut closed 8 years ago

zeyonaut commented 8 years ago
ld: unknown option: -pthread
clang: error: linker command failed with exit code 1 (use -v to see invocation)
--- errorlevel 1

That's what happens on my MBA 2013 running OS X 10.11.2. Here's my LD version.

ld -v
@(#)PROGRAM:ld  PROJECT:ld64-253.9
configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS)
LTO support using: Apple LLVM 7.0.2 (clang-700.1.81)

I did some research. Apparently pthread is not supported everywhere. It is hard to find info on. Perhaps that is true for OS X too?

This only happens when depending on ffmpeg-d.

ljubobratovicrelja commented 8 years ago

If you try to compile and link c++ program that uses and links to ffmpeg libraries, does the same happen? Also, was the ffmpeg compiled with clang, or maybe gcc? I don't know if gcc is supported anymore on the OSX, but could you maybe try co compile ffmpeg 2.7.6 with gcc, then try the same?

zeyonaut commented 8 years ago

I can't remember what ffmpeg was compiled with, it was just the configure, make, and make install. With clang, building a c++ project with ffmpeg's libraries linked works as expected. Only d has this problem.

rljubobratovic commented 8 years ago

I'm not really sure what could be the problem here. I would gladly try to solve this, but I'd have to set up a virtual machine to do it, and since I'm short of spare time, I fear It could take me a long time to do it. The only thing I suggest is to try to build ffmpeg with gcc if possible, and then try to link it in D program. Although that is only a guess, since I know really nothing about the DMD for OS X. Anyway, if building it with gcc doesn't cut it, I think we should go on D forums with this. I suppose this problem is strongly related to the OS X platform itself (or maybe clang), so I believe more experienced people could help here. Do you agree?

zeyonaut commented 8 years ago

Sure. I'll compile it one more time and ask somewhere else. Thanks for your help.

ljubobratovicrelja commented 8 years ago

Great! Thank you as well, for bringing this issue up! Could I ask you to leave a notification here about your findings on this issue afterwards? If this problem is, as I suspect, matter of system configuration, and not the library itself, then other people will cross it in future for sure...

zeyonaut commented 8 years ago

Alright, I found an answer. I don't know if this is intended, but I had to run (while building ffmpeg) ./configure --disable-pthreads. That fixed it, at least for now. I'm not sure if it's supposed to run without threads. Furthermore, ./configure --help shows disable pthreads [autodetect] which seems to indicate that it's meant to be detected automatically, which is strange.

I'm not sure if this is the end of it. I'll keep you posted if I find another solution or something else happens. For now, I'll be testing some code first just to make sure things work fine.

ljubobratovicrelja commented 8 years ago

That's great, and thanks for the info! Although, I also feel that this is not a long term fix. But anyways, I hope it works for you for now. Cheers!

zeyonaut commented 8 years ago

Although I couldn't get this to work through installing FFMPEG manually, I could by installing it through Homebrew.

I think this thread should be closed, because it is more of an issue with dmd linking. Perhaps a tip could be left in the README instead.

ljubobratovicrelja commented 8 years ago

Awesome- Thanks, Aaron! Will close the issue as soon as I update the README as you've suggested.

Cheers!

carun commented 6 years ago

Linker issue is visible on Ubuntu 17.10. Apparently this occurs because I didn't build FFmpeg from source, but I use the one that comes with the distro by default. Just had to install the following packages to solve this issue (sudo apt install <package>).

libavcodec-dev
libavformat-dev
libavdevice-dev
libavfilter-dev
libavutil-dev
libswscale-dev