NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Unable to solve “undefined reference” error message

 
Post new topic   Reply to topic    NetBeans Forums -> C/C++ Users
View previous topic :: View next topic  
Author Message
alexverde



Joined: 06 Apr 2012
Posts: 2

PostPosted: Fri Apr 06, 2012 3:14 pm    Post subject: Unable to solve “undefined reference” error message Reply with quote

Hi, hope someone can help me to get this fix.

I created a new netbeans project with existing sources and makefile. The project contains 3 files: two *.c files (main.c and test.c) and a header (test.h). The header contains the declaration of many functions including some external ones (Fortran LAPACK, BLAS libraries) not included in the corresponding test.c. However, the makefile include the path of directories containing these external functions (please, see details below):
---------------------------------------------------
CC = gcc
LD = gcc
LDPATH = -L/usr/lib
LDFLAGS = -llapack -lblas -lm
FLAGS = -Wall -O3
KERN = -DELASTIC #
PFLAG =

PROG = test
OBJS = main.o test.o

all: $(PROG)
main.o: main.c test.h
$(CC) $(FLAGS) $(KERN) -c main.c $(PFLAG)

%.o: %.c %.h
$(CC) $(FLAGS) $(KERN) -c $< $(PFLAG)

$(PROG): $(OBJS)
$(LD) $(OBJS) -o $(PROG) $(LDPATH) $(LDFLAGS) $(PFLAG)
---------------------------------------------------
I added a new file (dgmres.f) to the project with a new external function not included in the path declared above (makefile). I declared this new one in the header (test.h) but when I try to build the project, I got the following error message:

undefined reference to `dgmres_'

Assuming that the issue is closely related to the makefile specification, my questions is:

What changes Do I have to do in the makefile in order to include this new file/function?.

Please, let me know any comments or suggestions. I really appreciated any help on this regard.

PD: I am using Netbeans IDE 7.1.1 under linux Ubuntu 11.10.
Back to top
Paulo R. Panhoto
Posted via mailing list.





PostPosted: Sat Apr 07, 2012 3:04 pm    Post subject: Unable to solve Reply with quote

After a quick peek, it seems to me that your makefile "doesn't know how
to compile your .f file". There should a portion like this in the makefile:

dgmres.o: dgmres.f
gfortran -c dgmres.f

Regards,

Paulo

On 06/04/12 12:14, alexverde wrote:
Quote:
Hi, hope someone can help me to get this fix.

I created a new netbeans project with existing sources and makefile. The project contains 3 files: two *.c files (main.c and test.c) and a header (test.h). The header contains the declaration of many functions including some external ones (Fortran LAPACK, BLAS libraries) not included in the corresponding test.c. However, the makefile include the path of directories containing these external functions (please, see details below):
---------------------------------------------------
CC = gcc

LD = gcc

LDPATH = -L/usr/lib

LDFLAGS = -llapack -lblas -lm

FLAGS = -Wall -O3

KERN = -DELASTIC #

PFLAG =



PROG = test

OBJS = main.o test.o



all: $(PROG)



main.o: main.c test.h

$(CC) $(FLAGS) $(KERN) -c main.c $(PFLAG)



%.o: %.c %.h

$(CC) $(FLAGS) $(KERN) -c $< $(PFLAG)



$(PROG): $(OBJS)

$(LD) $(OBJS) -o $(PROG) $(LDPATH) $(LDFLAGS) $(PFLAG)

---------------------------------------------------
I added a new file (dgmres.f) to the project with a new external function not included in the path declared above (makefile). I declared this new one in the header (test.h) but when I try to build the project, I got the following error message:

undefined reference to `dgmres_'

Assuming that the issue is closely related to the makefile specification, my questions is:

What changes Do I have to do in the makefile in order to include this new file/function?.

Please, let me know any comments or suggestions. I really appreciated any help on this regard.

PD: I am using Netbeans IDE 7.1.1 under linux Ubuntu 11.10.



Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> C/C++ Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo