g++ unable to link OpenAL Libraries

这一生的挚爱 提交于 2019-12-13 14:18:36

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!