Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6117439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:19:15+00:00 2026-05-23T15:19:15+00:00

i am trying to compile this code, but if i do using: gcc prt.c

  • 0

i am trying to compile this code, but if i do using:

gcc prt.c portaudio.h -o prt

but i get this error:

main.c:47: undefined reference to `Pa_OpenDefaultStream'
main.c:62: undefined reference to `Pa_StartStream'
main.c:65: undefined reference to `Pa_Sleep'
main.c:66: undefined reference to `Pa_StopStream'
main.c:69: undefined reference to `Pa_CloseStream'
main.c:72: undefined reference to `Pa_Terminate'
main.c:78: undefined reference to `Pa_Terminate'

i don’t know why, then i though it might be beacuse i don’t have a rule (make file)
so i made one:

main: main.o
    gcc main.o -o main

main.o: main.c portaudio.h
    gcc -c main.c

but when i try to run it through cygwin: using “Make”
i get this message:

"make: *** No targets specified and no makefile found. Stop.

I don’t understand the problem, please help me is something wrong with my makefile or is there something else wrong.

also this is the code:
main.c

#include <stdio.h>
#include "portaudio.h"

#define SAMPLE_RATE (44100)


typedef struct
{
   float left_phase;
   float right_phase;
}
paTestData;

static int patestCallback( const void *inputBuffer, void *outputBuffer,
                       unsigned long framesPerBuffer,
                       const PaStreamCallbackTimeInfo* timeInfo,
                       PaStreamCallbackFlags statusFlags,
                       void *userData )
{
/* Cast data passed through stream to our structure. */
paTestData *data = (paTestData*)userData;
float *out = (float*)outputBuffer;
unsigned int i;
(void) inputBuffer; /* Prevent unused variable warning. */

for( i=0; i<framesPerBuffer; i++ )
{
    *out++ = data->left_phase;  /* left */
    *out++ = data->right_phase;  /* right */
    /* Generate simple sawtooth phaser that ranges between -1.0 and 1.0. */
    data->left_phase += 0.01f;
    /* When signal reaches top, drop back down. */
    if( data->left_phase >= 1.0f ) data->left_phase -= 2.0f;
    /* higher pitch so we can distinguish left and right. */
    data->right_phase += 0.03f;
    if( data->right_phase >= 1.0f ) data->right_phase -= 2.0f;
}
return 0;
}


static paTestData data;

int main (void) {
PaStream *stream;
PaError err;
err = Pa_OpenDefaultStream( &stream,
                            0,          /* no input channels */
                            2,          /* stereo output */
                            paFloat32,  /* 32 bit floating point output */
                            SAMPLE_RATE,
                            256,        /* frames per buffer, i.e. the number
                                               of sample frames that PortAudio will
                                               request from the callback. Many apps
                                               may want to use
                                               paFramesPerBufferUnspecified, which
                                               tells PortAudio to pick the best,
                                               possibly changing, buffer size.*/
                            patestCallback, /* this is your callback function */
                            &data ); /*This is a pointer that will be passed to
                                               your callback*/
                         err = Pa_StartStream( stream );
                         if( err != paNoError ) goto error;

                         Pa_Sleep(9*1000);
                        err = Pa_StopStream( stream );
                        if( err != paNoError ) goto error;

                        err = Pa_CloseStream( stream );
                        if( err != paNoError ) goto error;

                        err = Pa_Terminate( );
                        if( err != paNoError ) goto error;

                        printf("Test finished.\n");
                        return err;
                    error:
                        Pa_Terminate();

                        return err;




   }

and the header file portaudio.h: Portaudio.h
if you want cleaner view of main.c: main.c

I am not so sure why these messages/errors/warning are coming, please help.

also this is my folder view:
enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:19:15+00:00Added an answer on May 23, 2026 at 3:19 pm

    You seem to be using functions from a library for the ‘Port Audio’ facility, but your link line does not tell the C compiler how to find that library – so the functions show up as undefined references.

    Your link line should look something like:

    gcc -o main main.o -lpa
    

    That should be macroized, but the gist is correct.

    This assumes the library is in ‘libpa.a’ or thereabouts. If it is in ‘libportaudio.so’, then use -lportaudio instead of -lpa.

    Using macros in the makefile:

    PROGRAM = main
    SOURCE  = main.c
    OBJECT  = $(SOURCE:.c=.o)
    LIBDIR  = /cygdrive/c/installdir/portaudio/lib
    LIBRARY = $(LIBDIR)/portaudio_x86.lib
    
    $(PROGRAM): $(OBJECT)
        $(CC) $(CFLAGS) -o $@ $(OBJECT) $(LDFLAGS) $(LIBRARY)
    
    
    main.o: main.c portaudio.h
    

    You should not need an explicit compilation command for main.o; make should be able to deduce that from its internal rules. Note that the character before $(CC) must be a TAB and not spaces.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hI, I'm trying to get this code from Larry Nyhoff's book to compile in
I am trying to compile the following code on Linux using gcc 4.2: #include
I'm trying to compile an old project using VS express 2010 but I get
I've got yet another error trying to compile with Apple GCC 4.2.1 using the
i am trying to compile this very simple piece of code class myList {
I'm trying to compile a POCO with this code public class MenuItem { public
When trying to compile my class I get an error: The constant 'NamespaceName.ClassName.CONST_NAME' cannot
I've been trying to get this code to work for hours! All I need
recently I downloaded this open source project and I am trying to compile it.
I have a C++ driver I'm trying to compile, and it has this line

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.