hello, i’m trying to incorporate the glslang c++ api into my program, however i am getting an error
undefined reference to glslang::InitializeProcess();
i have both tried installing glslang from source building and installing it into normal system-wide libs (my .a are in the proper places in usr/ locations… and my include libs are in the right place.
just to make sure i did not do something wrong i ALSO tired from apt-get repository the glslang-dev which also installed… still same error. on the command line it finds the librarys with the -l flag. i assume i’m missing a step, or need a particular path? or, do i need to include some particular folder into an external folder? is it just not possible to do this via g++? and need to use cmake (i’d prefer not to at this point). as i’m not so good at it yet, and i have other library issues, with cmake vs at the moment everything else works nicely and i’m still in the process of making lots of files, and changes. would rather stick to my g++ comple method. i’ve had diffcult finding examples that use just comand lines for compling… any help be thankful!
void parser_vulkan_modual::init_glslang()
{
if (!glslangInitialized)
{
glslangInitialized = glslang::InitializeProcess();
// glslangInitialized = ShInitialize(); - i also tried to see if i this would work...
}
}
i’ve tried with a make file… same result
the libglslang.a located in usr/local/lib is present. (i have also tried with -L /usr/local/lib just incase and when i do objdump -t libglslang.a
i can find the symbol
`0000000000000010 g F .text 0000000000000015 glslang_initialize_process
By the way, the symbol for c++ is definitely not glslang_initialize_process, this is for c api. The c++ symbol is mangled by some certain rule(depends on your compiler and platform), this is called name mangling, you can search for more infos. In gcc world, It will look like this:
objdump -t /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../lib/libglslang.a |rg InitializeProcess
0000000000001950 g F .text 0000000000000014 _ZN7glslang17InitializeProcessEv
0000000000000000 *UND* 0000000000000000 _ZN7glslang17InitializeProcessEv
Nothing else except this UND?
*UND* means: if the section is referenced in the file being dumped, but not defined there.
The right one should be F .text which means this is a function and is a text segment.
If I’m reading the source and CMakeLists.txt of glslang correctly the glslang::InitializeProcess function is actually in libMachineIndependent.a and for a static library build does not get combined into libglslang.a (for shared library build it looks like libglslang.so contains everything).
Can you check if libMachineIndependent.a contains a definition of the symbol and if so does adding -lMachineIndependent to the linker command line resolve the problem?
haha you know what. i literally. found this out myself like 10 min ago. i was im going through every .a via objdump and figure out where it is.
NOTE: however that JUST including -lMachineIndependent
was not enough as it also threw a ton of unresloved refs. i then was like okk… progress. you ALSO need, -lOSDependent and -lGenericCodeGen -lOGLCompiler also you have to make sure -lpthread comes AFTER the MI and OSD one. and now lol and behold it complies!
thx alll after 3 late eves of working on this resolved with all your support.
Glad you’ve find your way!
And I just wanna mention rg (ripgrep) is just a drop in replacement for grep, which is faster (and 2 char shorter then grep in command). I highly recommend it and even vscode is using it for global search task.