There are several problems here, some of which are not your fault. First of all, the tests should get automatically built when you run "./autogen.sh ; ./configure ; make". I see now that that isn't happening, and I'm not quite sure why. I will see if I can find some time to look into that and fix it. In the meantime if you want to build it by hand, you'll have to fix the problems I point out below
On Wed, Nov 21, 2012 at 10:55 AM, Rodrigue Chakode < [email protected]> wrote: > Hi, > I download libdelcloud for C/C++, but when I try to compile the examples > provided I have the following linking errors. > > Do you have some ideas to fix that? > > $ gcc -Wl,-rpath -Wl,/usr/local/lib -L/usr/local/lib -ldeltacloud > -I/usr/local/include/libdeltacloud -I./tests/ tests/test_api.c > /tmp/cchStxCZ.o: In function `print_api': > test_api.c:(.text+0x6f): undefined reference to `print_link_list' > This is not being found because it exists in the "test_common.c" file. To fix this, you'll have to first compile that with "gcc -c -Wall -Iinclude/libdeltacloud tests/test_common.c -o tests/test_common.o" You'll then have to add "tests/test_common.o" to your compile command above. > /tmp/cchStxCZ.o: In function `main': > test_api.c:(.text+0x100): undefined reference to `deltacloud_initialize' > test_api.c:(.text+0x15f): undefined reference to `deltacloud_initialize' > test_api.c:(.text+0x1c1): undefined reference to `deltacloud_initialize' > test_api.c:(.text+0x220): undefined reference to `deltacloud_initialize' > test_api.c:(.text+0x27f): undefined reference to `deltacloud_initialize' > /tmp/cchStxCZ.o:test_api.c:(.text+0x2e7): more undefined references to > `deltacloud_initialize' follow > /tmp/cchStxCZ.o: In function `main': > test_api.c:(.text+0x2f0): undefined reference to > `deltacloud_get_last_error_string' > test_api.c:(.text+0x334): undefined reference to `deltacloud_has_link' > test_api.c:(.text+0x372): undefined reference to `deltacloud_has_link' > test_api.c:(.text+0x3c7): undefined reference to `deltacloud_has_link' > test_api.c:(.text+0x404): undefined reference to `deltacloud_free' > collect2: ld a retourné 1 code d'état d'exécution > > These are all happening because you have listed the library to link against (-ldeltacloud) before the files that need it. For it to work, it needs to be listed *afterwards*. If you take my advice above, then, you're compile step for the test_api should end up being something like: gcc -Wl,-rpath -Wl,/usr/local/lib -L/usr/local/lib -I/usr/local/include/libdeltacloud -I./tests/ tests/test_api.c ./tests/test_common.o -ldeltacloud Hopefully that works for you. In the meantime, I will try to see why the tests aren't getting automatically built. Thanks, Chris
