问题
I have trouble compiling the following code
#include <AL/al.h>
#include <AL/alc.h>
#include <iostream>
int checkEnumerationSupport() {
ALboolean enumeration;
enumeration = alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT");
if (enumeration == AL_FALSE) {
// enumeration not supported
std::cout << "enumerating devices NOT supported\n";
} else {
// enumeration supported
std::cout << "enumerating devices supported\n";
};
return 0;
}
int main() {
checkEnumerationSupport();
}
using the command below.
g++ test.cpp -o test
I get the following message:
/tmp/ccEN7YAp.o: In function `checkEnumerationSupport()':
test.cpp:(.text+0x13): undefined reference to `alcIsExtensionPresent'
collect2: error: ld returned 1 exit status
Realising the libraries weren't linked correctly, I tried changing the g++ line to
g++ -L/usr/lib/ test.cpp -o test -lal -lalc
giving me the following message:
/usr/bin/ld: cannot find -lal
/usr/bin/ld: cannot find -lalc
collect2: error: ld returned 1 exit status
I tested it on Linux Mint 17.2 and Ubuntu 14.04.
Does anyone know how to compile the code correctly?
回答1:
The answer, that we worked out in the comments, was for Brian to link to the openal library using -lopenal
instead of -lal
and -lalc
来源:https://stackoverflow.com/questions/32230601/g-unable-to-link-openal-libraries