Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 04-26-2006, 06:08 AM   #1
LQ Newbie
Registered: Apr 2006
Posts: 1

Rep: Reputation: 0
Angry how to compile a pam application

It's been two days in a row now, trying to find a simple Makefile that does nothing more than, compile a c application, that uses pam libraries.

I've been through:
- and much more
and all they talk about is: how to install a pam module, or how to create your own pam module, but none of them clearly explains how to compile the damn thing!

I've made the simplest thing I could think off:

#include <security/pam_appl.h>
#include <security/pam_misc.h>
#include <stdio.h>

static struct pam_conv conv = { NULL, NULL };

int main(int argc, char *argv[])
    pam_handle_t *pamh=NULL;
    int retval = pam_start("check_user", argv[1], &conv, &pamh);
    printf("User %sfound!\n", (retval == PAM_SUCCESS ? "" : "not ") );


    return 0;
It does nothing more, than inform if the requested user, exists or not.

Through my search I've come to this simple makefile:
	gcc -c <source>.c
	ld -x --shared -o <source>.so <source>.o -lpam  
	gcc <source>.c -lc -o <source>
using it to compile the “simple_pam_app.c”, it returns the following error:
/tmp/ccOSRcLc.o: In function `main':
simple_pam_app.c:(.text+0x3b): undefined reference to `pam_start'
simple_pam_app.c:(.text+0x79): undefined reference to `pam_end'
collect2: ld returned 1 exit status
make: *** [all] Error 1
It seems that the “pam_start” and “pam_end”, are considered to be prototype functions, can anyone explain, why this is happening?, or even better: can anyone, please, supply a simple Makefile that works, with the program above?

Sorry if I haven't been completely clear.
Thanks in advance.
Old 04-26-2006, 07:07 AM   #2
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671
You could install the pam source. It includes a short sample called check_user that includes a Makefile. The check_user.c and Makefile of this sample could serve as a model.

Last edited by jschiwal; 04-26-2006 at 01:17 PM.
Old 04-26-2006, 01:48 PM   #3
LQ Newbie
Registered: Apr 2006
Location: Minneapolis, Minnesota, USA
Posts: 16

Rep: Reputation: 1
How to compile a pam program

Do you need the shared library generated by the "ld -x ..." line for some reason? If not, you can simplify by doing just the following:

gcc -o <source> -lpam <source>.c


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
application won't compile. Help needed ASAP nunation Programming 1 03-22-2005 03:46 PM
How to compile win32 application? dmigh Programming 3 11-20-2004 10:00 AM
vsftpd + pam + virtual users - Pam cannot load database file. mdkelly069 Linux - Networking 3 09-22-2004 11:07 PM
I can't compile any QT depending C++ application! Paulo Góes Programming 1 04-17-2003 04:11 PM
compile an X-Qt-KDE application-- failed paulten Linux - Software 1 01-25-2003 10:16 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:08 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration