C++ symbol has different size in shared object
c++, glload, linker, linux, shared-libraries
Solution
wilsonmichaelpatrick's answer is mostly correct, but using `gdb` is likely not the fastest way to find the problem, and will likely not work at all if you have a non-debug build.
First, you should confirm that there in fact is a problem:
readelf -Ws _dist/x64-linux-debug/bin/test _dist/x64-linux-debug/lib64/libvendor.so |
grep glXCreateContextAttribsARB
This should show the symbol being defined in `test` and `libvendor.so`, with different size.
Second, re-link `test` and `libvendor.so` with `-Wl,-y,glXCreateContextAttribsARB` flag. That will tell you which object files (or libraries) provide the (different) definitions.
Finally, preprocess the sources that produce above object files with `-E` and `-dD` flags, and see what's different between them.
Update:
I need help digesting what it is saying
Don't be helpless. Read `man readelf`, or just run it by hand. You'll see something like this:
readelf -Ws /bin/date | head -5
Symbol table '.dynsym' contains 75 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __ctype_toupper_loc@GLIBC_2.3 (2)
This tells you the meaning of the data you've got. In particular, this tells you that the size of the symbol in `test` and in `libvendor.so` is the same (`8`). Therefore, the problem is not in these two ELF files, but somewhere else. Run `readelf` on your other libraries, and look for definition of `glXCreateContextAttribsARB` that has a different size. Then follow the rest of the procedure.
Problem
I have been working on a cross platform windowing library aimed to be used for OpenGL specifically, currently focusing on linux. I am making use of glload to manage OpenGL extensions, and this is being compiled, along with other libraries that I will use later, into an `.so`. This `.so is being dynamically loaded as you would expect, but at run time the program gives the following output (manually wrapped so it is easier to read): ``` _dist/x64-linux-debug/bin/test: Symbol `glXCreateContextAttribsARB' has \ different size in shared object, consider re-linking ``` Now, obviously I have tried re-linking, going as far as rebuilding the entire project many times (testing things out, not just blindly hoping it will magically make it all better). The program does seem to be willing to run as it will produce some logging output as I would expect it to. I have used `nm` to confirm that the 'symbol' is in the `.so` ``` nm _dist/x64-linux-debug/lib64/libvendor.so | grep glXCreateContextAttribsARB 00000000009e0e78 B glXCreateContextAttribsARB ``` If I use `readelf` to look at the symbols being defined I get the following (again, I have manually wrapped the first three lines for formatting sake): ``` readelf -Ws _dist/x64-linux-debug/bin/test \ _dist/x64-linux-debug/lib64/libvendor.so | \ grep glXCreateContextAttribsARB 348: 000000000062b318 8 OBJECT GLOBAL DEFAULT 26 glXCreateContextAttribsARB 421: 000000000062b318 8 OBJECT GLOBAL DEFAULT 26 glXCreateContextAttribsARB 1370: 00000000009e0e78 8 OBJECT GLOBAL DEFAULT 25 glXCreateContextAttribsARB 17464: 00000000009e0e78 8 OBJECT GLOBAL DEFAULT 25 glXCreateContextAttribsARB ``` I am afraid that this is about all I can offer to help, as I really do not know what to try or look into. Like I said, I am sure more will info will be need, so please just say an I will provide what I can. I am running these commands from my project root, encase you are wondering.