Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- sudo apt-get install libasound-dev
- g++ -I/usr/include/alsa -lasound main.cpp -o radio
- */
- #include <cstdio>
- #include <alsa/asoundlib.h>
- int
- main(int inArgC, const char** inArgs)
- {
- std::printf("Hello world\n");
- snd_pcm_t* pcm = NULL;
- char* pcmName = ::strdup("plughw:0,0");
- snd_pcm_stream_t stream = SND_PCM_STREAM_PLAYBACK;
- int result = snd_pcm_open(&pcm, pcmName, stream, 0);
- if (result < 0)
- {
- std::fprintf(stderr, "Error opening PCM device %s: %d\n", pcmName, result);
- return -1;
- }
- return 0;
- }
- -----------
- $ g++ -lasound main.cpp -o radio
- /tmp/cckzNJjH.o: In function `main':
- main.cpp:(.text+0x4a): undefined reference to `snd_pcm_open'
- collect2: error: ld returned 1 exit status
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement