0

I'm having some trouble compiling a program called RNASalsa (source code here). According to the manual, all I heve to do is download the tar.gz file and do

tar zxvf RNAsalsa_xxx.tar.gz
cd RNAsalsa_xxx
make

The output from make generates the following error:

    gcc -O1 -DUNUSED='' -g -lm -o RNAsalsa  main.o  alifold.o  align.o  constraint.o  energy_par.o  fold.o  fold_vars.o  makeMx6.o  params.o  read_input.o  sequences.o  structaln.o  scoring10.o  multiple8.o  makeMx7.o  PS_dot.o  utilities.o  utils.o  naview.o  final_consensus.o
alifold.o: In function `alifold':
RNAsalsa_0.8.1/alifold.c:186: undefined reference to `HairpinE'
RNAsalsa_0.8.1/alifold.c:203: undefined reference to `LoopEnergy'
RNAsalsa_0.8.1/alifold.c:465: undefined reference to `HairpinE'
RNAsalsa_0.8.1/alifold.c:479: undefined reference to `LoopEnergy'
fold.o: In function `ML_Energy':
RNAsalsa_0.8.1/fold.c:1242: undefined reference to `log'
fold.o: In function `HairpinE':
RNAsalsa_0.8.1/fold.c:789: undefined reference to `log'
fold.o: In function `LoopEnergy':
RNAsalsa_0.8.1/fold.c:869: undefined reference to `log'
RNAsalsa_0.8.1/fold.c:893: undefined reference to `log'
fold.o: In function `HairpinE':
RNAsalsa_0.8.1/fold.c:789: undefined reference to `log'
PS_dot.o: In function `PS_color_dot_plot':
RNAsalsa_0.8.1/PS_dot.c:764: undefined reference to `sqrt'
PS_dot.o: In function `simple_xy_coordinates':
RNAsalsa_0.8.1/PS_dot.c:805: undefined reference to `sincos'
PS_dot.o: In function `PS_dot_plot_list':
RNAsalsa_0.8.1/PS_dot.c:908: undefined reference to `sqrt'
PS_dot.o: In function `PS_color_dot_plot_turn':
RNAsalsa_0.8.1/PS_dot.c:997: undefined reference to `sqrt'
PS_dot.o: In function `PS_dot_plot_turn':
RNAsalsa_0.8.1/PS_dot.c:1027: undefined reference to `sqrt'
naview.o: In function `construct_circle_segment':
RNAsalsa_0.8.1/naview.c:981: undefined reference to `sqrt'
naview.o: In function `find_center_for_arc':
RNAsalsa_0.8.1/naview.c:1123: undefined reference to `sqrt'
RNAsalsa_0.8.1/naview.c:1130: undefined reference to `acos'
RNAsalsa_0.8.1/naview.c:1132: undefined reference to `acos'
naview.o: In function `construct_circle_segment':
RNAsalsa_0.8.1/naview.c:1006: undefined reference to `sqrt'
RNAsalsa_0.8.1/naview.c:1007: undefined reference to `atan2'
RNAsalsa_0.8.1/naview.c:1011: undefined reference to `sincos'
naview.o: In function `traverse_loop':
RNAsalsa_0.8.1/naview.c:467: undefined reference to `sincos'
RNAsalsa_0.8.1/naview.c:467: undefined reference to `sincos'
RNAsalsa_0.8.1/naview.c:463: undefined reference to `sqrt'
RNAsalsa_0.8.1/naview.c:466: undefined reference to `atan2'
RNAsalsa_0.8.1/naview.c:586: undefined reference to `asin'
RNAsalsa_0.8.1/naview.c:586: undefined reference to `sincos'
RNAsalsa_0.8.1/naview.c:587: undefined reference to `asin'
RNAsalsa_0.8.1/naview.c:587: undefined reference to `sincos'
RNAsalsa_0.8.1/naview.c:601: undefined reference to `sincos'
RNAsalsa_0.8.1/naview.c:628: undefined reference to `sincos'
RNAsalsa_0.8.1/naview.c:685: undefined reference to `sqrt'
RNAsalsa_0.8.1/naview.c:690: undefined reference to `sqrt'
RNAsalsa_0.8.1/naview.c:696: undefined reference to `sqrt'
RNAsalsa_0.8.1/naview.c:704: undefined reference to `atan2'
RNAsalsa_0.8.1/naview.c:708: undefined reference to `atan2'
RNAsalsa_0.8.1/naview.c:742: undefined reference to `sqrt'
RNAsalsa_0.8.1/naview.c:743: undefined reference to `atan2'
RNAsalsa_0.8.1/naview.c:747: undefined reference to `sqrt'
RNAsalsa_0.8.1/naview.c:748: undefined reference to `atan2'
naview.o: In function `construct_extruded_segment':
RNAsalsa_0.8.1/naview.c:1046: undefined reference to `sqrt'
RNAsalsa_0.8.1/naview.c:1068: undefined reference to `atan2'
RNAsalsa_0.8.1/naview.c:1077: undefined reference to `atan2'
RNAsalsa_0.8.1/naview.c:1083: undefined reference to `sincos'
RNAsalsa_0.8.1/naview.c:1087: undefined reference to `sincos'
naview.o: In function `traverse_loop':
RNAsalsa_0.8.1/naview.c:774: undefined reference to `sincos'
collect2: error: ld returned 1 exit status

So, it seems that there is something wrong in the order it is calling certain functions. For instance, function 'alifold' has an undefined reference to 'HairpinE' before this function is defined. Also, the undefined references to 'log' and 'sqrt' imply that it is failing to include 'math.h' (yes "include " is in the .c files).

Any ideas why this may happen? The makefile given by the developers is as follows:

EXE     = RNAsalsa
CC      = gcc
LL      = gcc
VERSION = 0.8.1
DISTNAME= RNAsalsa_0.8.1
CCFLAGS = -O1 -DUNUSED='' -g
LIBS    = -lm
INCS    = alifold.h energy_const.h \
          energy_par.h fold.h fold_vars.h intloops.h \
          pair_mat.h params.h scoretable.h \
          utils.h circfold.inc PS_dot.h structs.h
SRCS    = main.c alifold.c align.c constraint.c energy_par.c fold.c \
          fold_vars.c makeMx6.c params.c read_input.c sequences.c \
          structaln.c scoring10.c multiple8.c makeMx7.c PS_dot.c\
          utilities.c utils.c naview.c final_consensus.c
OBJS    = $(foreach file, $(SRCS:.c=.o), $(file))
all: $(EXE)
$(EXE): $(OBJS)
        $(LL) $(CCFLAGS) $(LIBS) -o $(EXE) $(OBJS)
$(OBJS): %.o: %.c
        $(CC) -c $(CCFLAGS) $< -o $@
veryclean:
        rm -f $(OBJS) $(EXE)
clean:
        rm -f $(OBJS) core

I'm using gcc 5.4.0, in ubuntu 16.04.1, build-essential is installed

Thanks in advance

bipll
  • 11,747
  • 1
  • 18
  • 32
  • 5
    This is a question to the software developer/maintainer. – Eugene Sh. Jul 04 '18 at 16:54
  • 3
    Old school: try `$(LL) $(CCFLAGS) $(OBJS) $(LIBS) -o $(EXE)` – WhozCraig Jul 04 '18 at 17:47
  • 1
    WhozCraig is correct. Libraries have to come _after_ object files on the link line. This makefile is wrong. – MadScientist Jul 04 '18 at 18:05
  • https://stackoverflow.com/questions/7826448/linking-libraries-with-gcc-order-of-arguments – Antti Haapala -- Слава Україні Jul 04 '18 at 18:49
  • The functions such as `log` are definitely missing because `-lm` appears before any object files, so there are no outstanding (undefined) references to the functions in the library when the library is searched. (Some systems handle it; they're an exception, not the rule, and for good reason.) Put the libraries after the object files on the linker command line. It is not so obvious why the other functions (`HairpinE` and `LoopEnergy`) are missed. The line `OBJS = $(foreach file, $(SRCS:.c=.o), $(file))` in the makefile is a convoluted way of writing `OBJS = $(SRCS:.c=.o)`. – Jonathan Leffler Jul 05 '18 at 00:04

0 Answers0