[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [OATH-Toolkit-help] compilation problem using liboath library
From: |
Ilkka Virta |
Subject: |
Re: [OATH-Toolkit-help] compilation problem using liboath library |
Date: |
Mon, 27 May 2013 15:53:44 +0300 |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 |
On 27.5.2013 1:19, Alan Markus wrote:
Hi,
I am trying to use the oath-toolkit lib to test totp but i am having a
problem when i try to compile my "test" program with the liboath
library. Sorry for asking this here but i am sutcked for the last 2 days.
here is the information:
Library is installed from oath-toolkit source, compilation and
installation without problems.
address@hidden:~/totp$ sudo ldconfig -v | grep liboath
liboath.so.0 -> liboath.so.0.1.3
My main.cpp "test" program:
#include <liboath/oath.h>
address@hidden:~/totp$ g++ main.cpp -loath -o teste
/tmp/ccXbve8u.o: In function `main':
main.cpp:(.text+0x45): undefined reference to `oath_init()'
Since that's a C program (instead of C++), you should use gcc to compile
it instead of g++.
If you change to C++ at some point, and use a C library (like -loath),
you have wrap the C declarations (or the header file) in extern "C" {}.
This should work:
extern "C" {
#include <liboath/oath.h>
}
You should find more information on this online (way more than I
know..., see for example:
http://stackoverflow.com/questions/1041866/in-c-source-what-is-the-effect-of-extern-c
--
Ilkka Virta / itvirta at iki.fi