You are not logged in.

#1 2007-05-05 13:48:57

jardasmid
Member
Registered: 2006-02-10
Posts: 25

alpm library and undefined symbols

Hi, I'm trying to create a GUI app for installing packages in ArchLinux using libalpm library. But I'm getting some errors during the linking:

CMakeFiles/synpacman.dir/SynPacman/UpdateReposThread.o: In function `SP_UpdateReposThread::sync_synctree(__alpm_list_t*)':
UpdateReposThread.cpp:(.text+0xe8): undefined reference to `alpm_list_getdata(__alpm_list_t const*)'
UpdateReposThread.cpp:(.text+0x192): undefined reference to `alpm_list_next(__alpm_list_t*)'
CMakeFiles/synpacman.dir/SynPacman/UpdateReposThread.o: In function `SP_UpdateReposThread::_entry()':
UpdateReposThread.cpp:(.text+0x1e7): undefined reference to `alpm_list_count(__alpm_list_t const*)'
collect2: ld returned 1 exit status
make[2]: *** [synpacman] Error 1
make[1]: *** [CMakeFiles/synpacman.dir/all] Error 2
make: *** [all] Error 2

Offline

#2 2007-05-07 15:48:59

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: alpm library and undefined symbols

Can you provide your gcc command line which is doing the linking?  The errors only tell us there was an error, but not what caused it

Offline

#3 2007-05-07 23:44:29

jardasmid
Member
Registered: 2006-02-10
Posts: 25

Re: alpm library and undefined symbols

I use CMake for compilling and it calls gcc this way:

gcc -c -I{some,include,paths,including,/usr/include} SynPacman/UpdateReposThread.cpp -o CMakeFiles/synpacman.dir/SynPacman/UpdateReposThread.o
gcc -L{some,libs,paths,including,/usr/lib} -l{some,libs,alpm} {some,object,files,including,CMakeFiles/synpacman.dir/SynPacman/UpdateReposThread.o}

Offline

#4 2007-07-28 01:56:50

denisfalqueto
Member
From: ES, Brazil
Registered: 2006-03-24
Posts: 197

Re: alpm library and undefined symbols

I'm having this also and it is really strange. I'm just playing with libalpm, so de code is:

/* 
 * File:   novomain.c
 * Author: denis
 *
 * Created on 27 de Julho de 2007, 22:15
 */

#include <stdio.h>
#include <stdlib.h>
#include <alpm_list.h>

int main(int argc, char** argv) {
    printf( "Inicialização\n" );
    // Inicializar a biblioteca alpm
    alpm_initialize();

    // Descobrir qual o diretório em que está o cache
    printf( "CacheDir = %s\n", alpm_option_get_cachedir() );
    
    printf( "Liberação\n" );
    // Liberar os recursos da biblioteca
    alpm_release();

    return (EXIT_SUCCESS);
}

The building is managed by Netbeans with the C/C++ pack (very good, by the way). The commands are:

gcc    -c -g -o build/Debug/GNU-Linux-x86/novomain.o novomain.c
gcc     -o dist/Debug/GNU-Linux-x86/testepacman build/Debug/GNU-Linux-x86/novomain.o -dynamic -lalpm

The code above works fine. It initializes the library, shows the cache dir and releases very well. But if I add the following after printing the cache dir, it claims about the undefined symbols:

    alpm_list_t* list = alpm_option_get_holdpkgs();
    printf( "holdpkgs count = %d\n", alpm_list_count( list ) );

It seems that not all functions are undefined. With alpm_get_upgrades it doesn't claim. I am not a experienced C programmer, so maybe I'm missing something basic here.

Thanks.


Satisfied users don't rant, so you'll never know how many of us there are.

Offline

#5 2007-07-28 09:20:43

shining
Pacman Developer
Registered: 2006-05-10
Posts: 2,043

Re: alpm library and undefined symbols

That was a problem in libalpm, this function (and several others) were not exported (not public), so you couldn't use them from a frontend.
For this particular function, it has been fixed in git (so it'll be in pacman 3.1) as part of this commit :
http://projects.archlinux.org/git/?p=pa … eec7250114

-alpm_list_t *alpm_option_get_holdpkgs() { return handle->holdpkg; }
+alpm_list_t SYMEXPORT *alpm_option_get_holdpkgs() { return handle->holdpkg; }

See, the SYMEXPORT is important here smile


pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))

Offline

Board footer

Powered by FluxBB