linux - dlsym()'ing a global variable in C++ -
I want to create a program which is a series of The problem is that the G + library has been compiled as: and "Function Index" have been declared and allocated: yet Shows: Do me so I can do Thanks Appendix Yes, I am using: G ++ - V Using a built-in app COLLECT_GCC = g ++ COLLECT_LTO_WRAPPER = / usr / lib / gcc / x86_64-unknown-linux-gnu / 4.5.2 / lto-wrapper Target: x86_64-unknown-linux-gnu is configured with: /build/src/gcc-4.5 -20110127 /configure --prefix = / usr --enable-languages = c, c ++, fortran, objc, obj-c ++, ada -enable-share - enabled-thread = Posix --enable -__ cxa_atexit --enable-clocale = gnu --enable-gnu-unique-object --enable-lto --enable-plugin --enable-gold --with-plugin-ld = ld.gold - -disable-multilib --disable -libstdcxx-pch --with-system-zlib -with-ppl --with-cloog - Include-clog - / usr / include / cloog-ppl --libdir = / Usr / lib --libexecdir = / thread model: Pausix GCC version 4.5.2 20110127 (Prerelease) (GCC) < / P> Appendix 2 For whatever reason does no works, but it does one: My question now : As I can see in some of your replies, The name of the problem is not one of the confused (or perhaps it is not: public variable name usually Is not confused.) The real problem is that "const" means steady constant, rendering invisible temporary outside the translation unit. To avoid this, the variable should be declared clearly. And "Includes Brace-Attached Announcement-seq as Linkage-Specification, does not affect whether the implied announcements are definitions or not (3.1); In the form of a linkage-specification, the same declaration will be given to an external specifier (7.1.1) For the purpose of determining that the implied declaration is a definition. "That, while it does not directly solve your problem (the presence of an initiator Ensures that the declaration is a definition), it would seem to indicate intention: are within a brace attached enclosure specifier, apply the general rule; If the link specifier is directly applicable for declaration, then it seems that the announcement was clearly excluded. You can either write: or but to explicitly define which should be an extern Built-in "override static" "Const key" dlopen () (written by itself ) And a omnibox variable is stored in it, which is named a valid variable name called
test_suite , which is a null-terminated array of function pointers (the signature of the function is predefined by me , No need to worry about that)
G ++ -Wall-Shared - Radi IP-FPIC foo.cpp -o foo. So
const testunit_testcase test_suite = {...}
objdump - t foo.so | Grep test_suite
0000000000200940L O.Data.rel.ro 0000000000000020 _ZL10test_suite
0000000000200940Lo Data .rel.ro 0000000000000020 test_suite
dlsym (dlh, "test_suite") program
dllupen () '
foo.so
Extern "c" I first tried:
extern "c" {const testunit_testcase test_suite [] = {// TESTUNIT_DEF_TESTCASE (doTest), {NULL, NULL}} }; }
Extern "C" {const testit_testcase test_suite = {. ..}}
extern "c" const Estunit_testcase test_suite = {...}
extern "C" {. ..} works for you Is there any compiler flag that I can use to make sure that
test_suite will never match, even if any 4. X (at least) g ++ version not used?
extern "c" {testunit_testcase const test_suite [] // ...}
extern "c" testunit_testcase const test_suite [] // ...
Comments
Post a Comment