Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linking to libopenal.a causes duplicated symbol error #636

Open
fuzhouch opened this issue Dec 3, 2023 · 0 comments
Open

Linking to libopenal.a causes duplicated symbol error #636

fuzhouch opened this issue Dec 3, 2023 · 0 comments

Comments

@fuzhouch
Copy link

fuzhouch commented Dec 3, 2023

Hi,

I'm working on a project to build Hashlink against 100% static libraries, which targets creating a binary that can be copied and use in any Linux distro. However when I link against a static libopenal.a, gcc complains a lot of "duplicated symbol" errors.

I have spotted the root cause: it's because AL_IMPORT() and ALC_IMPORT() macros apply a trick when loading extensions, that they define a global function pointer, with same name of corresponding openal-soft functions. Then the function pointers are loaded via alc_load_extensions(). For example:

    alBufferDataStatic = (TYPE_CAST)alGetProcAddress("alBufferDataStatic");

When linking against a static libopenal.a, the function pointer variables and functions have naming conflict, thus causes compiler complains.

I have a private fix by modifying AL_IMPORT() and ALC_IMPORT() macros, to use add function pointers with _dyn suffix. It verified it with my own build environment project.

I'm happy to contribute, but I would like to understand the history what why the trick was applied. What's more, I can see the extension functions have existed in openal-soft and OpenAL, so looks like there's no need to do a if-exist-and-load trick. Or, if we can call the functions directly, it will be even easier.

Any feedbacks will be appricated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant