-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
autodata and static library ? #21
Comments
picca notifications@github.com writes:
Ah, I see. That doesn't work: the linker won't include the xautodata I tried a few variants, but it was all fail here. I'll have to document Sorry, |
Hello, Do you think that it could be possible to solve this problem by asking on the gcc mailing list ? Cheers |
picca notifications@github.com writes:
Actually, I was wrong about the problem. The linker tries to be "smart"; it sees that you don't use any symbols For gcc (actually, the GNU linker) you can force it to include the main: main.o libfoo.a (Note that I surrounded only the library with the options to enable and Hope that helps! |
Hello, I will try to explain my problem here:
I have a library which use autodata.
hkl-factory-private.h:
struct _HklFactory
{
const char *name;
const char *description;
const darray_string axes;
HklFactoryGeometryFunction create_new_geometry;
HklFactoryEngineListFunction create_new_engine_list;
};
define REGISTER_DIFFRACTOMETER(name_, real_name_, description_) \
AUTODATA_TYPE(factories, HklFactory);
hkl-factory.c
HklFactory **hkl_factory_get_all(size_t *n)
{
return autodata_get(factories, n);
}
HklFactory _hkl_factory_get_by_name(const char *name, GError *_error)
{
size_t i, n;
HklFactory **factories;
}
and then I declare all my registered structure in a bunch of other .c files
REGISTER_DIFFRACTOMETER(twoC, "TwoC", HKL_GEOMETRY_TWOC_DESCRIPTION);
...
When I compile this code as a shared library, there is no problem, I have the expected section filled with all the factories
com-sixs@sixs7:~/picca/hkl.ssh/hkl/.libs$ nm -o libhkl.so | grep xauto
libhkl.so:00000000002467e0 D __start_xautodata_factories
libhkl.so:0000000000246850 D __stop_xautodata_factories
but when I try to generate a static library, I got htis error message
./.libs/libhkl.a(libhkl_la-hkl-factory.o): In function
hkl_factory_get_all': /home/experiences/sixs/com-sixs/picca/hkl.ssh/hkl/hkl-factory.c:29: undefined reference to
__stop_xautodata_factories'/home/experiences/sixs/com-sixs/picca/hkl.ssh/hkl/hkl-factory.c:29: undefined reference to
__start_xautodata_factories' ./.libs/libhkl.a(libhkl_la-hkl-factory.o): In function
hkl_factory_get_by_name':/home/experiences/sixs/com-sixs/picca/hkl.ssh/hkl/hkl-factory.c:37: undefined reference to
__stop_xautodata_factories' /home/experiences/sixs/com-sixs/picca/hkl.ssh/hkl/hkl-factory.c:37: undefined reference to
__start_xautodata_factories'and indeed:
com-sixs@sixs7:~/picca/hkl.ssh/hkl/.libs$ nm -o libhkl.a | grep xauto
libhkl.a:libhkl_la-hkl-factory.o: U __start_xautodata_factories
libhkl.a:libhkl_la-hkl-factory.o: U __stop_xautodata_factories
libhkl.a:libhkl_la-hkl-binding.o: U __start_xautodata_factories
libhkl.a:libhkl_la-hkl-binding.o: U __stop_xautodata_factories
So my question is, how can I fix this ?
thanks
Frederic
The text was updated successfully, but these errors were encountered: