On Thu, Jun 06, 2019 at 02:07:46PM +0200, Bram Moolenaar wrote:
> I tried a little example:
>
>
> #include <unistd.h>
> #include <canberra.h>
> int main () {
> ca_context * hello;
> ca_context_create (&hello);
> ca_context_play (hello, 0,
> CA_PROP_EVENT_ID, "phone-incoming-call",
> CA_PROP_EVENT_DESCRIPTION, "hello world",
> NULL);
> sleep(2);
> return 0;
> }
>
> gcc -o sound -D_REENTRANT -lcanberra sound.c
> /usr/bin/ld: /tmp/ccArSjRM.o: in function `main':
> sound.c:(.text+0x1f): undefined reference to `ca_context_create'
> /usr/bin/ld: sound.c:(.text+0x57): undefined reference to `ca_context_play'
> collect2: error: ld returned 1 exit status
>
> Somehow linking doesn't work, must be missing something...This works: gcc -o sound -D_REENTRANT sound.c -lcanberra (At some point back in 2011 Ubuntu changed the linker defaults to use --as-needed, which means the linker tries to drop unneeded libraries if it doesn't see any object files using symbols from that library before it encounters the name of the library. I don't really understand this; but it caused everyone's build scripts to fail at the time, and the fix was to move all the libraries to the end of the compiler command line. It's documented in https://wiki.ubuntu.com/NattyNarwhal/ToolchainTransition#Indirect_Linking_for_Shared_Libraries but I don't understand a word on that page. I hope it's the right page.) Marius Gedminas -- Perl is hard for most people to write. They write PERL or Pearl. -- Abigail -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/20190606170546.b6y6ajnlocplfnsj%40platonas. For more options, visit https://groups.google.com/d/optout.
signature.asc
Description: PGP signature
