I'm trying to use PortAudio for audio recording through a microphone. But I get a bunch of errors -
Compiling single file...
--------
- Filename: C:\Users\Gumm\Downloads\pa_stable_v190600_20161030\portaudio\examples\paex_record.c
- Compiler Name: TDM-GCC 4.9.2 64-bit Debug
Processing C source file...
--------
- C Compiler: C:\Program Files (x86)\Dev-Cpp\MinGW64\bin\gcc.exe
- Command: gcc.exe "C:\Users\Gumm\Downloads\pa_stable_v190600_20161030\portaudio\examples\paex_record.c" -o "C:\Users\Gumm\Downloads\pa_stable_v190600_20161030\portaudio\examples\paex_record.exe" -g3 -I"C:\Program Files (x86)\Dev-Cpp\MinGW64\include" -I"C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\include" -I"C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include" -L"C:\Program Files (x86)\Dev-Cpp\MinGW64\lib" -L"C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\lib" -L"C:\Users\Gumm\Downloads\pa_stable_v190600_20161030\portaudio\examples" -g3
C:\Users\Gumm\AppData\Local\Temp\ccih6neG.o: In function `main':
C:/Users/Gumm/Downloads/pa_stable_v190600_20161030/portaudio/examples/paex_record.c:224: undefined reference to `Pa_Initialize'
C:/Users/Gumm/Downloads/pa_stable_v190600_20161030/portaudio/examples/paex_record.c:227: undefined reference to `Pa_GetDefaultInputDevice'
C:/Users/Gumm/Downloads/pa_stable_v190600_20161030/portaudio/examples/paex_record.c:234: undefined reference to `Pa_GetDeviceInfo'
C:/Users/Gumm/Downloads/pa_stable_v190600_20161030/portaudio/examples/paex_record.c:238: undefined reference to `Pa_OpenStream'
C:/Users/Gumm/Downloads/pa_stable_v190600_20161030/portaudio/examples/paex_record.c:249: undefined reference to `Pa_StartStream'
C:/Users/Gumm/Downloads/pa_stable_v190600_20161030/portaudio/examples/paex_record.c:255: undefined reference to `Pa_Sleep'
C:/Users/Gumm/Downloads/pa_stable_v190600_20161030/portaudio/examples/paex_record.c:253: undefined reference to `Pa_IsStreamActive'
C:/Users/Gumm/Downloads/pa_stable_v190600_20161030/portaudio/examples/paex_record.c:260: undefined reference to `Pa_CloseStream'
C:/Users/Gumm/Downloads/pa_stable_v190600_20161030/portaudio/examples/paex_record.c:303: undefined reference to `Pa_GetDefaultOutputDevice'
C:/Users/Gumm/Downloads/pa_stable_v190600_20161030/portaudio/examples/paex_record.c:310: undefined reference to `Pa_GetDeviceInfo'
C:/Users/Gumm/Downloads/pa_stable_v190600_20161030/portaudio/examples/paex_record.c:314: undefined reference to `Pa_OpenStream'
C:/Users/Gumm/Downloads/pa_stable_v190600_20161030/portaudio/examples/paex_record.c:327: undefined reference to `Pa_StartStream'
C:/Users/Gumm/Downloads/pa_stable_v190600_20161030/portaudio/examples/paex_record.c:332: undefined reference to `Pa_Sleep'
C:/Users/Gumm/Downloads/pa_stable_v190600_20161030/portaudio/examples/paex_record.c:332: undefined reference to `Pa_IsStreamActive'
C:/Users/Gumm/Downloads/pa_stable_v190600_20161030/portaudio/examples/paex_record.c:335: undefined reference to `Pa_CloseStream'
C:/Users/Gumm/Downloads/pa_stable_v190600_20161030/portaudio/examples/paex_record.c:342: undefined reference to `Pa_Terminate'
C:/Users/Gumm/Downloads/pa_stable_v190600_20161030/portaudio/examples/paex_record.c:349: undefined reference to `Pa_GetErrorText'
collect2.exe: error: ld returned 1 exit status
Compilation results...
--------
- Errors: 1
- Warnings: 0
- Compilation Time: 0.53s
I know this is a linker error but I am unable to find any .lib file from my download of portaudio. How do I resolve this issue?
< /Hey >
It looks like you are trying to build one of the port audio examples, without first building and/or linking the portaudio library!
Building portaudio for windows
Since your on Windows, there's two main ways to build portaudio (official docs reference):
With Visual Studio (VS) : The portaudio download provides a VS project that you have to change a few minor things before it should (hopefully) compile.
With MinGW : A command line version of building portaudio on windows. You will need to install MinGW if you haven't already, but I think this method is much easier than my attempts with Visual Studio in the past.
Either technique you use will generate a static .lib file, which you can then be used to link to your project (i.e. the source file you are trying to compile).
Linking portaudio
Visual Studio
So since your on Windows, I would recommend doing this in Visual Studio (create a empty c++ command line program, and add the paex_record.c file ) if you want to have a setup project ready to go. Below is a quick way to setup a static lib in VS.
Reference the library header (portaudio.h) in Project
Properties->C/C++->General->Additional Include Directories
Reference the .lib (portaudio.lib) in Project Properties->Linker->Input
More info on creating and using static libs.
MinGW
It's actually much simpler with MinGW in my opinion but if you aren't used to working in the command line you might not prefer it.
Assuming you have your project directory with three files (for simplicity):
Project Folder
|paex_record.c
|portaudio.lib
|portaudio.h
Then the compile command (source) is:
cd /Project/Directory
gcc paex_record.c -lportaudio
Related
I have installed the GMP library and try to cross-compile with mingw-w64-posix.
My Library is in /usr/local/lib.
My compile command looks like the following:
x86_64-w64-mingw32-g++-posix src/factorial.cpp -o bin/factorial.win.o -I/usr/local/include -L/usr/local/lib -lgmp -lgmpxx
It throws an undefined reference error:
(I can remove the whole block from -L...., same error. Seems like the library doesnt link for some reason)
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccxY03WS.o:factorial.cpp:(.text$_ZN23__gmp_binary_multiplies4evalEP12__mpz_structPKS0_S3_[_ZN23__gmp_binary_multiplies4evalEP12__mpz_structPKS0_S3_]+0x27): undefined reference to `__gmpz_mul'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccxY03WS.o:factorial.cpp:(.text$_ZN23__gmp_binary_multiplies4evalEP12__mpz_structPKS0_l[_ZN23__gmp_binary_multiplies4evalEP12__mpz_structPKS0_l]+0x26): undefined reference to `__gmpz_mul_si'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccxY03WS.o:factorial.cpp:(.text$_ZN10__gmp_exprIA1_12__mpz_structS1_E7init_siEl[_ZN10__gmp_exprIA1_12__mpz_structS1_E7init_siEl]+0x1a): undefined reference to `__gmpz_init_set_si'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccxY03WS.o:factorial.cpp:(.text$_ZN10__gmp_exprIA1_12__mpz_structS1_EC1EOS2_[_ZN10__gmp_exprIA1_12__mpz_structS1_EC1EOS2_]+0x2e): undefined reference to `__gmpz_init'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccxY03WS.o:factorial.cpp:(.text$_ZN10__gmp_exprIA1_12__mpz_structS1_ED1Ev[_ZN10__gmp_exprIA1_12__mpz_structS1_ED1Ev]+0x14): undefined reference to `__gmpz_clear'
collect2: error: ld returned 1 exit status
However if i change my compiler to g++ instead everything works fine.
OK -
The link errors (__gmpz_init, __gmpz_clear, etc.) are GMP "internals". They're supposed to come from libgmp, the C-language base library.
The code that's referencing them (.text$ZN23__gmp_binary_multiplies4evalEP12__mpz_structPKS0_S3[ZN23__gmp_binary_multiplies4evalEP12__mpz_structPKS0_S3], etc.) is "name mangled" C++.
I suspect the problem is that your "gmpxx" library was built with a different C++ compiler, that has a different "name mangling" convention than MinGW.
SOLUTION:
Download the complete libGMP source (e.g. from https://gmplib.org/, and rebuild EVERYTHING (including libgmpxx) with your libmingw-w64-posix++ C++ cross-compiler.
ADDENDUM:
I downloaded gmp-6.2.1 source, and found __gmpz_clear here:
gmp-6.2.1\gmp-h.in
#define mpz_clear __gmpz_clear
__GMP_DECLSPEC void mpz_clear (mpz_ptr);
"gmp-h.in" is a template used by the project's "autoconf", to generate the libGMP source files for the specified target environment.
Which, in turn, means:
The project you started out with (in your original question) wasn't configured for MinGW
... and ...
You didn't run "configure" correctly when you tried building from source.
SUGGESTION:
Try building libGMP from source again. DELETE everything, re-extract from the libGMP tarball, and carefully follow the INSTALL instructions:
./configure
make
make check <= VERY IMPORTANT!!
make install
I'm curious about your build environment (Windows? Linux?), compiler (exact MinGW version) and target (if you're building on a Windows workstation, do you want to run your GMP app as a Windows .exe)?
I am trying to install the FreeImage library in C++ using Dev-Cpp on Windows 10, i put the .h files in the corresponding folder and i added the directories in Dev-cpp, the .DLL file i put it in the folder: C:\Program Files (x86)\Dev-Cpp\MinGW64\bin that it's where i have installed Dev-Cpp,also a .lib file i put it in the next folder: C:\Program Files(x86)\Dev-Cpp\MinGW64\lib that also it's where i have installed Dev-Cpp, i added -l FreeImage to the linker too.
when i compile the code the .h files are found correctly, but Dev-Cpp gives me errors of type Undefined reference to,i understand this is because C++ can't found where it's the functions defined.
Code:
#include <iostream>
#include <FreeImagePlus.h>
int main(){
fipImage img;
img.load("Goten.jpg");
return 0;
}
Errors:
C:\Users\admin\AppData\Local\Temp\ccjljTTu.o Aburrido2.cpp:(.text+0x36): undefined reference to `__imp__ZN8fipImageC1E15FREE_IMAGE_TYPEjjj'
C:\Users\admin\AppData\Local\Temp\ccjljTTu.o Aburrido2.cpp:(.text+0x53): undefined reference to `__imp__ZN8fipImage4loadEPKci'
C:\Users\admin\AppData\Local\Temp\ccjljTTu.o Aburrido2.cpp:(.text+0x68): undefined reference to `__imp__ZN8fipImageD1Ev'
C:\Users\admin\AppData\Local\Temp\ccjljTTu.o Aburrido2.cpp:(.text+0x7f): undefined reference to `__imp__ZN8fipImageD1Ev'
C:\Users\admin\Desktop\Programacion\collect2.exe [Error] ld returned 1 exit status
Linker:
-static-libgcc -lFreeImage
What i need to do? - Sorry for my english.
I'm trying to compile and link AVR based program in Atmel Studio (7). I have got the error message in linking phase.
I am doing this procedure first time with this software, because I got this software for maintenance. And I heard that this software have been succesfully built previously in "some environment". I installed the newest Atmel Studio, and picked project file, and selected correct processor. After the linking phase started, the error message appeared regarding undefined reference.
Building target: 16k.elf Invoking: AVR/GNU Linker : 5.4.0
"C:\Program Files
(x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe"
-o 16k.elf DanskOFP.o adc_drv.o -Wl,-Map="16k.map" -Wl,--start-group -Wl,--end-group -Wl,--gc-sections -mmcu=atmega164p -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.209\gcc\dev\atmega164p"
C:\Projektit\V2.34\DanskOFP\Atmega164p\Makefile(118,1): error: recipe
for target '16k.elf' failed DanskOFP.o: In function `CPRX':
C:\Projektit\V2.34\DanskOFP\Atmega164p\Makefile(118,1): error: recipe
for target '16k.elf' failed DanskOFP.o: In function CPRX':
C:\Projektit\V2.34\DanskOFP\DanskOFP.c(1507,1): error: undefined
reference to__eewr_byte_m164p'
C:\Projektit\V2.34\DanskOFP\DanskOFP.c(1507,1): error: undefined
reference to __eewr_byte_m164p'
C:\Projektit\V2.34\DanskOFP\DanskOFP.c(1507,1): error: undefined
reference to__eewr_byte_m164p'
C:\Projektit\V2.34\DanskOFP\DanskOFP.c(1507,1): error: undefined
reference to __eewr_byte_m164p'
C:\Projektit\V2.34\DanskOFP\DanskOFP.c(1507,1): error: undefined
reference to__eewr_byte_m164p'
I expect that the internal definition regarding "__eewr_byte_m164p" should be found from somewhere, but I have no glue, has something changed between AVR versions, or should the definition presented some new practise ?
I guess that's a function from avr-libc, namely the target-specific function called from eeprom_write_byte(). Make sure that avr-libc in in the build/link path.
I am relatively new to TCL and I am trying to execute a C++ program using SWIG on Windows 10. Using command prompt. I am not using Visual Studio
I am basically trying to run r_cpp using C++ MinGW from TCL
C:\swigwin-3.0.12\Examples\r\class>swig -c++ -tcl example.i`
C:\swigwin-3.0.12\Examples\r\class>g++ -c example.cxx
C:\swigwin-3.0.12\Examples\r\class>g++ -c example_wrap.cxx -I/Tcl/include/tcl8.6
C:\swigwin-3.0.12\Examples\r\class>g++ -shared example.o example_wrap.o -o example.dll
example_wrap.o:example_wrap.cxx:(.text+0x981): undefined reference to `_imp__Tcl_ResetResult'`example_wrap.o:example_wrap.cxx:(.text+0x995): undefined reference to `_imp__Tcl_SetObjResult'`example_wrap.o:example_wrap.cxx:(.text+0x9b9): undefined reference to `_imp__Tcl_SetErrorCode'
example_wrap.o:example_wrap.cxx:(.text+0x9cf): undefined reference to `_imp__Tcl_ResetResult'
example_wrap.o:example_wrap.cxx:(.text+0x9f3): undefined reference to `_imp__Tcl_SetErrorCode
example_wrap.o:example_wrap.cxx:(.text+0xa1e): undefined reference to `_imp__Tcl_AppendResult'
example_wrap.o:example_wrap.cxx:(.text+0xa3c): undefined reference to `_imp__Tcl_NewStringObj'
collect2.exe: error: ld returned 1 exit status
Can someone please help me on this??
Should I make changes to my Makefile.in in the folder?????
Its been a while since I've done C but I would think that you are not linking in the static/shared library that has the functions that g++ is complaining about. In this case the tcl library something like libTclXX.dll. I'm not too familiar with command lines on windows but something like -llibtclXX.dll -L path_to_tcllib could be added. If I recall correctly tcl does provide a stub library for you to link staticially your extension then at runtime the shared library can be use to resolve the functions... so something like -llibtclstubs.dll . look in your installed lib directory for actual names of these libraries.
I am using MinGW compiler on Windows to compile my C++ application with sockets. My command for linking looks like:
g++.exe -Wall -Wno-long-long -pedantic -lwsock32 -o dist/Windows/piskvorky { there are a lot of object files }
and I have also tried
g++.exe -Wall -Wno-long-long -pedantic -lws2_32 -o dist/Windows/piskvorky { there are a lot of object files }
but in both case I get this error:
build/Windows/MinGW-Windows/src/utils/tcpunit.o:tcpunit.cpp:(.text+0x33): undefined reference to `closesocket#4'
build/Windows/MinGW-Windows/src/utils/tcpunit.o:tcpunit.cpp:(.text+0xd0): undefined reference to `send#16'
build/Windows/MinGW-Windows/src/utils/tcpunit.o:tcpunit.cpp:(.text+0x1ee): undefined reference to `recv#16'
build/Windows/MinGW-Windows/src/utils/tcpdevice.o:tcpdevice.cpp:(.text+0x184): undefined reference to `WSAStartup#8'
build/Windows/MinGW-Windows/src/utils/tcpdevice.o:tcpdevice.cpp:(.text+0x1a5): undefined reference to `closesocket#4'
build/Windows/MinGW-Windows/src/utils/tcpdevice.o:tcpdevice.cpp:(.text+0x1cb): undefined reference to `closesocket#4'
build/Windows/MinGW-Windows/src/utils/tcpdevice.o:tcpdevice.cpp:(.text+0x1d3): undefined reference to `WSACleanup#0'
build/Windows/MinGW-Windows/src/utils/tcpdevice.o:tcpdevice.cpp:(.text+0x6fe): undefined reference to `bind#12'
build/Windows/MinGW-Windows/src/utils/tcpdevice.o:tcpdevice.cpp:(.text+0x724): undefined reference to `listen#8'
build/Windows/MinGW-Windows/src/utils/tcpdevice.o:tcpdevice.cpp:(.text+0x7f0): undefined reference to `gethostbyaddr#12'
build/Windows/MinGW-Windows/src/utils/tcpdevice.o:tcpdevice.cpp:(.text+0x83c): undefined reference to `socket#12'
build/Windows/MinGW-Windows/src/utils/tcpdevice.o:tcpdevice.cpp:(.text+0x86f): undefined reference to `htons#4'
build/Windows/MinGW-Windows/src/utils/tcpdevice.o:tcpdevice.cpp:(.text+0x8b5): undefined reference to `connect#12'
build/Windows/MinGW-Windows/src/utils/tcpdevice.o:tcpdevice.cpp:(.text+0x9c6): undefined reference to `accept#12'
Do you have any ideas where the problem can be, please?
Put the -lws2_32 AFTER the list of object files - GCC searches libraries and object files in the order they appear on the command line.
Just to help the other viewers out there:
gcc hello.c -o hello.o -lws2_32
With MinGW on eclipse:
Menu >> Project >> Properties >> C/C++ Build >> Settings: Register "Tool Settings" - MinGW C Linker - Miscellaneous: Lower Part "other objects"
Add: "D:\Programmierung\mingw\lib\libwsock32.a" for example. No other entries for libwsock32.a on any other properties required, especially not in Library-entries. Also no flags relating to this Lib.
In:
Menu - Project - Properties - c/c++Build - Settings: Register "Tool Settings" - MinGW C++ Linker - Miscellaneous: Lower Part "other objects"
Add: libwsock32.a from bin folder of MinGW.
Greetings I just went through the problem above....
So here are some observations first off....
I know you are refering to MinGw, but you may need cygwin to get around this, I don't know mingw that well, I know cygwin better. But I know that they are cousins of each other.
Cygwin comes with the precompiled boost libraries, but who knows of which version they are. I'm sure it's possible to check, but who has time to do that right? I do not link against cygwin boost libraries, or the mingw boost libraries, I built boost from scratch using gcc on windows (cygwin). The compile did fine.
At the time of this writing boost is on version 1.47.0 I beleive.
Already that fact that cygwin uses version (x?) and boost is 1.47.0 could be a major issue. Make you know what you are using in the way of boost.
I was using code developed on boost 1.42, and had related linker errors. The code compiled, headers were found, etc..etc... but then I got the undefined reference to WSA etc...etc...opensocket this, close socket that, etc....
So, apparantly boost, in order to do network sockets, requires a platform library, in which was found in the form of ws2_32 for windows, and socket for linux for sure.
So if you are properly using boost, and including the correct boost system libraries, you may also need an OS specific library to access some resources (networking in this case).
Linker errors dissappear after that. It's probably obvious to boost veterans what's going on here, but I was unable to find a clear answer via google.