undefined reference errors

The following is the output from my typing make in my directory that has the makefile in it.

main.o: In function main': /home/james/Desktop/WEGtest-64/./main.c:32: undefined reference to ___rouent64’
/home/james/Desktop/WEGtest-64/./main.c:32: undefined reference to ___linent64' /home/james/Desktop/WEGtest-64/./main.c:47: undefined reference to ___linent64’
/home/james/Desktop/WEGtest-64/./main.c:47: undefined reference to ___linent64' /home/james/Desktop/WEGtest-64/./main.c:50: undefined reference to ___linent64’
/home/james/Desktop/WEGtest-64/./main.c:53: undefined reference to ___linent64' main.o:/home/james/Desktop/WEGtest-64/./main.c:55: more undefined references to ___linent64’ follow
main.o: In function main': /home/james/Desktop/WEGtest-64/./main.c:130: undefined reference to ___rouret’
WEGprint.o: In function WEGprint': /home/james/Desktop/WEGtest-64/./WEGprint.c:34: undefined reference to ___rouent64’
/home/james/Desktop/WEGtest-64/./WEGprint.c:34: undefined reference to ___linent64' /home/james/Desktop/WEGtest-64/./WEGprint.c:37: undefined reference to ___linent64’
/home/james/Desktop/WEGtest-64/./WEGprint.c:37: undefined reference to ___linent64' /home/james/Desktop/WEGtest-64/./WEGprint.c:40: undefined reference to ___linent64’
/home/james/Desktop/WEGtest-64/./WEGprint.c:41: undefined reference to ___linent64' WEGprint.o:/home/james/Desktop/WEGtest-64/./WEGprint.c:42: more undefined references to ___linent64’ follow
WEGprint.o: In function WEGprint': /home/james/Desktop/WEGtest-64/./WEGprint.c:128: undefined reference to ___rouret’
InitializeScenarioData.o: In function InitializeScenarioData': /home/james/Desktop/WEGtest-64/./InitializeScenarioData.c:32: undefined reference to ___rouent64’
/home/james/Desktop/WEGtest-64/./InitializeScenarioData.c:32: undefined reference to ___linent64' /home/james/Desktop/WEGtest-64/./InitializeScenarioData.c:40: undefined reference to ___linent64’
/home/james/Desktop/WEGtest-64/./InitializeScenarioData.c:40: undefined reference to ___linent64' /home/james/Desktop/WEGtest-64/./InitializeScenarioData.c:41: undefined reference to ___linent64’
/home/james/Desktop/WEGtest-64/./InitializeScenarioData.c:43: undefined reference to ___linent64' InitializeScenarioData.o:/home/james/Desktop/WEGtest-64/./InitializeScenarioData.c:44: more undefined references to ___linent64’ follow
InitializeScenarioData.o: In function InitializeScenarioData': /home/james/Desktop/WEGtest-64/./InitializeScenarioData.c:237: undefined reference to ___rouret’
WAFmutex.o: In function InitMutex': /home/james/Desktop/WEGtest-64/./WAFmutex.c:28: undefined reference to ___rouent64’
/home/james/Desktop/WEGtest-64/./WAFmutex.c:28: undefined reference to ___linent64' /home/james/Desktop/WEGtest-64/./WAFmutex.c:30: undefined reference to ___linent64’
/home/james/Desktop/WEGtest-64/./WAFmutex.c:30: undefined reference to ___linent64' /home/james/Desktop/WEGtest-64/./WAFmutex.c:32: undefined reference to ___linent64’
/home/james/Desktop/WEGtest-64/./WAFmutex.c:34: undefined reference to ___linent64' WAFmutex.o:/home/james/Desktop/WEGtest-64/./WAFmutex.c:35: more undefined references to ___linent64’ follow
WAFmutex.o: In function InitMutex': /home/james/Desktop/WEGtest-64/./WAFmutex.c:77: undefined reference to ___rouret’
WAFmutex.o: In function LockMutex': /home/james/Desktop/WEGtest-64/./WAFmutex.c:87: undefined reference to ___rouent64’
/home/james/Desktop/WEGtest-64/./WAFmutex.c:87: undefined reference to ___linent64' /home/james/Desktop/WEGtest-64/./WAFmutex.c:89: undefined reference to ___linent64’
/home/james/Desktop/WEGtest-64/./WAFmutex.c:89: undefined reference to ___linent64' /home/james/Desktop/WEGtest-64/./WAFmutex.c:91: undefined reference to ___linent64’
/home/james/Desktop/WEGtest-64/./WAFmutex.c:92: undefined reference to ___linent64' WAFmutex.o:/home/james/Desktop/WEGtest-64/./WAFmutex.c:95: more undefined references to ___linent64’ follow
WAFmutex.o: In function LockMutex': /home/james/Desktop/WEGtest-64/./WAFmutex.c:96: undefined reference to ___rouret’

My makefile is as follows:




CC=pgcc
CFLAGS=-c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines
LDFLAGS= -lrt
SOURCES= main.c WEGprint.c InitializeScenarioData.c WAFmutex.c P_tra_ray2.c thread.c P_prc_typ2.c set_nod2.c env_nodb.c vlm_atnb.c tra_ray2.c zro_rng2.c lin_lin.c test_vlm_atn3.c prc_typ2.c ray_sgm2.c vlm_atn3.c ray_typ2.c test_ndx_tbl.c str_eig.c zsbl94.c snd_slw2.c ndx_tbl.c btm_dptb.c lwr_vtx2.c rfl_srf2.c rfl_btm2.c zbtms94.c zbtmrf9.c vrt_typ2.c dcm_sgm2.c vrt_tim2.c prc_ray2.c vrt_srf2.c srf_int2.c vrt_btm2.c btm_int2.c vrt_ray2.c gnr_seq.c chn_rfl2.c unfold2.c int_bnd2.c nrm_bnd2.c zblos94.c zbtmr04.c zsigmpr.c zsigmpv.c trn_mtx2.c adv_mtx2.c zelblos.c zbrlael.c WAFmathComplex.c zgsiz2des.c zgam.c zbeta.c WEG.c src_ang2.c prc_brn2.c merge.c IntSrcRays.c

OBJECTS=$(SOURCES:.c=.o)
EXECUTABLE=grab_64

all: $(SOURCES) $(EXECUTABLE)

$(EXECUTABLE): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) -o $@

.c.o:
$(CC) $(CFLAGS) $< -o $@


I am unsure as to why the undefined reference errors have suddenly popped up; It did not happen until I was working with the code for some time.

What is causing this.

Thanks in advance.

THX 1118

Hi THX 1138,

You need to add “-Mprof=lines” to both the compile and link lines. The problem here is that you forgot to include it on link line, hence the profiling libraries were not included on the link.

Note that you should choose one profile collection method, either instrumented (-Mprof) or sample based (pgcollect), but not both.

  • Mat

I did as you suggested and it still got some linking errors, I will show them now.

make
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 main.c -o main.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 WEGprint.c -o WEGprint.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 InitializeScenarioData.c -o InitializeScenarioData.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 WAFmutex.c -o WAFmutex.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 P_tra_ray2.c -o P_tra_ray2.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 thread.c -o thread.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 P_prc_typ2.c -o P_prc_typ2.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 set_nod2.c -o set_nod2.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 env_nodb.c -o env_nodb.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 vlm_atnb.c -o vlm_atnb.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 tra_ray2.c -o tra_ray2.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 zro_rng2.c -o zro_rng2.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 lin_lin.c -o lin_lin.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 test_vlm_atn3.c -o test_vlm_atn3.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 prc_typ2.c -o prc_typ2.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 ray_sgm2.c -o ray_sgm2.o
PGC-W-0155-Accelerator region ignored; see -Minfo messages (ray_sgm2.c: 692)
PGC-W-0155-Accelerator region ignored; see -Minfo messages (ray_sgm2.c: 707)
PGC-W-0155-Accelerator region ignored; see -Minfo messages (ray_sgm2.c: 797)
PGC/x86-64 Linux 12.5-0: compilation completed with warnings
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 vlm_atn3.c -o vlm_atn3.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 ray_typ2.c -o ray_typ2.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 test_ndx_tbl.c -o test_ndx_tbl.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 str_eig.c -o str_eig.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 zsbl94.c -o zsbl94.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 snd_slw2.c -o snd_slw2.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 ndx_tbl.c -o ndx_tbl.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 btm_dptb.c -o btm_dptb.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 lwr_vtx2.c -o lwr_vtx2.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 rfl_srf2.c -o rfl_srf2.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 rfl_btm2.c -o rfl_btm2.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 zbtms94.c -o zbtms94.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 zbtmrf9.c -o zbtmrf9.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 vrt_typ2.c -o vrt_typ2.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 dcm_sgm2.c -o dcm_sgm2.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 vrt_tim2.c -o vrt_tim2.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 prc_ray2.c -o prc_ray2.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 vrt_srf2.c -o vrt_srf2.o
PGC-W-0155-Accelerator region ignored; see -Minfo messages (vrt_srf2.c: 163)
PGC-W-0155-Accelerator region ignored; see -Minfo messages (vrt_srf2.c: 182)
PGC-W-0155-Accelerator region ignored; see -Minfo messages (vrt_srf2.c: 195)
PGC/x86-64 Linux 12.5-0: compilation completed with warnings
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 srf_int2.c -o srf_int2.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 vrt_btm2.c -o vrt_btm2.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 btm_int2.c -o btm_int2.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 vrt_ray2.c -o vrt_ray2.o
PGC-W-0155-Accelerator region ignored; see -Minfo messages (vrt_ray2.c: 100)
PGC/x86-64 Linux 12.5-0: compilation completed with warnings
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 gnr_seq.c -o gnr_seq.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 chn_rfl2.c -o chn_rfl2.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 unfold2.c -o unfold2.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 int_bnd2.c -o int_bnd2.o
PGC-W-0155-Accelerator region ignored; see -Minfo messages (int_bnd2.c: 167)
PGC-W-0155-Accelerator region ignored; see -Minfo messages (int_bnd2.c: 178)
PGC/x86-64 Linux 12.5-0: compilation completed with warnings
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 nrm_bnd2.c -o nrm_bnd2.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 zblos94.c -o zblos94.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 zbtmr04.c -o zbtmr04.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 zsigmpr.c -o zsigmpr.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 zsigmpv.c -o zsigmpv.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 trn_mtx2.c -o trn_mtx2.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 adv_mtx2.c -o adv_mtx2.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 zelblos.c -o zelblos.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 zbrlael.c -o zbrlael.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 WAFmathComplex.c -o WAFmathComplex.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 zgsiz2des.c -o zgsiz2des.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 zgam.c -o zgam.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 zbeta.c -o zbeta.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 WEG.c -o WEG.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 src_ang2.c -o src_ang2.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 prc_brn2.c -o prc_brn2.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 merge.c -o merge.o
pgcc -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines -m64 IntSrcRays.c -o IntSrcRays.o
pgcc -lrt -lm -Mprof=lines -m64 main.o WEGprint.o InitializeScenarioData.o WAFmutex.o P_tra_ray2.o thread.o P_prc_typ2.o set_nod2.o env_nodb.o vlm_atnb.o tra_ray2.o zro_rng2.o lin_lin.o test_vlm_atn3.o prc_typ2.o ray_sgm2.o vlm_atn3.o ray_typ2.o test_ndx_tbl.o str_eig.o zsbl94.o snd_slw2.o ndx_tbl.o btm_dptb.o lwr_vtx2.o rfl_srf2.o rfl_btm2.o zbtms94.o zbtmrf9.o vrt_typ2.o dcm_sgm2.o vrt_tim2.o prc_ray2.o vrt_srf2.o srf_int2.o vrt_btm2.o btm_int2.o vrt_ray2.o gnr_seq.o chn_rfl2.o unfold2.o int_bnd2.o nrm_bnd2.o zblos94.o zbtmr04.o zsigmpr.o zsigmpv.o trn_mtx2.o adv_mtx2.o zelblos.o zbrlael.o WAFmathComplex.o zgsiz2des.o zgam.o zbeta.o WEG.o src_ang2.o prc_brn2.o merge.o IntSrcRays.o -o grab_64
ray_sgm2.o: In function RAY_SGM2': /home/james/Desktop/WEGtest-64/./ray_sgm2.c:130: undefined reference to __pgi_cu_init’
/home/james/Desktop/WEGtest-64/./ray_sgm2.c:130: undefined reference to __pgi_cu_module3' /home/james/Desktop/WEGtest-64/./ray_sgm2.c:130: undefined reference to __pgi_cu_module_function3’
/home/james/Desktop/WEGtest-64/./ray_sgm2.c:130: undefined reference to __pgi_cu_alloc_a' /home/james/Desktop/WEGtest-64/./ray_sgm2.c:130: undefined reference to __pgi_cu_alloc_a’
/home/james/Desktop/WEGtest-64/./ray_sgm2.c:130: undefined reference to __pgi_cu_alloc_a' /home/james/Desktop/WEGtest-64/./ray_sgm2.c:130: undefined reference to __pgi_cu_alloc_a’
/home/james/Desktop/WEGtest-64/./ray_sgm2.c:130: undefined reference to __pgi_cu_uploadx_a' /home/james/Desktop/WEGtest-64/./ray_sgm2.c:130: undefined reference to __pgi_cu_uploadx_a’
/home/james/Desktop/WEGtest-64/./ray_sgm2.c:130: undefined reference to __pgi_cu_datadone_a' /home/james/Desktop/WEGtest-64/./ray_sgm2.c:131: undefined reference to __pgi_cu_launch_a’
/home/james/Desktop/WEGtest-64/./ray_sgm2.c:134: undefined reference to __pgi_cu_downloadx_a' /home/james/Desktop/WEGtest-64/./ray_sgm2.c:134: undefined reference to __pgi_cu_downloadx_a’
/home/james/Desktop/WEGtest-64/./ray_sgm2.c:134: undefined reference to __pgi_cu_datadone_a' /home/james/Desktop/WEGtest-64/./ray_sgm2.c:134: undefined reference to __pgi_cu_free_a’
/home/james/Desktop/WEGtest-64/./ray_sgm2.c:134: undefined reference to __pgi_cu_free_a' /home/james/Desktop/WEGtest-64/./ray_sgm2.c:134: undefined reference to __pgi_cu_free_a’
/home/james/Desktop/WEGtest-64/./ray_sgm2.c:134: undefined reference to __pgi_cu_free_a' /home/james/Desktop/WEGtest-64/./ray_sgm2.c:134: undefined reference to __pgi_cu_close’
/home/james/Desktop/WEGtest-64/./ray_sgm2.c:760: undefined reference to __pgi_cu_init' /home/james/Desktop/WEGtest-64/./ray_sgm2.c:760: undefined reference to __pgi_cu_module3’
/home/james/Desktop/WEGtest-64/./ray_sgm2.c:760: undefined reference to __pgi_cu_module_function3' /home/james/Desktop/WEGtest-64/./ray_sgm2.c:760: undefined reference to __pgi_cu_alloc_a’
/home/james/Desktop/WEGtest-64/./ray_sgm2.c:760: undefined reference to __pgi_cu_alloc_a' /home/james/Desktop/WEGtest-64/./ray_sgm2.c:760: undefined reference to __pgi_cu_alloc_a’
/home/james/Desktop/WEGtest-64/./ray_sgm2.c:760: undefined reference to __pgi_cu_alloc_a' /home/james/Desktop/WEGtest-64/./ray_sgm2.c:760: undefined reference to __pgi_cu_uploadx_a’
/home/james/Desktop/WEGtest-64/./ray_sgm2.c:760: undefined reference to __pgi_cu_uploadx_a' /home/james/Desktop/WEGtest-64/./ray_sgm2.c:760: undefined reference to __pgi_cu_datadone_a’
/home/james/Desktop/WEGtest-64/./ray_sgm2.c:761: undefined reference to __pgi_cu_launch_a' /home/james/Desktop/WEGtest-64/./ray_sgm2.c:764: undefined reference to __pgi_cu_downloadx_a’
/home/james/Desktop/WEGtest-64/./ray_sgm2.c:764: undefined reference to __pgi_cu_downloadx_a' /home/james/Desktop/WEGtest-64/./ray_sgm2.c:764: undefined reference to __pgi_cu_datadone_a’
/home/james/Desktop/WEGtest-64/./ray_sgm2.c:764: undefined reference to __pgi_cu_free_a' /home/james/Desktop/WEGtest-64/./ray_sgm2.c:764: undefined reference to __pgi_cu_free_a’
/home/james/Desktop/WEGtest-64/./ray_sgm2.c:764: undefined reference to __pgi_cu_free_a' /home/james/Desktop/WEGtest-64/./ray_sgm2.c:764: undefined reference to __pgi_cu_free_a’
/home/james/Desktop/WEGtest-64/./ray_sgm2.c:764: undefined reference to `__pgi_cu_close’
make: *** [grab_64] Error 2


The Makefile is shown:


CC=pgcc
CFLAGS= -c -ta=nvidia -O0 -Minfo=ccff -Mprof=lines
LDFLAGS= -lrt -lm -Mprof=lines
SOURCES= main.c WEGprint.c InitializeScenarioData.c WAFmutex.c P_tra_ray2.c thread.c P_prc_typ2.c set_nod2.c env_nodb.c vlm_atnb.c tra_ray2.c zro_rng2.c lin_lin.c test_vlm_atn3.c prc_typ2.c ray_sgm2.c vlm_atn3.c ray_typ2.c test_ndx_tbl.c str_eig.c zsbl94.c snd_slw2.c ndx_tbl.c btm_dptb.c lwr_vtx2.c rfl_srf2.c rfl_btm2.c zbtms94.c zbtmrf9.c vrt_typ2.c dcm_sgm2.c vrt_tim2.c prc_ray2.c vrt_srf2.c srf_int2.c vrt_btm2.c btm_int2.c vrt_ray2.c gnr_seq.c chn_rfl2.c unfold2.c int_bnd2.c nrm_bnd2.c zblos94.c zbtmr04.c zsigmpr.c zsigmpv.c trn_mtx2.c adv_mtx2.c zelblos.c zbrlael.c WAFmathComplex.c zgsiz2des.c zgam.c zbeta.c WEG.c src_ang2.c prc_brn2.c merge.c IntSrcRays.c

OBJECTS=$(SOURCES:.c=.o)
EXECUTABLE=grab_64

all: $(SOURCES) $(EXECUTABLE)

$(EXECUTABLE): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) -o $@

.c.o:
$(CC) $(CFLAGS) $< -o $@


I thought your suggestion took care of the problem, but it apparently did not.

Any help appreciated. Thanks in advance.

THX 1138

Now you’re missing the PGI Accelerator run time libraries. Add “-ta=nvidia”. Rule of thumb is to use the same optimisation flags on both the compile and link lines.

  • Mat