473,320 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

undefined reference error compiling demo program

I get compile error:
undefined reference to snd_pcm_format_width.
I included the library directory with -I flag on gcc.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sched.h>
#include <errno.h>
#include <getopt.h>
#include "../include/asoundlib.h"
#include <sys/time.h>
#include <math.h>

Jun 1 '06 #1
8 3513

vf***@talktalk.net wrote:
I get compile error:
undefined reference to snd_pcm_format_width.
I included the library directory with -I flag on gcc.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sched.h>
#include <errno.h>
#include <getopt.h>
#include "../include/asoundlib.h"
#include <sys/time.h>
#include <math.h>


A few problems you have here:

- there's a lot of non-standard stuff here, so it's off topic
- there's no program here at all, just some `#include`s
- there's a memory (and oil) leak on lines 42, and 57

Jun 1 '06 #2

Vladimir Oka wrote:
vf***@talktalk.net wrote:
I get compile error:
undefined reference to snd_pcm_format_width.
I included the library directory with -I flag on gcc.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sched.h>
#include <errno.h>
#include <getopt.h>
#include "../include/asoundlib.h"
#include <sys/time.h>
#include <math.h>


A few problems you have here:

- there's a lot of non-standard stuff here, so it's off topic
- there's no program here at all, just some `#include`s
- there's a memory (and oil) leak on lines 42, and 57


Sorry, I was a bit sloppy, the "../include/" is different. I only
pasted the header as that is where it looks for its references right ?
Here is the full code upto the error.
/*
* This small demo sends a simple sinusoidal wave to your speakers.
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sched.h>
#include <errno.h>
#include <getopt.h>
#include "../include/asoundlib.h"
#include <sys/time.h>
#include <math.h>

static char *device = "plughw:0,0"; /* playback
device */
static snd_pcm_format_t format = SND_PCM_FORMAT_S16; /* sample
format */
static unsigned int rate = 44100; /* stream rate
*/
static unsigned int channels = 1; /* count of
channels */
static unsigned int buffer_time = 500000; /* ring buffer
length in us */
static unsigned int period_time = 100000; /* period time
in us */
static double freq = 440; /* sinusoidal
wave frequency in Hz */
static int verbose = 0; /* verbose flag */
static int resample = 1; /* enable
alsa-lib resampling */

static snd_pcm_sframes_t buffer_size;
static snd_pcm_sframes_t period_size;
static snd_output_t *output = NULL;

static void generate_sine(const snd_pcm_channel_area_t *areas,
snd_pcm_uframes_t offset,
int count, double *_phase)
{
static double max_phase = 2. * M_PI;
double phase = *_phase;
double step = max_phase*freq/(double)rate;
double res;
unsigned char *samples[channels], *tmp;
int steps[channels];
unsigned int chn, byte;
int ires;
unsigned int maxval = (1 << (snd_pcm_format_width(format) - 1))
- 1;
int bps = snd_pcm_format_width(format) / 8; /* bytes per
sample */

/* verify and prepare the contents of areas */

Jun 1 '06 #3
v...@talktalk.net wrote:
Vladimir Oka wrote:
vf***@talktalk.net wrote:
I get compile error:
undefined reference to snd_pcm_format_width.
I included the library directory with -I flag on gcc.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sched.h>
#include <errno.h>
#include <getopt.h>
#include "../include/asoundlib.h"
#include <sys/time.h>
#include <math.h>


A few problems you have here:

- there's a lot of non-standard stuff here, so it's off topic
- there's no program here at all, just some `#include`s
- there's a memory (and oil) leak on lines 42, and 57


Sorry, I was a bit sloppy, the "../include/" is different. I only
pasted the header as that is where it looks for its references right ?
Here is the full code upto the error.

.... snip code ...

As the error says, none of your code modules contain the identifier
concerned. Why don't you try using nm to dump the symbols in the
library to which your link to?

Jun 1 '06 #4

santosh wrote:

As the error says, none of your code modules contain the identifier
concerned. Why don't you try using nm to dump the symbols in the
library to which your link to?


OK, I used nm on the link directory and it did not recognise the files,
where do I find the files for nm ? It likes to check .o files, right ?

Jun 1 '06 #5
In article <11**********************@f6g2000cwb.googlegroups. com>,
<vf***@talktalk.net> wrote:
santosh wrote:
As the error says, none of your code modules contain the identifier
concerned. Why don't you try using nm to dump the symbols in the
library to which your link to?

OK, I used nm on the link directory and it did not recognise the files,
where do I find the files for nm ? It likes to check .o files, right ?


Wrong newsgroup -- you are asking a Linux-specific question.

<OT warning="The below is unverified">
- nm usually checks libraries as well as .o files.
- http://glide.stanford.edu/lxr/ident?...m_format_width
- http://glide.stanford.edu/lxr/source...?v=linux-2.6.5
</OT>
--
"law -- it's a commodity"
-- Andrew Ryan (The Globe and Mail, 2005/11/26)
Jun 1 '06 #6

Walter Roberson wrote:
Wrong newsgroup -- you are asking a Linux-specific question.


phhu, there is no comp.lang.c.linux group, nothing matching that with
much activity at least not that i found quickly.

Jun 1 '06 #7

v...@talktalk.net wrote:
Walter Roberson wrote:
Wrong newsgroup -- you are asking a Linux-specific question.


phhu, there is no comp.lang.c.linux group, nothing matching that with
much activity at least not that i found quickly.


OK, I did find a linux dev group.

Jun 1 '06 #8
On 1 Jun 2006 10:53:21 -0700, vf***@talktalk.net wrote:

Vladimir Oka wrote:
vf***@talktalk.net wrote:
> I get compile error:
> undefined reference to snd_pcm_format_width.
> I included the library directory with -I flag on gcc.
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> #include <sched.h>
> #include <errno.h>
> #include <getopt.h>
> #include "../include/asoundlib.h"
> #include <sys/time.h>
> #include <math.h>


A few problems you have here:

- there's a lot of non-standard stuff here, so it's off topic
- there's no program here at all, just some `#include`s
- there's a memory (and oil) leak on lines 42, and 57


Sorry, I was a bit sloppy, the "../include/" is different. I only
pasted the header as that is where it looks for its references right ?
Here is the full code upto the error.

No. The undefined reference error is a linker error. Headers are
used by the compiler, not the linker.

On many common systems, references are resolved by searching
libraries. Libraries and headers are completely different.
Remove del for email
Jun 2 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: ferdous | last post by:
Hi Greetings to all I am new to ProC. I am compiling a very simple program written in ProC. I can compile the program using proc filename.pc and it generates the corresponding c code :) , but...
1
by: Foolster41 | last post by:
I'm rather new to C++ programing. I'm using the dev-C++ program on a windows XP OS. I'm trying to compile the code for a multi user dungeon (MUD) called circle-mud. When I compile I get the...
7
by: Richard Hayden | last post by:
Hi, I've just upgraded my gcc and I'm currently trying to compile some code for my own operating system kernel, but I am getting an error of "Undefined reference to `memcpy`" when I try to link...
4
by: Albert Oppenheimer | last post by:
I have a small program, test.c. It runs OK. This is on Linux (kernel 2.6.8.1, GCC 3.4.1). I decided to convert it to C++ before expanding it to a larger program. I changed the filename to...
45
by: VK | last post by:
(see the post by ASM in the original thread; can be seen at <http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/3716384d8bfa1b0b> as an option) As that is not in relevance to...
5
by: druberego | last post by:
I read google and tried to find the solution myself. YES I do know that you can get undefined references if you: a) forget to implement the code for a prototype/header file item, or b) you forget...
8
by: wdh3rd | last post by:
I'm still new at C and can't solve this problem. I've looked through the FAQ and on the Web, but am not having luck. I'm getting an "undefined reference" error as well as a "Id returned 1 exit...
16
by: Micko1 | last post by:
Hello there :) I have been using Visual Studio on a program which I have just completed, however I need to have it compiling using a unix based compiler, when I try in cygwin, I get the following...
13
by: ptn | last post by:
Hi everyone, I was messing around with math.h and I got this error: """ /tmp/ccefZYYN.o: In function `digcount': itos.c:(.text+0x103): undefined reference to `log10' itos.c:(.text+0x111):...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.