[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Linkage and LTDL_SET_PRELOADED_SYMBOLS
From: |
Peter Rosin |
Subject: |
Linkage and LTDL_SET_PRELOADED_SYMBOLS |
Date: |
Fri, 17 Sep 2010 16:22:37 +0200 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.8) Gecko/20100802 Thunderbird/3.1.2 |
Hi!
I have been trying to fix exceptions.at on MSVC and have stumbled
into a problem. The function main() in main.cpp starts out with
LTDL_SET_PRELOADED_SYMBOLS();
If you look at what that macro does, it look like this in ltdl.h:
#define lt_preloaded_symbols lt__PROGRAM__LTX_preloaded_symbols
#define LTDL_SET_PRELOADED_SYMBOLS() LT_STMT_START{ \
extern LT_DLSYM_CONST lt_dlsymlist lt_preloaded_symbols[]; \
lt_dlpreload_default(lt_preloaded_symbols); \
}LT_STMT_END
I.e. call lt_dlpreload_default with the address of
lt__PROGRAM__LTX_preloaded_symbols as argument. Now, that address
comes from the generated symbol resolution table, i.e. main.exeS.c
in this case. The code from that file looks like this if you cut
out the "crap":
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
const char *name;
void *address;
} lt_dlsymlist;
extern lt_dlsymlist
lt__PROGRAM__LTX_preloaded_symbols[];
lt_dlsymlist
lt__PROGRAM__LTX_preloaded_symbols[] =
{ { "@PROGRAM@", (void *) 0 },
{0, (void *) 0}
};
#ifdef __cplusplus
}
#endif
See the mismatch? main.cpp gets lt__PROGRAM__LTX_preloaded_symbols with
C++ linkage, and main.exeS.c gets it with C linkage. So, linking main.exe
explodes with:
main.obj : error LNK2019: unresolved external symbol "struct lt_dlsymlist *
lt__PROGRAM__LTX_preloaded_symbols"
(?lt__PROGRAM__LTX_preloaded_symbols@@3PAUlt_dlsymlist@@A) referenced in
function _main
.libs/main.exe : fatal error LNK1120: 1 unresolved externals
Should I do extern "C" { ... } around the whole main() function in main.cpp
or what? (that makes it build, when some other nits have been fixed)
Cheers,
Peter
- Linkage and LTDL_SET_PRELOADED_SYMBOLS,
Peter Rosin <=
- Re: Linkage and LTDL_SET_PRELOADED_SYMBOLS, Ralf Wildenhues, 2010/09/17
- Re: Linkage and LTDL_SET_PRELOADED_SYMBOLS, Peter Rosin, 2010/09/18
- Re: Linkage and LTDL_SET_PRELOADED_SYMBOLS, Peter Rosin, 2010/09/20
- [PATCH 1/2] tests: __declspec (dll{ex, im}port) in tests/exceptions.at, Peter Rosin, 2010/09/20
- Re: [PATCH 1/2] tests: __declspec (dll{ex, im}port) in tests/exceptions.at, Bob Friesenhahn, 2010/09/20
- Re: [PATCH 1/2] tests: __declspec (dll{ex, im}port) in tests/exceptions.at, Peter Rosin, 2010/09/20
- [PATCH 2/2] libltdl: Make sure preloaded symbols are declared extern "C"., Peter Rosin, 2010/09/20
- Re: Linkage and LTDL_SET_PRELOADED_SYMBOLS, Peter Rosin, 2010/09/20
- Re: Linkage and LTDL_SET_PRELOADED_SYMBOLS, Bob Friesenhahn, 2010/09/20