NO

Author Topic: Guide. Build library "Portaudio stable_v19_20140130" in Pelles C 8.00 64bit  (Read 5281 times)

PlezzeR

  • Guest
Hello all!
Sorry for my English!

I don't know, need it to somebody someday or not. But I want to publish my instructions to build "Portaudio stable_v19_20140130" library. In this library available record audio with WASAPI.

Download PortAudio "pa_stable_v19_20140130.tgz" http://www.portaudio.com/download.html

1) Pelles C 8.00 64bit > New project > Win64 Static library (LIB)
Project name: "portaudio".

2) Pelles C compiler option:
2.1) \Ze (Enable Microsoft extensions)
2.2) Runtime library: Multithreaded (LIB)
2.3) Example compiler options: -std:C11 -Tx64-coff -MT -Ot -Ob1 -fp:precise -W1 -Gr -Ze

3) Copy folders "src" and "include" from "portaudio" in archive "pa_stable_v19_20140130.tgz" to project folder.

4) Add source files *.c to project from \src\common; \src\os\win; src\hostapi\wasapi; src\hostapi\wmme

5) Additional Include Directories: \include; \src\common; \src\os\win; src\hostapi\wasapi\mingw-include
5.1) Should be this order:
\include
\src\common
\src\os\win
src\hostapi\wasapi\mingw-include
<Pelles C dir>\Include\Win
<Pelles C dir>\Include

6) Preprocessor Definitions: WIN64 NDEBUG _USRDLL PA_ENABLE_DEBUG_OUTPUT _CRT_SECURE_NO_DEPRECATE PAWIN_USE_WDMKS_DEVICE_INFO PA_WDMKS_NO_KSGUID_LIB PA_USE_ASIO=0 PA_USE_DS=0 PA_USE_WMME=1 PA_USE_WASAPI=1 PA_USE_WDMKS=0

7) Changes in the source files of the library:
7.1) \src\common\pa_debugprint.c
line 77:
Code: [Select]
#if _MSC_VER
#if defined(_MSC_VER)
7.2) \src\common\pa_memorybarrier.h
7.2.1) First way
line 101:
Code: [Select]
#elif (_MSC_VER >= 1400) && !defined(_WIN32_WCE)
#elif (_MSC_VER >= 1100) && !defined(_WIN32_WCE)
Comment lines 103-109 (inclusive)
Add after line 109:
Code: [Select]
#define PaUtil_FullMemoryBarrier() __memory_barrier()
#define PaUtil_ReadMemoryBarrier() __memory_barrier()
#define PaUtil_WriteMemoryBarrier() __memory_barrier()
7.2.2) Other way (not safety !!!)
Comment lines 115-117 (inclusive)
Add after line 117: (not safety !!!)
Code: [Select]
#define PaUtil_FullMemoryBarrier()
#define PaUtil_ReadMemoryBarrier()
#define PaUtil_WriteMemoryBarrier()
7.3) \src\hostapi\wasapi\mingw-include\ksmedia.h
Add after line 823:
Code: [Select]
#ifndef WINBOOL
    #define WINBOOL BOOL
#endif
7.4) \src\hostapi\wasapi\pa_win_wasapi.c
Change 2 lines (3470, 3649) where functions "alloca" to "_alloca"
Change line 52:
Code: [Select]
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
#if defined(_MSC_VER) && (_MSC_VER >= 1100)
Add after line 520:
Code: [Select]
#ifndef __FUNCTION__
    #define __FUNCTION__ __func__
#endif
7.5) \src\hostapi\wmme\pa_win_wmme.c
Change 4 lines (2337, 2387, 3713, 3819) where functions "alloca" to "_alloca"

For create program with "portaudio.lib":
1) Copy folder "include" from "portaudio" in archive "pa_stable_v19_20140130.tgz" to project folder.

2) Add line to your code:
Code: [Select]
#include "include/portaudio.h"
3) Pelles C compiler option:
\Ze (Enable Microsoft extensions)
Runtime library: Multithreaded (LIB)

4) Additional library and object files: ole32.lib winmm.lib pomp64.lib uuid.lib portaudio.lib

Everything checked me. Works.
But there are warnings when compiling the library. But the library functions and the audio recording works.

PortAudio documentation: http://www.portaudio.com/docs.html

And I have a question. How to safely and correctly use the function __memory_barrier() (in 7.2.1 item) ? Thank you all.

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2096
Thanks for the contribution PlezzeR.
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide

Offline bobgardner

  • Member
  • *
  • Posts: 3
I'm an avr c programmer mostly, I can write pelles c console apps, and I'm a live sound engineer. My idea to write a low latency (<100ms) board to wifi multicast using portaudio took a big leap when these portaudio static lib instructions appeared. But of course I'm confused... Has anyone built the portaudio static lib as described above? Have a marked up version you can post? I get the idea if I compile the static lib, then I can link that with any of the portaudio tests and demos.
My pelles c portaudio app will read stereo line in from the board in the sound booth, send it as udp to 239.1.1.1 as stereo 16 bit 44100. There are android apps to listen to multicast audio. as it is being played on stage 100 ft away. No giant PA used after 11pm. So I need a portaudio-pellesc static lib collaborator.

Offline John Z

  • Member
  • *
  • Posts: 790
Hi bobgardner,

So what you are asking is if any forum member has built this recently with Pelles C? 
Have you tried and been unsuccessful for some reason?  What errors have you encountered?

Looks like April 6, 2021 - tag v19.7.0 is the current release.  http://files.portaudio.com/download.html
Have you asked the PostAudio project people they seem to be active with this 2021 release? I would think they are your first choice for questions.

I've downloaded it and will try but no guarantees - busy time of the year you know.

John Z

Offline John Z

  • Member
  • *
  • Posts: 790
I can write pelles c console apps ... Has anyone built the portaudio static lib as described above?

OK I seem to have built it, no errors Level 1, but plenty of warnings.  I have no idea if it works.
I'll zip the PellesC project files and, if small enough, I'll post it here, probably later today.
With that you'll be able to build the lib yourself too.

John Z

Offline John Z

  • Member
  • *
  • Posts: 790
Has anyone built the portaudio static lib as described above? Have a marked up version you can post? I get the idea if I compile the static lib, then I can link that with any of the portaudio tests and demos.

Attached is a PellesC project zip file which does build using most, but not all, of the instructions above plus additional changes and see previous post. I don't know that it actually works but it builds using the most recent portaudio sources with modifications.
You can find mods I made usually by searching for //Z, alternatively compare original sources with the ones in the zip file that have modification date 12-22-2021.

So I need a portaudio-pellesc static lib collaborator.

Having done this as a start for you however, does not mean I'm interested in an ongoing collaboration.  I also hold no responsibility or liability for providing this build - after all they are not my sources.

I do hope it works and helps you, if not it at least gets you started.

Regards,
John Z

Offline bobgardner

  • Member
  • *
  • Posts: 3
Hi John! Thanks for the zip file. I moved the portaudio.lib into my pellesc project dir paex_record, where I have the paex_record.c example and I only got
these errs:POLINK: error: Unresolved external symbol 'alloca' - referenced from 'portaudio.lib(pa_win_wasapi.obj)'.
POLINK: error: Unresolved external symbol 'GUID_NULL' - referenced from 'portaudio.lib(pa_win_wdmks_utils.obj)'.
So this is a lot farther than I got trying to follow the original poster instructions, which I think are for an older version of portaudio. Thanks for the work so far! Happy holidays.
 

Offline John Z

  • Member
  • *
  • Posts: 790
Hi,

So to clarify the 'alloca' error was during the lib build? Or was it during building an executable using the built library?
There should be no errors at all building the library.  It created the lib without issue on my system and with the code I posted, which included fixes for using the current portaudio sources. The built library was in the zip file too.
portaudio.lib 12/22/2021 190KB.

So while I try the build again, please post the particulars of your installed Pelles version, your OS, and if the error manifested during the library build or during building a program using the library.  If during a build of a program using the sample sources they might not be current with the new release of the portaudio lib.  If it is the case of building using the library post the sample source you are using and I'll take a look.  pa_win_wasapi.c was one of the files needing modification.

Thanks,
John Z

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
for alloca use /Go
and for GUID_NULL include lib uuid.lib
May the source be with you

Offline bobgardner

  • Member
  • *
  • Posts: 3
Hi John Z. I'm running win10, pellesc ver 11. I attempted to compile paex_record. Made a new console app, added paex_record.c , put your portaudio.lib in same dir, hit compile. Guess I dont know how to point pellesc to the portaudio include dir. Pellesc is on c:programfiles on an ssd and my dev dir is on d:\bgpellesc\paex_record, so I need to add something to path or something. POLINK: fatal error: File not found: 'd:\pellesc\paex_record.obj'.

Offline John Z

  • Member
  • *
  • Posts: 790
Re: Guide. Build library "Portaudio stable_v19_20140130" in Pelles C 8.00 64bit
« Reply #10 on: December 31, 2021, 01:15:15 PM »
Yes of course Pelles C needs to be able to find the library file.  You can accomplish this in at least one of two ways.
Under Project - Options - Folders : add the path to wherever you have the portaudio library.  OR copy the portaudio library into one of the paths already in use for Pelles C.  The first method is preferred I think.

Secondly you must tell the software to use the library.
Under Project - Options - Linker:  add the library name to the list there.

It does not seem to me from your description of the fatal error that the problem had even gotten to not finding the library.  Your C file did not even create an object file for linking.  Use Pelles  Project - Zip Files and attach to your next posting, I or perhaps someone else will take a look as time permits.

Have you ever had a successful build, perhaps from a Pelles C sample program to verify your install?

John Z