473,786 Members | 2,445 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3547

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(c onst 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.n et 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************ **********@f6g2 000cwb.googlegr oups.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.lin ux group, nothing matching that with
much activity at least not that i found quickly.

Jun 1 '06 #7

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


phhu, there is no comp.lang.c.lin ux 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
40623
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 when i try to compile the C program using cc -O3 -DPRECOMP -I. -I/opt/oracle/products/9.2.0/rdbms/public -I/opt/oracle/products/9.2.0/precomp/public -I/opt/oracle/products/9.2.0/rdbms/demo
1
9613
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 following errors: ---- Compiler: Default compiler Building Makefile: "C:\EvoMud\circle-3.1\src\Makefile.win" Executing make...
7
12099
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 it using the GNU linker. I do not reference the symbol memcpy explicitly anywhere in the offending function. I have narrowed the offending code down to the initialisation of an array of pointers to char (i.e. an array of strings), which is given...
4
75444
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 test.cpp and added extern "C" { } around main and all the non-static subroutines. It compiles OK, but when I
45
4863
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 "new Array() vs " question or to the array performance, I dared to move it to a new thread. Gecko takes undefined value strictly as per Book 4, Chapter 3, Song 9 of Books of ECMA :-)
5
11361
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 to pass all the necessary object files to the linker. Neither of those are my problem. Please bear with me as the question I ask is rather long and I think it's beyond a CS101 level of linker stupidity. If it is a stupid CS101 mistake I'm making...
8
5627
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 status" error. I've pared down the code to a simple example: ---------------------------------square.c ---------------------------------------------------
16
43731
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 error: undefined reference to `_WinMain@16' I have tried searching for a workaround, although I am not a programming guru, and I find it difficult to comprehend the discussions on this topic :) Any help is appreciated.
13
537
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): undefined reference to `ceil' collect2: ld returned 1 exit status
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9492
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10163
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10108
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9960
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3668
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.