I have a HUGE C++ program which compiles fine with -O3 optimization but gives a "undefined reference to strings_array_multilevel variable" error, when compiled with -g option (-O3 is removed).
I have reduced the testcase somewhat. If you have encountered a similar error, let me know how you fixed it. I have a library named libtest.so. The file test.c is compiled into a library using standard gcc commands. The thing to note is that header file test.h has an array declared as an extern (strings_array_multilevel)
const struct mystruct elem3 = = {
{30, 9, 26},
{
{
{9, 9},
{9, 9}
},
{
{9, 11},
{9, 11}
}
},
(char**)strings_array_multilevel
};
test.h : Please see here http://ift.tt/1HWRPtc
test.c : Please see here http://ift.tt/1DqEt92
Makefile :Please see here http://ift.tt/1DqEt94
Now, when I include test.h in my a project and link it against libtest.so with option -g, I get following error
cat use_library.c
#include <stdio.h>
int main () {
printf ("hello world\n");
return 0;
}
Following works.
g++ -O3 use_library.c -L<original_directory> -ltest
The following fails
g++ -g use_library.c -L<original_directory> -ltest
Undefined reference to strings_array_multilevel
Please let me know if you can figure this out. Sorry, because of private nature of code, I cannot share it here.
Thanks
Aucun commentaire:
Enregistrer un commentaire