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

Option to disable pkg-config #444

Open
pszturmaj opened this issue Oct 20, 2014 · 7 comments
Open

Option to disable pkg-config #444

pszturmaj opened this issue Oct 20, 2014 · 7 comments

Comments

@pszturmaj
Copy link
Contributor

I had problem with manually built ffmpeg libs and pkg-config on Ubuntu 14.04. The problem with ffmpeg's pkg-config was that it appended "-pthread" to libs arguments and dmd/gdc was always returning with /usr/bin/ld error "unrecognized option -pthread".

This option may be passed to gcc when compiling sources. Unfortunately, when gcc is used as a linker (without specifying any sources, as dub/dmd does in linking stage) it passes all params to gnu LD. LD linker does not support "-phtread" option (instead one must use "-lpthread"). I also tried with gold linker, but the error was exactly the same.

Please consider adding an option to disable pkg-config's library resolution. Personally, I'm fine with setting "libs" manually. Another option may be skipping "-pthread" parameter when passing pkg-config --libs to the linker.

@pszturmaj
Copy link
Contributor Author

The same problem with libupnp. This is libupnp's .pc file:

prefix=/usr/local
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: libupnp
Description: Linux SDK for UPnP Devices
Version: 1.6.19
Libs: -pthread  -L${libdir} -lupnp -lthreadutil -lixml 
Cflags: -pthread -I${includedir}/upnp

As you can see, there's -pthread option which dub is passing to the linker. Example dub output:

Package vibe-d can be upgraded from 0.7.21-rc.3 to 0.7.21-rc.4.
Use "dub upgrade" to perform those changes.
Target vibe-d 0.7.21-rc.3 is up to date. Use --force to rebuild.
Building my_project ~master configuration "application", build type debug.
Compiling using dmd...
Linking...
/usr/bin/ld: unrecognized option '-pthread'
/usr/bin/ld: use the --help option for usage information
collect2: error: ld returned 1 exit status
--- errorlevel 1
FAIL .dub/build/application-debug-linux.posix-x86_64-dmd_2066-228CE7DAF81A2A2003D524DC9FA074EC/ my_project executable
Error executing command build: dmd failed with exit code 1.

@ximion
Copy link
Contributor

ximion commented Mar 3, 2016

I can confirm this issue, it's quite annoying...

@s-ludwig
Copy link
Member

s-ludwig commented Mar 4, 2016

For the time being, you could use the "dflags" or "lflags" fields to specify the necessary libraries manually. Not sure how to best approach this, since pkg-config generally outputs in GCC format, but DMD AFAIK doesn't allow to pass flags to the GCC linker command line verbatim. So the only real option seems to be to recognize the -pthread switch and remove it, since DMD already links against libpthread.

@jeanbaptistelab
Copy link
Contributor

@s-ludwig do you want me to update #783 to transform occurrences of -pthread in the output of pkg-config --libs to -lpthread as well ?

@s-ludwig
Copy link
Member

If you have the necessary time, then that would be great.

@jeanbaptistelab
Copy link
Contributor

@s-ludwig I've now added "-pthread" option handling in my fork, #783 should now include this change as well.

@Geod24
Copy link
Member

Geod24 commented Dec 20, 2019

There is now an option in DMD to pass arguments directly to CC: dlang/dmd#10441

Unfortunately it still requires handling directly from dub AFAICS, but it sounds a much better option than disabling pkg-config.

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

No branches or pull requests

5 participants