Popular Posts

Saturday, January 7, 2012

Compiling and Installing WFDB version 10.5 on Debian Squeeze

Today I tried to compile and install the WFDB tools from the PhysioToolkit (PhysioNet) on my Debian Squeeze system. I am documenting this experience here!

  1. Download the source package from http://www.physionet.org/physiotools/wfdb.tar.gz
  2. Install the needed Debian packages first. I needed the following Debian packages
    • libcurl4-gnutls-dev (for NETFILES feature support in WFDB, which allows you to work on portions of the PhysioBank data records online, without having to download the entire record on your computer)
    • libexpat1-dev (for XML parsing, some files did not compile successfully while installig the WFDB library because this package was missing)
  3. Follow the steps under "if you download the sources (recommended):" in the official quick start guide. If you are on a 64-bit system (like me!) then do NOT install the WAVE application now
  4. If you installed the WFDB library in a non-standard path (as I did), then probably you will need to adjust the $PATH and $LD_LIBRARY_PATH environment variables. I added the following snippet to my ~/.bashrc, (this will be automatically executed every time you login into a shell -- run '. ~/.bashrc' ('DOT SPACE ~/.bashrc') to execute the profile script immediately!) -- I also needed to manually copy the 'man' folder from the "(path to WFDB installation)/share/man" to '/usr/share/man' for manual enteries to be installed into the system!
  5. # add WFDB binaries to PATH
    PATH="$PATH:(path to WFDB installation)/bin"

    # add WFDB libraries to LD_LIBRARY_PATH
    LD_LIBRARY_PATH="$LD_LIBRARY_PATH:(path to WFDB installation)/lib64"
  6. Now you are ready to install the optional WAVE application in case you are running a 64-bit system. For this, I followed the instructions in this post. (Note: package ia32-libs must be installed!) Finally, you will need to further modify your ~/.bashrc to append the following
# add WFDB-32 binaries to PATH
PATH="$PATH:(path to WFDB-32 installation)/bin"

# add WFDB-32 libraries to LD_LIBRARY_PATH
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:(path to WFDB-32 installation)/lib"
Update1: With WFDB version 10.5.13 on Ubuntu 12.04, I had to manually change two lines in each Makefile of the subdirectories (app,checkpkg,convert,examples,fortran,psd,xml) to compile with libcurl successfully
LC = `curl-config --cflags`
LL = `curl-config --libs`

Otherwise, I was getting errors such as
ann2rr.c: In function ‘help’:
ann2rr.c:370:6: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
/home/islam/wfdb/wfdb-10.5.13/build/lib64/libwfdb.so: undefined reference to `curl_global_cleanup'
/home/islam/wfdb/wfdb-10.5.13/build/lib64/libwfdb.so: undefined reference to `curl_easy_perform'
/home/islam/wfdb/wfdb-10.5.13/build/lib64/libwfdb.so: undefined reference to `curl_global_init'
/home/islam/wfdb/wfdb-10.5.13/build/lib64/libwfdb.so: undefined reference to `curl_easy_init'
/home/islam/wfdb/wfdb-10.5.13/build/lib64/libwfdb.so: undefined reference to `curl_version'
/home/islam/wfdb/wfdb-10.5.13/build/lib64/libwfdb.so: undefined reference to `curl_easy_setopt'
/home/islam/wfdb/wfdb-10.5.13/build/lib64/libwfdb.so: undefined reference to `curl_easy_cleanup'
collect2: ld returned 1 exit status
make[2]: *** [ann2rr] Error 1


Update2: Check the solution posted by Murari Srinivasan and George Moody (the author of WFDB) in the comments below. The error above is temporary and should be resolved soon out-of-the-box.

9 comments:

Jacques Bessa said...

I'm with the same problem. Anyone can help?

Murari Srinivasan said...

The configure file does NOT generate the correct Makefile in subdirectories. Specifically, the variables $LC and $LL are set incorrectly in all subdirectories except for “lib”. This may be fixed byby making the following changes to conf/linux.def:

LC = ‘curl-config --cflags”
LL = ‘curl-config --libs’


This is a better solution than manually modifying Makefiles in all directories since those Makefiles are auto-generated.

Anonymous said...

I am using ubuntu 12.04 and the install was successful, the "make check" ran ok, but all the code examples are not compiling.

When i try to compile "example1.c", this errors occur.

/usr/lib64/libwfdb.so: undefined reference to `curl_global_cleanup'
/usr/lib64/libwfdb.so: undefined reference to `curl_easy_perform'
/usr/lib64/libwfdb.so: undefined reference to `curl_global_init'
/usr/lib64/libwfdb.so: undefined reference to `curl_easy_init'
/usr/lib64/libwfdb.so: undefined reference to `curl_version'
/usr/lib64/libwfdb.so: undefined reference to `curl_easy_setopt'
/usr/lib64/libwfdb.so: undefined reference to `curl_easy_cleanup'

Do someone know how to fix this?

Sorry my english, not first language.

George Moody said...

I'm the author of the WFDB package. Sorry that you
encountered this problem. The solution quoted by Murari Srinivasan was originally included in the comments in conf/linux.def, immediately above the lines that need to be changed, in every libcurl-compatible version of the WFDB library (the first one was version 10.3.17 in August 2005). (BTW, Murari used 2 backquotes (`), a double quote ("), and an apostrophe (') -- but all four of these should be backquotes.) In that file, LC and LL are empty by default, because (depending on how you wish to use the WFDB library) libcurl is not required in all cases. For example, in embedded devices with no network connections, libcurl is unneeded. The 'configure' script is intended to set the values of LC and LL.

The problem appears to result from changes in Debian's packaging or default installation of libcurl, which is called by
the WFDB library but not directly by typical WFDB applications. In most cases, the locations of shared libraries need to be specified only when compiling the code that invokes them (as is done when compiling the WFDB library). It's generally harmless to include this information even if it is unnecessary, however. I didn't do so originally because it causes complications (which I have since worked out) when compiling 32-bit code on 64-bit platforms.

Since Ubuntu 12.04 is based on Debian, this problem occurs there, too. It does not seem to be happening on RPM-based Linux distributions, but it's probably just a matter of time until it does.

To avoid this problem in the future, I've made a small change in the 'configure' script in the latest release (10.5.17, which I'll post on PhysioNet within the next hour), so that the line that was

if [ $LIBTYPE = "static" -a $NETLIB != "none" ]

is now

if [ $NETLIB != "none" ]

This change causes 'configure' to set LC and LL as needed by current versions of Debian and Ubuntu, without causing problems on other GNU/Linux distributions, as far as I can tell. Please let me know if you encounter any related problems in the future.

Anonymous said...

@George Moody

Unfortunately, none of the solutions listed here work. :/

Lean Wang said...

This problem persists on my ubuntu 13.10 desktop:

gcc -g -O -DWFDB_MAJOR=10 -DWFDB_MINOR=5 -DWFDB_RELEASE=22 -fno-stack-protector `curl-config --cflags` -I/usr/include ann2rr.c -o ann2rr -L/usr/lib64 -lwfdb `curl-config --libs`
ann2rr.c: In function ‘help’:
ann2rr.c:370:6: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
(void)fgets(b, 5, stdin);
^
/usr/lib64/libwfdb.so: undefined reference to `curl_global_cleanup'
/usr/lib64/libwfdb.so: undefined reference to `curl_easy_perform'
/usr/lib64/libwfdb.so: undefined reference to `curl_global_init'
/usr/lib64/libwfdb.so: undefined reference to `curl_easy_init'
/usr/lib64/libwfdb.so: undefined reference to `curl_version'
/usr/lib64/libwfdb.so: undefined reference to `curl_easy_setopt'
/usr/lib64/libwfdb.so: undefined reference to `curl_easy_cleanup'
collect2: error: ld returned 1 exit status
make[1]: *** [ann2rr] Error 1
make[1]: Leaving directory `/home/lean/Downloads/wfdb-10.5.22/app'
make: *** [install] Error 2
root@lean-HPVirtualBox:/home/lean/Downloads/wfdb-10.5.22#

my system is:
1. ubuntu 13.10 desktop (64-bit)
2. Oracle VM 4.3.6 (1024M memory)
3. gcc.real 4.8.1
4. libcurl 7.32.0
5. perl v5.14.2

Steps:
1. Enter SuperUser;
2. follow Step 2 in "WFDB Quick Start for GNU/Linux", http://www.physionet.org/physiotools/wfdb-linux-quick-start.shtml;
3. got error after entering "make install";

note:
a. all the Makefile contains the right LC and LL as Murari said in Oct 3,2012:
LC = `curl-config --cflags`
LL = `curl-config --libs`

b. if [ $NETLIB != "none" ] found in line#458 of file:configure is exactly what George posted on Jan 2,2013.


Additional Note:
i. I add "INCDIR=." in file:configure so that wrdb directory is generated in my local directory:
/home/lean/Downloads/wfdb-10.5.22

Can you help?

Many thanks in Advance!!

Lean Wang said...

BTW, this is only FYI:

when I enter "curl-config --libs", system gives me:
-L/usr/lib/x86_64-linux-gnu -lcurl

when I enter "curl-config --cflags", system gives me an emply line. Assuming there is no cflags for curl-config.

Anonymous said...

Solved in http://ubuntuforums.org/showthread.php?t=1982214

I was having the same problem trying to compile psamples.c in Ubuntu 12.04

I finally get it to compile correctly with:

`curl-config --cc --cflags --libs` -o psamples psamples.c -lwfdb `curl-config --libs`

Miguel Altuve said...

I have the same problem on kubuntu 13.10, as Lean Wang said.

Furthermore, When I change LC = `curl-config --cflags` by `curl-config --cc --cflags --libs`, as Anonymous said, after make install I get

gcc -g -O -DWFDB_MAJOR=10 -DWFDB_MINOR=5 -DWFDB_RELEASE=22 -fno-stack-protector `curl-config --cflags` `curl-config --cc --cflags --libs` -I/usr/include ann2rr.c -o ann2rr -L/usr/lib64 -lwfdb `curl-config --libs` `curl-config --libs`
gcc: error: gcc: No such file or directory